Skip to content

Commit

Permalink
Added current datetime properties to the Lua API
Browse files Browse the repository at this point in the history
Also deprecated the IsHalloween property in favour of them.
  • Loading branch information
penev92 committed Oct 17, 2023
1 parent 7515c18 commit 7121025
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions OpenRA.Mods.Common/Scripting/Global/DateTimeGlobal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public DateGlobal(ScriptContext context)
}

[Desc("True on the 31st of October.")]
[Obsolete("Use CurrentMonth and CurrentDay instead.")]
public bool IsHalloween => DateTime.Today.Month == 10 && DateTime.Today.Day == 31;

[Desc("Get the current game time (in ticks).")]
Expand All @@ -43,6 +44,13 @@ public int Seconds(int seconds)
return seconds * ticksPerSecond;
}

public int CurrentYear => DateTime.Now.Year;
public int CurrentMonth => DateTime.Now.Month;
public int CurrentDay => DateTime.Now.Day;
public int CurrentHour => DateTime.Now.Hour;
public int CurrentMinute => DateTime.Now.Minute;
public int CurrentSecond => DateTime.Now.Second;

[Desc("Converts the number of minutes into game time (ticks).")]
public int Minutes(int minutes)
{
Expand Down

0 comments on commit 7121025

Please sign in to comment.