defold-scripts-editing

Installation
SKILL.md

Editing Defold Script Files and Lua Modules

Defold has four Lua script types (each running in a different context with different APIs) and plain .lua modules for reusable logic.

For API details use defold-api-fetch skill. For conceptual manuals use defold-docs-fetch skill. This skill covers script structure, constraints, and templates.

Lua modules (.lua)

Plain .lua files are Lua modules used to encapsulate reusable logic. Extract frequently used universal logic into .lua modules — avoid duplication and keep scripts lean. Modules are required via require("path.to.module") (dots as path separators).

Defold projects typically use Lua shared state (shared_state in game.project). When enabled, all scripts, GUI scripts, and the render script run in the same Lua context. A Lua module required from any script has the same context and state within that single Lua interpreter instance — module-level locals and package.loaded are shared across all users of the module. Stateful modules behave like singletons.

Lua module structure (.lua)

Encapsulate data and functions in a local table, return it:

local M = {}
Related skills
Installs
1
GitHub Stars
62
First Seen
6 days ago