Script (Power Type)
Runs a script when the power is granted or revoked.
Runs a script when the power is granted to an entity or taken away again. Needs KubeJS — without it the power loads and logs once that no script backend is installed.
Type ID: apoli:script
Fields
| Field | Type | Default | Description |
|---|---|---|---|
on_added | Identifier | optional | Script to run when the power is granted. |
on_removed | Identifier | optional | Script to run when the power is revoked. |
params | NBT | optional | Values handed to the script as params. |
Example
{
"type": "apoli:script",
"on_added": "mypack:welcome",
"params": { "message": "Welcome to the coven." }
} // kubejs/server_scripts/coven.js
ApoliEvents.powerAdded('mypack:welcome', event => {
event.entity.tell(event.params.getString('message'))
}) This power type only covers grant and revoke, because that is the one thing you cannot compose. To run a script on a timer, use
apoli:action_over_timewith anapoli:scriptaction — you getinterval,onset_delay,rising_actionandfalling_actionfor free. To gate a power on a script, put anapoli:scriptcondition in the power’s owncondition.