Twine Version: sugarcube 2.36.1
Hello! I have racked my brain long enough on this and need some help. I have a very simple time system I picked up from some post that works by periods which almost works great for what I’m doing but the way it handles days has stopped progress all together. It will count the periods of the day then when it hits max periods it will switch to next day number then sign the number a week day name defined in storyinit but I can not find a way to make those weekday names in to a variable I can use.
/ story init /
/% 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 ["Early Morning", "Morning", "Noon", "Afternoon", "Evening", "Night", "Asleep"]>>
/% The current Game Day: Monday. %/
<<set $day to 1>>
/% The current Time Period: Morning. %/
<<set $period to 1>>
/ and the widgets /
<<widget "now">>
\It is <<print setup.DAYS[$day % 7]>>, <<print setup.PERIODS[$period]>>, Day $day.
<</widget>>
/*
* <<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.
*/
<<widget "AdvancePeriod">>
\<<silently>>
<<set _offset to 1>>
<<set _periodsInDay to setup.PERIODS.length>>
<<if $args.length > 0>>
<<set _offset to $args[0]>>
<</if>>
<<set $period += _offset>>
/% Update the Day Number as necessary. %/
<<if $period >= _periodsInDay>>
<<set $day += Math.trunc($period / _periodsInDay)>>
<<set $period to ($period % _periodsInDay)>>
<</if>>
<</silently>>\
<</widget>>
/*
* <<NextMorning>>
*
* Advances the current Time Period to the Morning of the next day.
*/
<<widget "NextMorning">>
\<<silently>>
/% 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 0>>
<</silently>>\
<</widget>>
It will count the days as numbers that keeps going up, so say if I wanted to do
<<if $day gte 0 and $day lte 6>>
<<if $period gte 0 and $period lte 5>>
[[walk in to school|school1]]
<</if>>
<</if>>
this works as it will not fire past the $day6 but the week doesn’t stop at day 7 it will call and print the next Monday as day 8
my question is are there anyways to make this stop at day7 and the next Monday restart to day1 then keep the day number from being printed or can I some how turn the day name in to a variable? I have tried to figure it out myself but i just started coding to make this game this month so I gave it a go but here I am.
any help would be appreciated!