Constructor


Event(x: number?, y: number?, width: number?, height: number?)

@param shape — Shape data for this event. First two indexes are the width and height of the object. The third (optional) index is polygon data.

Arguments:

x: number?
y: number?
width: number?
height: number?




Methods


Event:addFlag(flag: string, amt: number?)

Adds amount to a numeric flag named flag (or defines it if it does not exist)
This variant of Game:addFlag() interacts with flags specific to this event's unique id

@param flag — The name of the flag to add to

@param amt — (Defaults to 1)

Arguments:

flag: string

The name of the flag to add to

amt: number?

(Defaults to 1)

Returns:

new_value: number




Event:flash(sprite: Sprite?, offset_x: number?, offset_y: number?, layer: number?)

Causes this event to flash once

@param sprite — An optional sprite to use for the flash instead of the event's default sprite.

Arguments:

sprite: Sprite?

An optional sprite to use for the flash instead of the event's default sprite.

offset_x: number?
offset_y: number?
layer: number?

Returns:

1: FlashFade


Event:getFlag(flag: string, default: any)

Gets the value of the flag named flag, returning default if the flag does not exist
This variant of Game:getFlag() interacts with flags specific to this event's unique id

Arguments:

flag: string
default: any

Returns:

1: unknown


Event:getUniqueID()

Gets this Event instance's unique id within the whole mod The returned id follows the format #[map.id](file:///vercel/path0/tmp/kristal/luadoc_meta/class.lua#26)#[object_id](file:///vercel/path0/tmp/kristal/src/engine/game/world/event.lua#11) if a custom unique_id is not defined

Returns:

id: string?


Event:onAdd(parent: Object)

Called when the event is added as the child of another object

Arguments:

parent: Object

The base class of all objects in Kristal.
When added to the stage, an object will be updated and rendered.



Event:onClone(src: any)

Arguments:

src: any


Event:onCollide(player: Player, DT: number)

(Override) Called every frame the player and event are colliding with each other

Arguments:

player: Player

The character controlled by the player when in the Overworld.

DT: number


Event:onEnter(player: Player)

(Override) Called whenever the player enters this event

Arguments:

player: Player

The character controlled by the player when in the Overworld.



Event:onExit(player: Player)

(Override) Called whenever the player leaves this event

Arguments:

player: Player

The character controlled by the player when in the Overworld.



Event:onInteract(player: Player, dir: string)

(Override) Called whenever the player interacts with this event

@param player — The interacting Player

@param dir — The direction the player is facing

@return blocking — Whether this interaction should prevent other events in the interaction region activating with this frame

Arguments:

player: Player

The interacting Player

dir: string

The direction the player is facing

Returns:

blocking: boolean

Whether this interaction should prevent other events in the interaction region activating with this frame



Event:onLoad()

Runs once the map has finished loading



Event:onRemove(parent: Object)

Called when the event is removed

Arguments:

parent: Object

The base class of all objects in Kristal.
When added to the stage, an object will be updated and rendered.



Event:postLoad()

Runs once the entire world has finished loading



Event:setFlag(flag: string, value: any)

Sets the value of the flag named flag to value
This variant of Game:setFlag() interacts with flags specific to this event's unique id

Arguments:

flag: string
value: any


Event:setSprite(texture: string?, speed: number?, use_size: boolean?)

Changes the object's sprite

@param texture — The name of the new texture to set, removes the object's sprite if nil

@param speed — The speed at which the new sprite should animate if it has multiple frames

@param use_size — Whether to use the sprite's size for the event's size (defaults to true)

Arguments:

texture: string?

The name of the new texture to set, removes the object's sprite if nil

speed: number?

The speed at which the new sprite should animate if it has multiple frames

use_size: boolean?

Whether to use the sprite's size for the event's size (defaults to true)



Event:shake(x: number?, y: number?, friction: number?, delay: number?)

Shakes this Event by the specified amount, shaking the sprite instead if it exists

@param x — The amount of shake in the x direction. (Defaults to 4)

@param y — The amount of shake in the y direction. (Defaults to 0)

@param friction — The amount that the shake should decrease by, per frame at 30FPS. (Defaults to 1)

@param delay — The time it takes for the object to invert its shake direction, in seconds. (Defaults to 1/30)

Arguments:

x: number?

The amount of shake in the x direction. (Defaults to 4)

y: number?

The amount of shake in the y direction. (Defaults to 0)

friction: number?

The amount that the shake should decrease by, per frame at 30FPS. (Defaults to 1)

delay: number?

The time it takes for the object to invert its shake direction, in seconds. (Defaults to 1/30)



Event:shakeSelf(x: number?, y: number?, friction: number?, delay: number?)

Shakes this event by the specified amount

@param x — The amount of shake in the x direction. (Defaults to 4)

@param y — The amount of shake in the y direction. (Defaults to 0)

@param friction — The amount that the shake should decrease by, per frame at 30FPS. (Defaults to 1)

@param delay — The time it takes for the object to invert its shake direction, in seconds. (Defaults to 1/30)

Arguments:

x: number?

The amount of shake in the x direction. (Defaults to 4)

y: number?

The amount of shake in the y direction. (Defaults to 0)

friction: number?

The amount that the shake should decrease by, per frame at 30FPS. (Defaults to 1)

delay: number?

The time it takes for the object to invert its shake direction, in seconds. (Defaults to 1/30)



Event:stopShake()

Stops this event or its sprite from shaking



Event:stopShakeSelf()

Stops a shake applied directly to this event




Fields






Event.sprite: Sprite?

A simple object that renders a texture.
This texture must be placed inside assets/sprites/.



Event.world: World

The world that this event is contained in



Undocumented



Event._default_collider: unknown

Default collider (Object width and height)