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
@@ -2,6 +2,7 @@
2
2
usingSystem.Collections.ObjectModel;
3
3
usingSystem.Threading;
4
4
usingSystem.Threading.Tasks;
5
+
usingSystem.Xml.Serialization;
5
6
usingNLog;
6
7
usingTorch;
7
8
usingTorch.API;
@@ -26,45 +27,44 @@ public class AutoCommand : ViewModel
26
27
privatefloat_triggerRatio;
27
28
privatedouble_triggerCount;
28
29
30
+
[XmlIgnore]
31
+
publicboolCompleted{get;set;}
29
32
30
-
[Display(Name="Trigger",Description="Choose a trigger for the command")]
33
+
[Display(Order=3,Name="Trigger",Description="Choose a trigger for the command")]
31
34
publicTriggerCommandTrigger
32
35
{
33
36
get=>_trigger;
34
37
set=>SetValue(ref_trigger,value);
35
38
}
36
39
37
-
[Display(Name="Trigger Operator",Description="Choose a Ratio Comparer for the command")]
40
+
[Display(Order=6,Name="Trigger Operator",Description="Choose a comparer for the command")]
38
41
publicGtlCompare
39
42
{
40
43
get=>_comparer;
41
44
set=>SetValue(ref_comparer,value);
42
45
}
43
46
44
47
45
-
[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.")]
48
+
[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.")]
46
49
publicstringName
47
50
{
48
51
get=>_name;
49
52
set=>SetValue(ref_name,value);
50
53
}
51
54
52
-
[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.")]
55
+
//[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.")]
56
+
[Display(Visible=false)]
53
57
publicstringScheduledTime
54
58
{
55
59
get=>_scheduledTime.ToString();
56
60
set
57
61
{
58
62
_scheduledTime=TimeSpan.Parse(value);
59
63
OnPropertyChanged();
60
-
if(CommandTrigger!=Trigger.Scheduled)return;
61
-
_nextRun=DateTime.Now.Date+_scheduledTime;
62
-
if(_nextRun<DateTime.Now)
63
-
_nextRun+=TimeSpan.FromDays(1);
64
64
}
65
65
}
66
66
67
-
[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!")]
67
+
[Display(Order=2,Description="Sets an interval/Time for this command to be repeated. Format is HH:MM:SS.")]
68
68
publicstringInterval
69
69
{
70
70
get=>_interval.ToString();
@@ -78,18 +78,19 @@ public string Interval
78
78
_nextRun=DateTime.Now+_interval;
79
79
}
80
80
81
+
81
82
}
82
83
}
83
84
84
-
[Display(Name="Trigger Ratio",Description="Ratio for Sim Speed or Vote Trigger. 0.5 is equivalent to 50%")]
85
+
[Display(Order=5,Name="Trigger Ratio",Description="Ratio for Sim Speed or Vote Trigger. 0.5 is equivalent to 50%")]
0 commit comments