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

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-wide variables
  3. Controllers — gamepad input
  4. CoroutinesCo() wrapper
  5. Debugging — logging, ImGui, breakpoints
  6. 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