all at once
2.7 KiB
The localAnimator table provides bindings used by client side animation scripts (e.g. on objects and active items) to set drawables/lights and perform rendering actions.
void
localAnimator.playAudio(String
sound, [int
loops], [float
volume])
Immediately plays the specified sound, optionally with the specified loop count and volume.
void
localAnimator.spawnParticle(Json
particleConfig, Vec2F
position)
Immediately spawns a particle with the specified name or configuration at the specified position.
void
localAnimator.addDrawable(Drawable
drawable, [String
renderLayer])
Adds the specified drawable to the animator's list of drawables to be rendered. If a render layer is specified, this drawable will be drawn on that layer instead of the parent entity's render layer. Drawables set in this way are retained between script ticks and must be cleared manually using localAnimator.clearDrawables().
The drawable object must specify exactly one of the following keys to define its type:
- [
pair<Vec2F, Vec2F>
line] - Defines this drawable as a line between the specified two points. - [
List<Vec2F>
poly] - Defines the drawable as a polygon composed of the specified points. - [
String
image] - Defines the drawable as an image with the specified asset path.
The following additional keys may be specified for any drawable type:
- [
Vec2F
position] - Relative position of the drawable. - [
Color
color] - Color for the drawable. Defaults to white. - [
bool
fullbright] - Specifies whether the drawable is fullbright (ignores world lighting).
The following additional key may be specified for line drawables:
- [
float
width] - Specifies the width of the line to be rendered.
The following transformation options may be specified for image drawables. Note that if a transformation is specified, it will be used instead of other specific transformation operations.
- [
Mat3F
transformation] - [
bool
centered] - [
float
rotation] - [
bool
mirrored] - [
float
scale]
void
localAnimator.clearDrawables()
Clears the list of drawables to be rendered.
void
localAnimator.addLightSource(Json
lightSource)
Adds the specified light source to the animator's list of light sources to be rendered. Light sources set in this way are retained between script ticks and must be cleared manually using localAnimator.clearLightSources(). The configuration object for the light source accepts the following keys:
Vec2F
positionColor
color- [
bool
pointLight] - [
float
pointBeam] - [
float
beamAngle] - [
float
beamAmbience]
void
localAnimator.clearLightSources()
Clears the list of light sources to be rendered.