Skip to main content

Script (Bi-Entity Condition Type)

Passes when a script returns a truthy value for the pair. event.entity is the actor and event.target is the target.

Type ID: apoli:script

Fields

FieldTypeDefaultDescription
scriptIdentifierrequiredThe script to run. Either an ID registered from KubeJS with ApoliEvents, or the path of a .js file shipped in a data pack at data/<namespace>/apoli/scripts/<path>.js, in which case the .js is part of the ID.
paramsNBToptionalValues handed to the script. Read them with event.params from KubeJS, or params inside a data pack script. This is how one script serves several powers.

Example

Only glow for players who are on the same scoreboard team and below half health, two conditions that are easy apart and awkward together. The script goes in kubejs/server_scripts/pack_sense.js:

kubejs/server_scripts/pack_sense.js
ApoliEvents.bientityCondition('mypack:wounded_ally', event => {
  const a = event.entity, b = event.target
  if (!a.team || !b.team || a.team.name !== b.team.name) return false
  return b.health < b.maxHealth / 2
})
{
  "type": "apoli:entity_glow",
  "bientity_condition": {
    "type": "apoli:script",
    "script": "mypack:wounded_ally"
  }
}
note

This condition needs KubeJS. Without it the type still loads and the pack still works, but the call logs once and does nothing. Scripts always run on the server.