- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register




Search:

Listing Commands...

 View All

Found 1 match.
Nameforeach
Syntax - foreach [stop/next/<object>|...] (as:<name>) [<commands>]
Short DescriptionLoops through a ListTag, running a set of commands for each item.
Full DescriptionLoops through a ListTag of any type. For each item in the ListTag, the specified commands will be ran for
that list entry. To call the value of the entry while in the loop, you can use <[value]>.

Optionally, specify "as:<name>" to change the definition name to something other than "value".

To end a foreach loop, do - foreach stop

To jump immediately to the next entry in the loop, do - foreach next


Related Tags<[value]> to get the current item in the loop
<[loop_index]> to get the current loop iteration number

Usages

» Use to run commands 'for each entry' in a list of objects/elements.
- foreach <[some_entity]>|<[some_npc]>|<[player]>:
    - announce "There's something at <[value].location>!"


» Use to iterate through entries in any tag that returns a list
- foreach <server.online_players> as:player:
    - narrate "Thanks for coming to our server! Here's a bonus $50.00!" targets:<[player]>
    - give money qty:50 player:<[player]>

Groupqueue