Incorporating time into games


#1

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?
*choice
 #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.

#2

@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?


#3

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
*return

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
${mtime}.

This will display in military time.

Easy, right? :slight_smile: Hope this helps.


#4

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


#5

Oh, in that case, just take out the :

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


#6

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


#7

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: