Making InGame Clock to Determine Events

Ive been working on a SugarCube Game for Quite a while now and I’m wondering if anyone has a way to make a simple InGame Clock that counts down and can make Events happen, or some sort of Status Effect.

Games an RPG.

1 Like

I see nobody has ansewered yet, so I’ll try something not too technical yet absolutely not elegant.

You can set a $Time variable (I’d go from 0 to 24, or 0 to 1,440 if minutes are needed). You can also set à $Day variable.

Each action takes some time, you add it to $Time. If $Time is greater than 24 (or 1,440), you substract 24 (or 1,440) from current $Time and increase $Day.
If, for some reason, there’s a gap you reset $Time to whatever is convenient, and also $Day.
As far as you have $Day and $Time you could check if something happens.

Example StoryInit passage:

<<set $Day to 1>>
<<set $Time to 1380>>
<<set $Event0 to false>>
<<set $Event1 to false>>
<<set $Event2 to false>>

StoryCaption passage:

It's day $Day, <<if $Time%60 < 10>><<print Math.floor($Time/60)>>h0<<print $Time%60>><<else>><<print Math.floor($Time/60)>>h<<print $Time%60>><</if>>.

Events passage:

<<if $Time >= 1440>><<set $Day +=1>><<set $Time -=1440>><</if>>
<<set _clock to $Day*1440 + $Time>>
<<if $Event0 is false && _clock >= 3500>>
	<<link "Suddenly something happens.""Event0">><</link>> 
<<elseif $Event1 is false && _clock >= 3700>>>
	<<link "Suddenly something happens.""Event1">><</link>>
<<elseif $Event2 is false && _clock >= 4000>>>
	<<link "Suddenly something happens.""Event2">><</link>>
<<else>><<link "Nothing deters your plans" $Nextpassage>><</link>>
<</if>>

Example of a move from passage to passage:

<<link "You want to sleep" "Events".>><<set $Day +=1>><<set $Time to 480>><<set $Nextpassage to "Awaken">><</link>>

In this not so subtile example each passage leads to the “Events” passage. In this passage the clock is tested against whatever event might happen. If any event happens the normal flow of the game is interrupted, before returnung to whatever should have happened. If nothing happens, well the game goes on.

That’s a very heavy procedure, and absolutely not invisible. Some people here will no doubt offer you easier way.

1 Like

It might have a better look with modifying

<<else>><<link "Nothing deters your plans" $Nextpassage>><</link>>

by

<<else>><<include $Nextpassage>>

This would make the process less tedious for the reader as he won’t see that there was a check for events.

Thanks for replying! This has really been bugging me while creating my Game.

1 Like