Scripting Examples

This section is a cookbook, not a minimal tutorial. The examples are adapted from the Test chronicle sandbox and rewritten with neutral names, safer guards, and comments that explain why each engine field is touched.

Use these pages by intent:

Goal Page
Air control, run/walk speed tiers, wall jumps, rolling movement, charge movement Movement And Input
Spawn projectiles, move projectiles, persistent hitboxes, stationary effects, projectile bursts Projectiles And Items
Blocks, parries, break specials, weapon-specific move overrides, hit-pause reactions Combat And Defense
Front grabs, grab walking, air grabs, piledriver-style throws, victim positioning Grabs And Throws
Pack-level pre/post update scripts, wall bounce, juggle/multi-hit rules, recovery escape Global Update Hooks
Entity-level enemy behaviour, targeting, distance gates, hook/fall setup, scripted attack selection Enemy AI

How To Read These Examples

Every example has three jobs:

  • show a complete script, returning its update function, that can be attached to an animation, an enemy entity, or a global hook
  • explain the internal engine state that makes the script work
  • show when to return true and when to return false

The numbers are intentionally visible. Animation IDs, frame numbers, offsets, velocities, and object_mode values are part of scripting. Change them to match your own character's animations and sprite alignment. For Classic behaviour values, use Entity Types and Behaviour Modes.

Common Adaptation Rules

  • Replace pack names, entity names, sound names, and animation IDs with your own data.
  • Keep the nil guards unless the script is absolutely guaranteed to run in one context.
  • If the script calls check_hitting_entities, moves position_offset_y, or calls update_position_and_check_world_collisions, it probably owns that frame and should return false.
  • If the script only sets a parameter, spawns once on a frame, or nudges input state before animation behaviour, it can usually return true.
  • Use custom_value_1 through custom_value_10 for per-object script state, not Lua locals, when the value must survive across frames. Locals outside the update function are shared by every object using the script and are not rolled back.
  • Avoid math.*; the gameplay sandbox does not register the Lua math module.

Example Style

The examples prefer documented snake_case names:

character.current_animation_frame
character.position_offset_y
character.hit_pause_timer

The runtime also accepts exact bridge names such as currentAnimationFrame, but mixing styles makes scripts harder to review.