Loop
Executes an action for the specified amount of iterations.
Type ID: eggolib:loop
Fields
Field | Type | Default | Description |
---|---|---|---|
before_action |
Action Type | optional | If specified, this action will be executed before the loop starts. |
action |
Action Type | optional | If specified, this action will be executed for each iteration of the loop. |
after_action |
Action Type | optional | If specified, this action will be executed after the loop ends. |
score |
Scoreboard | optional | If specified, this value will be used as the amount of iterations for the loop. |
value |
Integer | optional | If specified and if score is not specified, this value will be used as the amount of iterations for the loop. |
Examples
"entity_action": {
"type": "eggolib:loop",
"action": {
"type": "apoli:execute_command",
"command": "say Hello!"
},
"value": 3
}
This example will make the entity that invoked the action say "Hello!" thrice.
"entity_action": {
"type": "eggolib:loop",
"action": {
"type": "apoli:heal",
"amount": 2
},
"score": {
"name": "amountOfHeals",
"objective": "example"
}
}
This example will heal the entity that invoked the action depending on the score of the amountOfHeals
score holder in the example
scoreboard objective. If it doesn't exist, the action will simply do nothing.
"entity_action": {
"type": "eggolib:loop",
"before_action": {
"type": "apoli:execute_command",
"command": "tag @s add temp"
},
"action": {
"type": "apoli:heal",
"amount": 2
},
"after_action": {
"type": "apoli:execute_command",
"command": "tag @s remove temp"
},
"score": {
"name": "@e[tag = temp, limit = 1]",
"objective": "example"
}
}
This example will heal the entity that invoked the action depending on the score of the said entity in the example
scoreboard objective.