Jump to content

Pausing & Resetting Timers in Urwigo


YawningFox

Recommended Posts

Hello! I'm building a cartridge in Urwigo where every minute, an antagonist moves to a different location. The player must finish their tasks within 15 minutes, too. Some of my dialogue is lengthy, so I didn't want players to feel like they have to skip through it all in order to move quickly enough and/or avoid the antagonist. Because of this, I added a function before and after dialogue that "stop"s all timers and then "start"s them again when the conversation is over. In testing, though, it seems that the timers stop and then reset completely. For example, if I had 13 minutes remaining on my 15 minute timer and then talked to someone, it would then have 15 minutes remaining once the conversation ended. I do want to reset my timers at specific times, like when the player runs into the antagonist or runs out of time, after which a new round is started, but I'd also like to be able to pause the timers and then start them from where they were before the pause. Is this possible on countdown and interval timers?

 

TLDR: Is there a way to pause interval and countdown timers and then have them continue from where they were in Urwigo?

 

Thank you so much for your help and time!

Link to comment

Timers are rudimentary.  You can start and stop them, but can't poll the remaining time or pause them.

 

What we usually do is set a smaller interval timer, such as five seconds.  When the timer elapses, we increment a variable that represents the number of times this timer has elapsed.  We can then perform tests based on this.  You can then stop and start the smaller timer without worry.

 

Thus, some pseudocode on the smaller timer's elapsed event:

  • Increment the number of times this timer has elapsed
  • If the number of times this timer has elapsed is greater than or equal to 15 x (60 / 5), perform the game over routine
    • Note: the math works out so it's the number of times the timer can elapse in 15 minutes if the timer elapses every five seconds
  • Else if the number of times this timer has elapsed is cleanly divisible by 60, move the antagonist
    • Note: this is called modulus.  Since I don't believe you can do this through the Urwigo UI, you could always maintain a second timer elapsed variable, incrementing both the game order and the antagonist move variables when the timer elapses.  When you move the antagonist, you set the antagonist move variable to zero, thereby resetting it.
  • Else don't do anything
  • Helpful 1
Link to comment

That is such a good idea! I tested out the incremental variables for both the 15 minute and antagonist-moving timers, and not only do they work perfectly now, but my code also looks a lot cleaner (I previously had 9 timers to remind the player how much time they have left, but I can now use if/else to have all the messages in one timer!) I'm also able to give the player statistics on their performance at the end by displaying the variables. That tip really made my Wherigo a lot more feasible for the player. Thank you so much for your help, Ranger Fox!

Link to comment

You're very welcome.  Anything to reduce complexity and make cartridges easier to work with is a plus.

 

To make things even more fun, you could put a timer object in inventory.  You could make the name look like "300 seconds remaining", then adjust the name every timer tick.  You might have to enable and disable the object to notify the player app that the name changed.  Theoretically, you could also do the same for a zone's name.  I do not, however, know off the top of my head how player apps will react with regard to their navigation UI if you change the zone's name, then disable and enable it to force the UI update.  That is, if a navigation compass is displayed and the zone briefly has its enabled state toggled, I'm not sure if the compass UI will continue to be shown.  That's why I was going with the item idea instead.

 

Enjoy!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...