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

FieldTypeDefaultDescription
on_addedIdentifieroptionalScript to run when the power is granted.
on_removedIdentifieroptionalScript to run when the power is revoked.
paramsNBToptionalValues 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_time with an apoli:script action — you get interval, onset_delay, rising_action and falling_action for free. To gate a power on a script, put an apoli:script condition in the power’s own condition.