Revision as of 11:13, 4 May 2012 by Scimonster (talk | contribs) (Transcribed an image.)

There are many methods to make a script perform an action for a set amount of time. This tutorial will cover the simplest of them.

This script uses the timer. It will repeat the action until the timer is greater than the set limit.

These timer-based repeater scripts can be used in many different ways. The one pictured is for a sprite that will continuously move to the right for the set amount of time.

when green flag clicked
go to x:(x location) y: (y location)
reset timer
repeat until <(timer) > (limit)>
  change x by (1)
  • x location is the x of where the sprite goes to before it starts.
  • y location is the y of where the sprite goes to before it starts.
  • limit is how long the action should be repeated for (e.g. if the limit were 10, the sprite would drift to the right for 10 seconds).

If the timer is already being used and cannot be reset without ruining the project, a variable can be used instead of the timer:

when gf clicked
set [seconds v] to [0] //enter amount of time to repeat for
repeat until <(seconds) = [0]>
 wait (1) secs
 change [seconds v] by (1)

when gf clicked
repeat until <(seconds) = [0]>
 do action