Creating an in-game timer / countdown?


#1

How do you set up an artificial timer? I want to use it for status effects that eventually wear off, or for delayed scenes that pop up a few days after you trigger it, and so on.

My game is played using a calendar system, so I keep track of an arbitrary ingame date (day 1, day 2, etc). I want to create an event countdown so that after a week passes in-game, a certain scene is triggered.

so far this is my very simplistic method, it involves injecting a few lines of code to every “day” of the game.

*create timer 0

When the timer starts:
*set timer 7

Add this check to every day of the game:
*set timer -1
*if timer = 1
–*gosub list_of_triggered_events

I plan to modify the mini-scene system found here, so there’ll be another .txt file with all the delayed events which will trigger depending on your variables.

The problem is that I can’t have overlapping status effects or events. I’d have to create multiple timers for that, which would make the code really clunky.

Is there a more elegant solution available?


#2

I use a similar event system, and have resorted to putting all of the checks and timer stuff on a completely separate scene that sorts it out:

*set timer1 - 1
*set timer2 - 1

~and so on~

*if timer1 = 1
    *goto_scene event1
*if timer2 = 1
    *goto_scene event2

~and so on~

*set jumped true
*if current_scene = "scene 1"
    *goto_scene scene_1
*if current_scene = "scene 2"
    *goto_scene scene_2

so I only have to put something like this in every scene:

*if jumped
    *set jumped false
    *goto dayend

The day plays out.

*set current_scene "scene 1"
*goto_scene timer
*label dayend

#3

looks good, ill give it a whirl.

Does tbis mean you have a separate scene for every day of your game?


#4

No, that’s just a very basic version of my Sorter-o-Doom. You can adapt it to include multiple event checks (corresponding to each day) in each scene by creating different “jumped” variables that will direct the player back to the proper spot in the scene.

Instead of:

*if jumped
    *set jumped false
    *goto dayend

what I have at the top of the scenes tends to look something like this, which lets me return the player to one of four different points in the scene:

*comment ---scene returns---
*if event1return
    *set event1return false
    *set event1 "none"
    *goto event2
*if event2return
    *set event2return false
    *goto event2
*if tracereturn
    *set tracereturn false
    *goto freetimeend
*if activityreturn
    *set activityreturn false
    *goto activityend

Just keep in mind that every time you leave the scene and return it’s going to erase any *temp variables you may have.