How do I pick the lowest duration timer from 3 timers with the same tag?

0 favourites
  • 4 posts
From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • So I have 3 timers all with the same tag & would like to know if it's at all possible to pick the one with the lowest duration left?

    I am using the timer behavior for clarification.

  • The first thing that comes to mind is to use an array. For each object that has that timer running, push timer.duration-timer.currenttime, and the object's uid into an array. Sort the array to get his of the object with the lowest duration remaining.

    If they all had the same duration to begin with you can just push and remove the object uid directly into an array, first in first out.

    Or are they all on the same object? If you elaborated on your set up and how you are using the timers there may be better approaches. For finer control over timers you would normally use different tags.

    EDIT: Below is a better idea.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can also do it by setting an instance variable to the timer value and then using pick highest/lowest. Because timers count up you would pick the highest variable in order to get the instance with the least time remaining.

    Example: onedrive.live.com/redir

  • Cheers for your time guys! I agree, I think the second one is a good idea as you both recommended.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)