Time issues

Twine Version: 2.3.15
Story Format: SugarCube

I had a great time system working here a little bit ago, one that would simply cycle through $dayPart each time I used a gametime if statement. That gametime if statement still works, the number goes up by one each time it’s called up, but now for whatever reason it’s not translating the numerical value to the day specified:
Whenever I ask the StoryCaptions passage to print $gameTime it prints the number instead of what that number should mean (1-morning, 2-evening, etc.)
I know there is something small I’m doing wrong, but I can’t for the life of me figure it out. Any help would be greatly appreciated!

//this part is in the StoryInit passage.//
<<set setup.dayPart = ["Morning", "Afternoon", "Evening", "Night"]>>
<<set $gameTime = "2">>
//this part is in the StoryCaption passage.//
<<print 'Time of day: $gameTime'>>
//it just says Time of day: 2//

You have to actually tell it to print a value from the array if that’s what you want it to print. For example:

''Time of day:'' <<print setup.dayPart[$gameTime]>>

(Note: The two single-quotes on each side of “Time of day:” is to make the text show up as bold, and isn’t required, it just looks nice.)

However, you need to make sure that $gameTime is set to an actual number value, and not a string, so it should be set like this:

<<set $gameTime = 2>>

without the quotes around the number. Putting the quotes around the number like you did makes it into a string, thus you couldn’t use that text to indicate which element in the array you want. The array index has to be an actual number value, not a string with a number in it.

Hope that helps! :slight_smile:

Just plugged that in and it worked perfect, thank you so much! :slight_smile: