Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Event: Repeat

tenebraemaximus edited this page Sep 16, 2013 · 5 revisions

Syntax: {entity}.start.{nameOfRepeat}.{delay}[.{count}]
Where delay is the delay between each time it runs in ticks (20 ticks = 1 second), and count is after how many repeats to terminate the repeat automatically. Leave blank for unlimited repeats.

The Repeat Event is an easy way of running a bunch of routines over and over again either a fixed number of times or indefinitely. You can start and stop repeats via the start and stop routines like in the examples. If the entity is not a player and dies, the repeat will stop. If you want a repeat to stop when a Player dies, you must stop it explicitly in the Death event.

If you give a count, inside the repeat event repeat_count will be the number of repeats left before it terminates. If you don't give a count, it will be set to -1, which will cause the repeat to run forever.

Repeats are designed to never have more than one repeat of the same name running on the same entity at once. This means you are safe to use the start routine as much as you want. If you specify a count in the second start and the previous count is positive, it will be added to the previous count. If you do not specify a count in the second one, it will be set to -1.

Both repeat_count and repeat_delay are settable inside the repeat, so you can do fun things like the second example.

Repeats can also be set on a world. When doing so, the 'world_name' must be specified in the repeat.

Example:

Command:
    - 'startrep':
        - 'sender.start.repeatthis.20' # infinite, same as count of -1
    - 'startrep #num':
        - 'sender.start.repeatthis.20.num'
    - 'stoprep':
        - 'sender.stop.repeatthis'

Repeat:
    - 'repeatthis':
        - 'message.entity': 'Repeating! Count: %{repeat_count}'

In this example, the delay between the repeats is set to the count at each repeat, so each repeat will happen 1 tick faster than the last.

Command:
    -'blah #num':
        - 'sender.start.blah.20.num'
    - 'noblah':
        - 'sender.stop.blah'
Repeat:
    - 'blah':
        - 'message.entity': 'blah %{repeat_count}'
        - 'set.repeat_delay': 'repeat_count'

When starting a repeat on a world:

Init:
    - 'if world.named.world_nether':
        - 'world.start.repeat1.100'
Repeat:
    - 'repeat1 world_nether':
        - 'message.server': "This message is being broadcast as a result of a world repeat"

Or

Init:
    - 'worldnamed_worldy.start.repeater.1'
Repeat:
    - 'repeater worldy':
        - 'message.server': "SPAMMMMMM"
Clone this wiki locally