The following shows how to setup a very basic Block based time system.
1. Place the following within your StoryInit special passage.
It defines the names of the "Days of the Week" and of the "Time Periods in a Day" on the special setup variable so that they aren't added to the story's saves. It also defines the $day and $period story variables which are used to track the current day and period respectively.
/% The names of the Days of the Week. %/
<<set setup.DAYS to ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>>
/% The names of the Time Periods of a Day. %/
<<set setup.PERIODS to ["Asleep", "Morning", "Noon", "Afternoon", "Evening", "Night"]>>
/% The current Game Day: Monday. %/
<<set $day to 1>>
/% The current Time Period: Morning. %/
<<set $period to 1>>
NOTE: The comments within the above (and proceeding) code examples can be safely removed, they are only there to try and add some clarity to what is happening.
2. Place the following within a widget tagged Passage.
(The name of the passage isn't important and can be whatever you like, I named mine StoryWidgets)
* Displays the current Day of Week, Period of Day and Day Number.
\It is <<print setup.DAYS[$day % 7]>>, <<print setup.PERIODS[$period]>>, Day $day.
* <<AdvancePeriod [number of periods]>>
* Advance current Time Period by a set number of periods, if no number
* if pass to widget then current Time Period is advanced by 1 unit.
* <<AdvancePeriod>> Advances time period by 1 unit.
* <<AdvancePeriod 1>> Advances time period by 1 unit.
* <<AdvancePeriod 2>> Advances time period by 2 units.
* If the current day's time boundary is exceeded then the Day Number
* will also be updated.
<<set _offset to 1>>
<<set _periodsInDay to setup.PERIODS.length>>
<<if $args.length > 0>>
<<set _offset to $args>>
<<set $period += _offset>>
/% Update the Day Number as necessary. %/
<<if $period >= _periodsInDay>>
<<set $day += Math.trunc($period / _periodsInDay)>>
<<set $period to ($period % _periodsInDay)>>
* Advances the current Time Period to the Morning of the next day.
/% Increament the Day Number by 1 unit. %/
<<set $day += 1>>
Set the current Time Period to the index of the
"Morning" element of setup.PERIODS array.
<<set $period to 1>>
...the following is a simple example of how to use the above widgets.
<<link "Advance period by 1 unit">>
<<link "Advance period by 3 units">>
<<link "Advance period by 10 units">>
You will of noted that the PERIODS array defined in point 1 includes an extra period at the start of the day named "Asleep". I did this so that you can have events that occur while the Main Character is asleep (eg. Dreams, etc...), which would otherwise between the last period of a day "Night" when they go to bed and the start of the next day "Morning" when they wake up. You can obviously rename that period (or any other) to whatever makes sense to you.