Incorporating time into games

I’m developing a game where time is an integral part. However, I’m trying to find the best way to code it in. So far what I’ve done is something similar to this:

You just finished making a COG game.
The time is ${time} ${PM}.
What else do you want to do?
 #Make another one.
  *set time +3
  *goto doublethreat".

And then, if noon happens:
`*if ((time >= 12) and (pm = "am"))
  *set pm "pm``

I would appreciate if  anyone could offer some insight on how to make this more efficient. Ideally, I want to get it to a military time.
1 Like

@Lordirish has posted a very thorough clock system…is that something like what you are wanting, or are you looking for a more limited-scope, less complex timer?


If you’re looking for a realistic, real-world sort of clock feature…

*create htime 12
*create mtime 0

(hour time and minute time)
(setting it this way would start the time at noon)

*label timetrack
*if htime > 24
*set htime -24
*if mtime > 59
*set mtime -60
*set htime +1

Then, any time you want an action to take a certain amount of time… you can add that in hours and minutes. Eg.
*set htime +2
*set mtime +30
*gosub_scene clock timetrack
(or whatever scene your timetrack is in)
(two hours and thirty minutes.)

Then, any time you want to display the time- you just write
{htime}: *if mtime = 0 00. *if ((mtime > 0) and (mtime < 10)) 0{mtime}.
*if mtime > 9

This will display in military time.

Easy, right? :slight_smile: Hope this helps.


I took a look at that. Ideally, I just want minutes and seconds displayed in military time (e.g 0900, 2100, etc…)


Oh, in that case, just take out the :

*if htime < 10
*if htime > 9
{htime} *if mtime = 0 00. *if ((mtime > 0) and (mtime < 10)) 0{mtime}.
*if mtime > 9


Thanks. That’s exactly what I’m aiming for.


it is nice to see an informative and genteel soul around these parts once more. I was afraid an editing monster had driven @Fiogan down a hole or sumsuch. :frowning: