Gametime works with negative gametime values as well. You can set up random ages with code like this.
NewGameSetup.cs
usingstaticInfinityPBR.LegendOfTheStones.Game;usingstaticInfinityPBR.Modules.Timeboard;usingstaticInfinityPBR.Modules.StatsRepository;//.....foreach (Player player ingame.data.players){ var years =18*timeboard.gametime.GameTimePerYear;var months =timeboard.gametime.GameTimePerMonth*Random.Range(0,timeboard.gametime.MonthsPerYear-1);var days =timeboard.gametime.GameTimePerDay*Random.Range(0,timeboard.gametime.DaysPerMonth-1);var age = years + months + days *-1; // Use the "Properties" feature of Game Modules to easily grab // the uid of the Stat scriptable object.var ageStatUid =Properties.Stats.MainStats.AgeUid; // Set the age to be the gameTime value for when the player was bornplayer.stats.Get(ageStatUid).SetPoints(age); // ... // Later we can convert the gameTime value to years // This subtracts the birth gameTime (Stored in the stat "Age") from // the "Now()" gametime, and gets the year from the result gameTime. // We call "false" at the end to avoid adding the startYear to the // year value.var agePoints =player.stats.Get(ageStatUid).Points; var playerAgeInYears =timeboard.gametime.GetYear((Now(false) - agePoints),false);}
Subscribe to TimeMod
In this example, a UI element subscribes to the TimeMod of the Timeboard and updates the text value when the TimeScale changes.