A standard Varwin object that is used for timing. It is a "technical" object - it is not displayed to the player in play mode, but its blocks are triggered according to the selected logic.

Blockly

The main interaction with the timer takes place inside the built-in Blockly logic editor

The default block types for the object are as follows:

Logic blocksLink to Logic blocks

Contains a block that returns one of the following three timer states:

  • suspended
  • started
  • stopped

Action BlocksLink to Action Blocks

Contains blocks for starting a timer with different timing modes, pausing or resuming it.

Start timer with interval N and duration/number of triggers MLink to Start timer with interval N and duration/number of triggers M

After calling this action, the event "Timer triggered" is triggered every N seconds. After M seconds the timer stops and the "Timer Ended" event is called.

Start once for the set time NLink to Start once for the set time N

The function "Start timer once for the set time N" is called

The function starts a single timer countdown of N seconds. After their expiry the timer stops.

Start infinitely with interval NLink to Start infinitely with interval N

The function "Start infinite timer with interval N" is called.

The function starts an infinite timer that can count down time with the set interval N until it is stopped.

Pause/Resume/StopLink to Pause/Resume/Stop

Action blocks that allow you to pause, resume, or stop the timer completely.

VariablesLink to Variables

Contains blocks of variables with the possibility of selecting the timer value

  • From the moment of its triggering
  • From the previous triggering
  • To the next triggering
  • To end

EventsLink to Events

Event blocks that react to start or stop the timer and trigger the events "Timer triggered" or "Timer ended"

Examples of use

Standard timerLink to Standard timer

In this example, when the world is initialized, a timer with an interval of 1 second and a number of triggers of 60 starts, that is, after 60 seconds the timer must end. The next block is a reaction block to the timer event: when the timer triggers, the blocks with functions within this block start to execute, - text is displayed on the text panel (you can read more about text panels here) indicating the remaining number of triggers until the timer finishes. The third block responds to the event "Timer ended", which automatically occurs when the timer finishes and performs the functions embedded in it; in this case, the block prints the text about the "Timer finished".

The difference between the duration timer and the number-of-times timerLink to The difference between the duration timer and the number-of-times timer

The duration timer works by the second regardless of the interval. If the user sets the timer visual display, he will see that with an interval of 2 and a duration of 60 seconds, the timer will only count to 30 seconds, because 2 seconds elapse between each second display, as the user has set.

The number of triggers timer runs until the timer reaches the number of triggers M. In other words, the counting occurs regardless of the time. If the user sets a visual display of the timer, he will see that with an interval of 2 and a duration of 60 seconds, the timer will count to 60, but it will take 120 seconds because it will take two seconds to count each second because the user has set the interval to 2.