# A question of time - HELP!

For the game I am creating I want to have a time system. Each choice you make will take an amount of time which will be checked periodically throughout the game.
I can do this as a simple number, but that has limitations. It would be hard to add a line of code saying “The time is now {time}" as that would just display the time number... it wouldn't make sense. I could say "{time} minutes have passed since you started racing”, but again this is not easy for the reader to follow. Especially as they get further into the story and the minutes become hours. It wouldn’t be fun for the reader to have to convert 468 minutes into hours, then add that to their starting time to work out the current time!

Anyway, the point of this thread:

Does anyone have any ideas on how I can add time for each of the decisions you make. (2 mins, 5 mins, 30 mins, etc.)

AND

Display that time accurately as hours and minutes.

Any help will be very much appreciated and warrant a mention in the credits to my game.

The modulo operator would be good for converting time measurements, but I don’t think it’s implemented.

Try this workaround:

*set time 126
*comment in this example, 126 minutes have passed. I assume, you have the time var in mygame.js

*gosub show_time
*comment should display: 2 hours and 6 minutes have passed.
*finish

*label show_time
*temp m
*set m time
*temp h
*set h 0
*temp diff
*set diff 0

*label loop
*set diff m - 60
*if diff > 0
*set h + 1
*set m - 60
*goto loop
*else
*if h > 0
{h} hours and {m} minutes have passed.
*return
*else
\${m} minutes have passed.
*return

I haven’t tested that code, but it should give you a general idea of how to do it.

As for adding time, I’d just decide how much time any given segment takes and put a *set time + 42 at its end, where 42 is the number of minutes you want that segment to take.
Hope that helps.

Cheers,
Simon

That’s great Simski! I didn’t think of using a loop like that. Thanks, I’ll play around with it and give you a mention when I finish my game.