You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated codes for autocommands
OnStart Command now only runs immediately on session ready ONCE.
Removed ScheduledTime in autocommands
Add method to convert ScheduleTime to Interval for commands with Scheduled Trigger (new method)
Co-authored-by: Olatide F <tide1988@live.com>
Copy file name to clipboardExpand all lines: Essentials/AutoCommand.cs
+17-15Lines changed: 17 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
usingSystem.Runtime.CompilerServices;
5
5
usingSystem.Threading;
6
6
usingSystem.Threading.Tasks;
7
+
usingSystem.Xml.Serialization;
7
8
usingNLog;
8
9
usingTorch;
9
10
usingTorch.API;
@@ -31,45 +32,44 @@ public class AutoCommand : ViewModel
31
32
privatefloat_triggerRatio;
32
33
privatedouble_triggerCount;
33
34
35
+
[XmlIgnore]
36
+
publicboolCompleted{get;set;}
34
37
35
-
[Display(Name="Trigger",Description="Choose a trigger for the command")]
38
+
[Display(Order=3,Name="Trigger",Description="Choose a trigger for the command")]
36
39
publicTriggerCommandTrigger
37
40
{
38
41
get=>_trigger;
39
42
set=>SetValue(ref_trigger,value);
40
43
}
41
44
42
-
[Display(Name="Trigger Operator",Description="Choose a Ratio Comparer for the command")]
45
+
[Display(Order=6,Name="Trigger Operator",Description="Choose a comparer for the command")]
43
46
publicGtlCompare
44
47
{
45
48
get=>_comparer;
46
49
set=>SetValue(ref_comparer,value);
47
50
}
48
51
49
52
50
-
[Display(Description="Sets the name of this command. Use this name in conjunction with !admin runauto to trigger the command from ingame or from other auto commands.")]
53
+
[Display(Order=1,Description="Sets the name of this command. Use this name in conjunction with !admin runauto to trigger the command from ingame or from other auto commands.")]
51
54
publicstringName
52
55
{
53
56
get=>_name;
54
57
set=>SetValue(ref_name,value);
55
58
}
56
59
57
-
[Display(Name="Scheduled Time",GroupName="Schedule",Description="Sets a time of day for this command to be run. Format is HH:MM:SS. MUST use 24 hour format! Will be reset to zero if Interval is set.")]
60
+
//[Display(Name = "Scheduled Time", GroupName = "Schedule", Description = "Sets a time of day for this command to be run. Format is HH:MM:SS. MUST use 24 hour format! Will be reset to zero if Interval is set.")]
61
+
[Display(Visible=false)]
58
62
publicstringScheduledTime
59
63
{
60
64
get=>_scheduledTime.ToString();
61
65
set
62
66
{
63
67
_scheduledTime=TimeSpan.Parse(value);
64
68
OnPropertyChanged();
65
-
if(CommandTrigger!=Trigger.Scheduled)return;
66
-
_nextRun=DateTime.Now.Date+_scheduledTime;
67
-
if(_nextRun<DateTime.Now)
68
-
_nextRun+=TimeSpan.FromDays(1);
69
69
}
70
70
}
71
71
72
-
[Display(Description="Sets an interval for this command to be repeated. Format is HH:MM:SS. Will be reset to zero if Scheduled Time is set!")]
72
+
[Display(Order=2,Description="Sets an interval/Time for this command to be repeated. Format is HH:MM:SS.")]
73
73
publicstringInterval
74
74
{
75
75
get=>_interval.ToString();
@@ -83,18 +83,19 @@ public string Interval
83
83
_nextRun=DateTime.Now+_interval;
84
84
}
85
85
86
+
86
87
}
87
88
}
88
89
89
-
[Display(Name="Trigger Ratio",Description="Ratio for Sim Speed or Vote Trigger. 0.5 is equivalent to 50%")]
90
+
[Display(Order=5,Name="Trigger Ratio",Description="Ratio for Sim Speed or Vote Trigger. 0.5 is equivalent to 50%")]
0 commit comments