I’m new to coding and to working with twine/ sugarcube, so I’m looking for any help if possible. I’ve found a decent code that I’m trying to implement into a game I’m developing for a basic time look with phases for the day and I’m encountering trouble with making it work. Any help would be greatly appreciated. Here is the code I’m using in a StoryInIt passage:
> /* Game Date */
> <<set setup.datePart = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]>>
> <<set $gameDate = 0>>
>
> /* Game Time */
> <<set setup.dayPart = ["Morning", "Afternoon", "Evening", "Night"]>>
> <<set $gameTime = 0>>
>
> <<if setup.dayPart[$gameTime] is "Night">>
> <<set $gameTime = 0>>
> <<endif>>
>
> <<if setup.dayPart[$gameTime] is "Morning">>
> You wake up in the morning feeling refreshed.
> <<endif>>
>
> <<set $gameTime = ($gameTime + 1) % setup.dayPart.length>>
>
> <<if setup.datePart[$gameDate] is "Sunday">>
> <<set $gameDate = 0>> // Start again from Monday
> <<else>>
> <<set $gameDate = ($gameDate + 1) % setup.datePart.length>> //Increase game date
> <<endif>>
To display the day and time period on the sidebar I’m using the following code in a StoryCaption passage:
> Date: <<=setup.datePart[$gameDate]>>
> Time: <<=setup.dayPart[$gameTime]>>
When I run the game to test it shows the following error message on the sidebar:
> Error: <<=>>: bad evaluation: Cannot read properties of undefined (reading 'undefined')
>
>
> <<=setup.datePart[$gameDate]>>
>
Any help is greatly appreciated. Sorry if this is posted in the wrong place. I’m new here. Thanks