defold-scripts-editing
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 = {}
More from indiesoftby/defold-agent-config
defold-project-setup
Downloads Defold project dependencies into .deps/ folder. Also provides recommended game.project settings. Use FIRST before any other task when .deps/ folder is missing or empty, or after editing dependency URLs in game.project. Also use when creating a new project, configuring game.project, or asking about recommended project settings.
10defold-docs-fetch
Fetches Defold manuals and documentation. Use when looking up how Defold features work, understanding concepts, components, workflows, platform setup, or needing guidance beyond API reference.
2defold-api-fetch
Fetches Defold API documentation. Use when working with Defold engine APIs, looking up Lua/C++ functions, or needing API reference for game development.
1xmath-usage
Provides xmath API reference and in-place math optimization patterns for Defold. Use when writing performance-critical math code, optimizing vector/quaternion/matrix operations, or when the user mentions xmath, zero-allocation math, or reducing Lua GC pressure.
1monarch-screen-setup
Organizes screens and popups in a Defold game using Monarch screen manager. Use when creating new screens, popups, or setting up navigation between them.
1defold-skill-maintain
Maintains Defold agent skills. Use when asked to update link lists in api-fetch/docs-fetch/examples-fetch skills, create or update proto file references, or fetch proto schemas.
1