Skip to content

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.

Getting started

  1. Basics — Lua syntax, Behaviour skeleton, imports
  2. ClassesClass.new, inheritance
  3. Globals — global types and functions
  4. Lifecycle Methodsinit, update, rendergui, …
  5. Properties — inspector fields and links
  6. Editor Tools — Studio-only Lua scripts and inspector actions
  7. TSL Shaders — custom materials and backgrounds (JavaScript)

Core workflows

  1. Scene Graph — Items vs SceneObjects, find, create, transform
  2. Asset Loading/resources/... paths and Loader
  3. Prefabs — spawn prefab instances at runtime
  4. Promises and Await — async loading and creation
  5. Events — input, pick, collisions, variables
  6. Node Game Eventsnode:on (goalReached, jump, …)

Gameplay systems

  1. Physics Scripting — raycasts, forces, collisions
  2. Math and Transforms — Vector3, Transform, frame timing
  3. Materials — textures and materials from scripts
  4. Audio — SgAudio and positional sound
  5. Particles — particle system control
  6. Canvas and HUD Overlays — 2D HUD drawing
  7. Navmesh — pathfinding agents
  8. Storage — client-side save data

Architecture and tools

  1. Cross-Behaviour Calls — call methods on other scripts
  2. Variable Sets — project and per-node variables
  3. Structured Data — project JSON tables from Lua
  4. Controllers — gamepad input
  5. CoroutinesCo() wrapper
  6. Debugging — logging, ImGui, breakpoints
  7. 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
Node game events Node Game Events
Save games Storage
Inspector fields Properties
Editor workflows Editor Tools
Custom shading TSL Shaders
Vehicles SgVehicle
Player controller SgPlayer
Nav / AI agents Navigation and AI
Nav Crowd agent SgAgent
Nav obstacles SgObstacle