Tracking time differently
Local_Redditor
25 Sept 2021, 16:07I want to make a time system where there will be 4 times in a day (Morning, Afternoon, Night, Midnight) and want to track which day it is too (Don't want to track month). I don't want to have time progress automatically, I want the time and/or day to progress if either the player sleeps, or if they encounter an event that changes the time and/or accordingly. I did try to make one using 2 attributes, one tracking the time of day while the other tracks the day as a whole, but I didn't know how to link both of them together. I have seen the clock library, but don't know how to use it or don't really want to use it.
I have been asking a lot of questions here, I'm just getting hooked onto quest that's all.
mrangel
25 Sept 2021, 16:26I'd suggest having an attribute game.time
that tracks the current time as a single number. 0 could be morning day 1, 1 would be afternoon day 1, 3 would be midnight, and 4 would be the morning of day 2. Then any command or event that involves time passing can do game.time = game.time + 1
or similar.
You can access the separate parts using a changescript. For example, create a script attribute game.changedtime
(this will run automatically whenever a script changes game.time
). You could have it do something like:
game.day = game.time / 4 + 1
game.timeofday = ListItem (Split ("morning;afternoon;night;midnight"), game.time % 4)
This means that game.timeofday
and game.day
will change automatically when game.time
is changed; so you can look at those whenever a script needs to know what time it is.
mrangel
25 Sept 2021, 17:54Oh, if you want day of week, you could add:
game.weekday = ListItem (Split ("mon;tue;wed;thur;fri;sat;sun"), game.day % 7)
Local_Redditor
26 Sept 2021, 13:15How would I display this time?
mrangel
26 Sept 2021, 16:13Same way you display any attribute. You can include it in messages, or add day
, weekday
and/or timeofday
to the game's statusattributes.