Scripting
Lemonate game logic is written in Lua as scripts attached to scene objects. Most scripts are Behaviours that run during play; Editor tools are a separate script type for Studio-only workflow helpers. This section covers language basics, engine workflows, and patterns for building games in Studio.
Recommended reading order
Getting started
- Basics — Lua syntax, Behaviour skeleton, imports
- Classes —
Class.new, inheritance - Globals — global types and functions
- Lifecycle Methods —
init,update,rendergui, … - Properties — inspector fields and links
- Editor Tools — Studio-only Lua scripts and inspector actions
- TSL Shaders — custom materials and backgrounds (JavaScript)
Core workflows
- Scene Graph — Items vs SceneObjects, find, create, transform
- Asset Loading —
/resources/...paths and Loader - Prefabs — spawn prefab instances at runtime
- Promises and Await — async loading and creation
- Events — input, pick, collisions, variables
Gameplay systems
- Physics Scripting — raycasts, forces, collisions
- Math and Transforms — Vector3, Transform, frame timing
- Materials — textures and materials from scripts
- Audio — SgAudio and positional sound
- Particles — particle system control
- Canvas and HUD Overlays — 2D HUD drawing
- Navmesh — pathfinding agents
- Storage — client-side save data
Architecture and tools
- Cross-Behaviour Calls — call methods on other scripts
- Variable Sets — project-wide variables
- Controllers — gamepad input
- Coroutines —
Co()wrapper - Debugging — logging, ImGui, breakpoints
- Procedural Content — build levels from code
Coming from other languages
API reference
Module and type documentation lives in API Reference. The scripting guides above explain how to use the APIs; the reference lists every method and field.
Topic index
| Topic | Page |
|---|---|
| Scene objects | Scene Graph |
| Load assets | Asset Loading |
| Spawn prefabs | Prefabs |
| Physics | Physics Scripting |
| HUD / 2D overlay | Canvas and HUD Overlays |
| Async / loading | Promises and Await |
| Input events | Events |
| Save games | Storage |
| Inspector fields | Properties | |
| Editor workflows | Editor Tools |
| Custom shading | TSL Shaders |
| Vehicles | SgVehicle |