Dren Posted April 2, 2023 Share Posted April 2, 2023 I need to set a variable to the number of days that have passed since the apocalypse first started, in order to determine if certain zombie types have evolved yet or not (imagine a certain zombie starts appearing after 30 days, for example) Functions like "getGameTime():getDay()" only get the current day of the month, and "getGameTime():getDaysSurvived()" resets whenever the player dies, so that won't work either. I would think there is a built in variable for this, used to determine things like the level of erosion in the world? Is there a more practical way to do this besides doing all the math to compare the starting day/month/year to current day/month/year? Thank you for the help! Link to comment Share on other sites More sharing options...
Dren Posted April 2, 2023 Author Share Posted April 2, 2023 (edited) I think I figured it out! I used the mod "Kayli's Evolution Mod" for reference. function getTime (year, month, day, hour, minute) return os.time{ year = year, month = month, day = day, hour = hour, min = minute} end function CalculateEvoDays() local nowTime = getTime( getGameTime():getYear(), getGameTime():getMonth(), getGameTime():getDay(), 0, 0) local startTime = getTime( getGameTime():getStartYear(), getGameTime():getStartMonth() - (getSandboxOptions():getTimeSinceApo() -1), getGameTime():getStartDay(), 0, 0) EvoDays = os.difftime(nowTime, startTime) / 86400 end The "CalculateEvoDays()" function runs every night at midnight, which sets the "EvoDays" variable to the number of days since apocalypse. Edited April 2, 2023 by Dren Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now