Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Starting a timer with a variable?

Basicly, I'm in a room and every 30 seconds a monster is added to this room, everything works perfect until I enter battle. The timer keeps on going in the battle and whenever it reaches 0 the battle just stops and the game continues acting like I won it (without winning it nor losing it.) So my question is, is it possible to start up the timer with a variable? From what I have seen it is definitely possible to save the timer in a variable, but I haven't found a way yet to recall it.
Thanks in advance,
GlennDH
 

Zeriab

Sponsor

The encounter being an event is good news.
1. In the event save the timer in an event. Let's say you save it in variable 42.
2. Stop the timer (you wouldn't want it to mess up the battle)
3. Do the battle
4. Put this in a call script to continue the timer:
[ruby]t = $game_variables[42]
t = t * Graphics.frame_rate
$game_system.timer = t
$game_system.timer_working = true
[/ruby]

Notice the t = $game_variables[42] part. Just change 42 to another number if you want to use another variable. (Do not use any leading zeros. I.e. 008 is wrong while 8 correct)

As a final note having a variable based time is easier, especially if you have random encounters, since it will not run during battles. The down side is that it will not be shown. (You can event it, but that's far to tedious)

*hugs*
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top