Scripting Guide

Attach gameplay logic to entities using ScriptComponent lifecycle callbacks and CollisionCallbackComponent for collision events.

# ScriptComponent

ScriptComponent attaches three lifecycle callbacks to an entity: on_start, on_update, and on_destroy. All callbacks are optional — only provide the ones you need.

script_component.jl

# Callback Signatures

Each callback receives the entity ID and a context object. The on_update callback additionally receives the frame delta time.

signatures.jl

# Error Budget

Scripts that throw exceptions accumulate an error count. After exceeding the budget (default: 5 errors), the script's callbacks are automatically disabled to prevent log spam and performance degradation.

error_budget.jl

# Example: Rotating Cube

A complete example attaching a script that rotates a cube around the Y axis at 90 degrees per second.

rotating_cube.jl

# CollisionCallbackComponent

CollisionCallbackComponent provides enter/stay/exit collision events. The engine tracks collision pairs across frames using a CollisionEventCache to determine transitions.

collision_callback.jl

# Example: Collision Detection

A pickup item that logs a message when another entity enters its trigger volume.

collision_example.jl