Script (Power Type)
Runs a script when the power is granted to an entity or taken away again. It needs KubeJS. Without KubeJS the power still loads, and the log says once that no script backend is installed.
Type ID: apoli:script
Fields
| Field | Type | Default | Description |
|---|---|---|---|
on_added | Identifier | optional | The script to run when the power is granted. |
on_removed | Identifier | optional | The 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." }
}The script it runs, in kubejs/server_scripts/coven.js:
kubejs/server_scripts/coven.js
ApoliEvents.powerAdded('mypack:welcome', event => {
event.entity.tell(event.params.getString('message'))
})tip
This power only covers granting and revoking, because those can't be built from other types. To run a script on a timer, use apoli:action_over_time with an apoli:script action, which gives you interval, onset_delay, rising_action and falling_action. To make a power depend on a script, put an apoli:script condition in the power's own condition.