# Adding time to clock won't make it move

The variable \$time is in minutes

``````<<set \$time to 1440>>

<<if \$time > 1440>>
<<set \$et to \$time - 1440>>
<<set \$time to 0 + \$et>>
<<endif>>

<<set \$hr to Math.trunc(\$time/60)>>

<<if \$time < 60>>
<<set \$hr to 12>>
<<endif>>

<<set \$min to \$time%60>>

<<if Math.trunc(\$min/10) < 1>>
<<set \$min to "0" + \$min>>
<<endif>>

<<if \$time < 720>>
<<set \$ampm to "am">>
<<set \$clock = \$hr + ":" + \$min + \$ampm>>

<<elseif \$time == 1440>>
<<set \$hr -= 12>>
<<set \$ampm to "am">>
<<set \$clock = \$hr + ":" + \$min + \$ampm>>

<<elseif \$time > 780>>
<<set \$hr -= 12>>
<<set \$ampm to "pm">>
<<set \$clock = \$hr + ":" + \$min + \$ampm>>

<<elseif \$time >= 720>>
<<set \$ampm to "pm">>
<<set \$clock = \$hr + ":" + \$min + \$ampm>>

<<endif>>``````

Might have made it more difficult than it should have been. I am not very good in coding.

The problem that I am facing is that I am trying to add time after the player clicks on sleep

``<<click "Wake up">><<set \$time += 5>><<goto [[Start of a new day]]>><</click>>``

It still shows the time that was set above which is 12:00 am and not 12:05 am

I have no idea what went wrong.

+1 vote
by (44.7k points)

If "<<set \$time to 1440>>" is at the start of your clock code, then that will keep setting the time back to midnight.

Take that line out of your clock code, put it in your StoryInit passage, and then it should work.

by (130 points)
The thing is, that is the init. Should I have made another passage for clock?

If so, how do I implement it to the story?

Also, what should be in the init and what shouldn't be in the init?

Sorry for asking so many questions, I started using twine two days ago and am not too sure what to do and not to do.