Twine Version: 2.6.2
So I’m sorry for making so many questions on this topic, but I’m really stumped. My posts below were my previous posts (and have context for the variables and constants)
https://intfiction.org/t/help-with-day-time-cycle/66043?u=tennshii
https://intfiction.org/t/help-with-resetting-weekdays-for-day-time-cycle/66053?u=tennshii
I have the day/time cycle nearly complete, I just wanted to add a working month roll-over system that also increases the year by one. However I get the following error when I move to a passage that uses my <add-time>
widget.
Error: <<add-time>>: errors within widget code (Error: cannot find a closing tag for macro <<if>>; Error: child tag <</if>> was found outside of a call to its parent macro <<if>>)
It’s skipping going through all the times of day, going from Morning to Noon to the next day. It also doesn’t properly switch months (I set $gameMonth = 0
and $monthDay = 31
but the next day shows January 32th instead of February 1st). Below is my code in my time cycle widget and StoryInit in that order:
/* Changes the time of day by one */
/* Use <<add-time>> multiple times to pass more time for the same passage */
<<widget "add-time">>
<<set $gameTime += 1>>
/* If it is midnight, execute following function */
<<if setup.time[$gameTime] == "Midnight">>
/* If it is Saturday, the day will roll-over to Sunday */
<<if setup.dateDay[$gameDay] == "Saturday">>
/* Interrupts clicked on passages to display sleep message */
<<done>>
<<replace "#regular-content">>
It's getting late. You decide to head to bed before you feel more tired.
<br><br><<button "Okay.">>
/* Player wakes up at their alarm time */
<<set $gameTime = $playerAlarm>>
<<set $totalDays += 1>>
<<set $monthDay += 1>>
<<set $gameDay = 0>>
/* month code start */
<<if setup.dateMonth[$gameMonth] == "December">>
<<if $monthDay = 31>>
<<set $gameMonth = 0>>
<<set $gameYear += 1>>
<</if>>
<<elseif setup.dateMonth[$gameMonth] == "January" or "March" or "May" or "July" or "August" or "October">>
<<if $monthDay = 31>>
<<set $gameMonth += 1>>
<</if>>
<<elseif setup.dateMonth[$gameMonth] == "April" or "June" or "September" or "November">>
<<if $monthDay = 30>>
<<set $monthDay = 0>>
<<set $gameMonth += 1>>
<</if>>
<<elseif setup.dateMonth[$gameMonth] == "February">>
<<if ($gameYear/4) = 0>>
<<if $monthDay = 29>>
<<set $monthDay = 0>>
<<set $gameMonth += 1>>
<</if>>
<</if>>
<<if ($gameYear/4) != 0>>
<<if $monthDay = 28>>
<<set $monthDay = 0>>
<<set $gameMonth += 1>>
<</if>>
<</if>>
/* month code end */
<</if>>
<<goto [[Disclaimer]]>>
<</button>>
<</replace>>
<</done>>
/* If the day is not Saturday, the day will continue forward */
<<else>>
/* Interrupts clicked on passages to display sleep message */
<<done>>
<<replace "#regular-content">>
It's getting late. You decide to head to bed before you feel more tired.
<br><br><<button "Okay.">>
/* Player wakes up at their alarm time */
<<set $gameTime = $playerAlarm>>
<<set $totalDays += 1>>
<<set $monthDay += 1>>
<<set $gameDay += 1>>
/* month code start */
<<if setup.dateMonth[$gameMonth] == "December">>
<<if $monthDay = 31>>
<<set $gameMonth = 0>>
<<set $gameYear += 1>>
<</if>>
<<elseif setup.dateMonth[$gameMonth] == "January" or "March" or "May" or "July" or "August" or "October">>
<<if $monthDay = 31>>
<<set $gameMonth += 1>>
<</if>>
<<elseif setup.dateMonth[$gameMonth] == "April" or "June" or "September" or "November">>
<<if $monthDay = 30>>
<<set $monthDay = 0>>
<<set $gameMonth += 1>>
<</if>>
<<elseif setup.dateMonth[$gameMonth] == "February">>
<<if ($gameYear/4) = 0>>
<<if $monthDay = 29>>
<<set $monthDay = 0>>
<<set $gameMonth += 1>>
<</if>>
<</if>>
<<if ($gameYear/4) != 0>>
<<if $monthDay = 28>>
<<set $monthDay = 0>>
<<set $gameMonth += 1>>
<</if>>
<</if>>
/* month code end */
<<goto [[Disclaimer]]>>
<</button>>
<</replace>>
<</done>>
<</if>>
<</if>>
<</widget>>
/* Constants */
// Total number of days the player has played
<<set $totalDays = 1>>
// The current month +1
<<set $gameMonth = 0>>
// The current day of the month
<<set $monthDay = 31>>
// Tracks what day it is (eg. 0 is Sunday)
<<set $gameDay = 0>>
// Tracks the time of day
<<set $gameTime = 1>>
// Player's wake up time
<<set $playerAlarm = 1>>
// The current year
<<set $gameYear = 2023>>
// School days passed
<<set $schoolDays = 0>>
/* Game Date */
// Determines what the current month is
<<set setup.dateMonth = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]>>
// Determines what day it is
<<set setup.dateDay = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>>
// Determines the time of the day
<<set setup.time = ["Dawn", "Morning", "Noon", "Afternoon", "Evening", "Night", "Midnight"]>>