Namespace Engine::LuaAPI¶
Namespace List > Engine > LuaAPI
Namespaces¶
| Type | Name |
|---|---|
| namespace | Internal |
Public Functions¶
| Type | Name |
|---|---|
| void | openStandardLibraries (lua_State * L) Opens the standard Lua libraries on the state. |
| void | registerAnimation (sol::state_view lua, Registry & registry) Registers the animation bindings in the Component namespace. MirrorsEngine 'sAnimationPlugin / AnimationComponent. |
| void | registerAudio (sol::state_view lua, Registry & registry) |
| void | registerCamera (sol::state_view lua, Registry & registry) |
| void | registerCollider (sol::state_view lua, Registry & registry) Registers collider bindings in the Component namespace. MirrorsEngine 'sColliderPlugin /ColliderComponent . |
| void | registerComponentQuery (sol::state_view lua, Registry & registry) Registers the cross-component query half of the Component namespace:Component.has(entity, tag) andComponent.remove(entity, tag) . |
| void | registerConnections (sol::state_view lua, Registry & registry) Registers Godot-style connection bindings in the Component namespace. |
| void | registerController (sol::state_view lua, Registry & registry) Registers the Controller namespace: action-based input backed by theEngine 'sInputManager /Controller (one file perEngine plugin). |
| void | registerEngineAPI (lua_State * L, Registry & registry) Registers every Engine API module into the Lua state. |
| void | registerEntity (sol::state_view lua, Registry & registry) Registers the Entity namespace: create/destroy/queueDestroy/find/getName/setName. |
| void | registerInput (sol::state_view lua) Registers the Input namespace: keyboard polling, mouse position, and theKEY.* constant table. MirrorsEngine 'sInputPlugin /Controller (keyboard + mouse devices). |
| void | registerLog (sol::state_view lua) Registers the log namespace and the globalprint .log.error is a user error: the editor Console shows it and the terminal worker writes it.print ,log.info , andlog.debug go to the terminal only. |
| void | registerMultiplayer (const sol::state_view & lua, Registry & registry) |
| void | registerOpacity (sol::state_view lua, Registry & registry) Registers opacity bindings in the Component namespace. MirrorsEngine 'sOpacityPlugin /Opacity component. |
| void | registerParent (sol::state_view lua, Registry & registry) Registers parenting bindings in the Component namespace. MirrorsEngine 'sHierarchyPlugin /Parent component. |
| void | registerPool (sol::state_view lua, Registry & registry) |
| void | registerPosition (sol::state_view lua, Registry & registry) Registers the position half of the Transform namespace: getPosition ({x, y, z}) / setPosition (x, y [, z]) / translate / getZIndex / setZIndex. MirrorsEngine 'sPositionPlugin /PositionSystem . |
| void | registerRotation (sol::state_view lua, Registry & registry) Registers the rotation half of the Transform namespace: getRotation / setRotation / rotate. MirrorsEngine 'sRotationPlugin . |
| void | registerScene (sol::state_view lua, Registry & registry) Registers the Scene namespace:Scene.load(name) andScene.current() . |
| void | registerScript (const sol::state_view & lua, Registry & registry) Registers script-attachment bindings in the Component namespace. MirrorsEngine 'sScriptComponent /ScriptSystem . |
| void | registerShape (sol::state_view lua, Registry & registry) Registers Component.addShape . MirrorsEngine 'sShapePlugin /ShapeComponent . |
| void | registerSprite (sol::state_view lua, Registry & registry) Registers the sprite bindings in the Component namespace. MirrorsEngine 'sSpritePlugin /SpriteComponent . |
| void | registerText (sol::state_view lua, Registry & registry) Registers Component.addText . MirrorsEngine 'sTextPlugin /Text component. |
| void | registerTime (sol::state_view lua) Registers the Time namespace (Time.time ,Time.deltaTime ). |
Public Functions Documentation¶
function openStandardLibraries¶
Opens the standard Lua libraries on the state.
Parameters:
LRaw Lua state.
function registerAnimation¶
Registers the animation bindings in the Component namespace. MirrorsEngine 'sAnimationPlugin / AnimationComponent.
Getters return nil (or false) when the entity has no Animation component. The clip state is advanced by AnimationSystem; scripts only pick a clip and toggle playback.
Component.addAnimation(entity, pathsOrSheet [, frameWidth, frameHeight, totalFrames, frameDuration, loop])-> boolComponent.playAnimation(entity, clipName [, restartIfSame])-> boolComponent.getAnimation(entity)-> clip name or nilComponent.getAnimationClips(entity)->{name1, name2, ...}or nilComponent.setAnimationPlaying(entity, playing)-> boolComponent.isAnimationPlaying(entity)-> boolComponent.getAnimationFrame(entity)-> frame index or nilComponent.setAnimationFlip(entity, flipX [, flipY])-> boolComponent.getAnimationFlip(entity)->{flipX = bool, flipY = bool}or nil
pathsOrSheet is either a table of frame image paths (one clip from multiple files) or a single spritesheet path sliced with frameWidth and frameHeight.
Parameters:
luaView of the shared Lua state.registryECS registry; also owns the AssetManager resource.
function registerAudio¶
function registerCamera¶
function registerCollider¶
Registers collider bindings in the Component namespace. MirrorsEngine 'sColliderPlugin /ColliderComponent .
Component.addBoxCollider(entity, w, h [, isTrigger [, isStatic]])-> bool Reconfigures an existing collider in place: the shape is always replaced, but layer/mask/enabled (and any flag that was not passed) are preserved.Component.getColliderSize(entity)-> {w, h, width, height} table or nilComponent.setColliderSize(entity, w, h)-> boolComponent.getColliderEnabled(entity)-> bool or nilComponent.setColliderEnabled(entity, v)-> boolComponent.getColliderTrigger(entity)-> bool or nilComponent.setColliderTrigger(entity, v)-> boolComponent.getColliderStatic(entity)-> bool or nilComponent.setColliderStatic(entity, v)-> boolComponent.getColliderLayer(entity)-> int or nilComponent.getColliderLayerName(entity)-> string or nilComponent.setColliderLayer(entity, layerOrName)-> boolComponent.getColliderMask(entity)-> int or nilComponent.setColliderMask(entity, mask)-> boolComponent.collidersCanCollide(a, b)-> bool (the CollisionSystem pair filter)Component.isColliding(entity)-> bool (polls CollisionSystem contacts)Component.getCollisions(entity)-> array table of other entity ids
Also registers the Layers namespace: Layers.name(i), Layers.index("Enemy"), Layers.bit(i | "Enemy"), Layers.all, Layers.none, Layers.count.
Removal uses the existing generic Component.remove(entity, "Collider").
Parameters:
luaView of the shared Lua state (used at registration time only).registryECS registry used to add the Collider component.
function registerComponentQuery¶
Registers the cross-component query half of the Component namespace:Component.has(entity, tag) andComponent.remove(entity, tag) .
These two functions dispatch across every registered component type, so they deliberately live in their own file referred to by every component module.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry used to query and remove components.
function registerConnections¶
Registers Godot-style connection bindings in the Component namespace.
Component.connect(emitter, signal, target, method)-> bool (idempotent: re-connecting the exact tuple returns true without duplicating, so script reloads that re-run onCreate stay clean; false on dead emitter/target or unknown signal)Component.disconnect(emitter, signal [, target [, method]])-> bool (true when anything was removed)Component.getConnections(emitter)-> array of {signal, target, method} tables
Connections are plain data on SignalConnections: the target method is re-resolved at dispatch, so they survive save/load and script reloads.
Parameters:
luaView of the shared Lua state (used at registration time only).registryECS registry holding the entities.
function registerController¶
Registers the Controller namespace: action-based input backed by theEngine 'sInputManager /Controller (one file perEngine plugin).
Exposes:
* Controller.isActionActive(action [, playerId])
* Controller.getActiveActions([playerId])
* Controller.addKeybind(action, key [, deviceType [, composeKey [, playerId [, networked]]]]) networked (default false) marks the bind's action as sent to the server in player_input.
* Controller.hasController([playerId])
* Controller.KEYBOARD / MOUSE / GAMEPAD / TOUCH device constants
Player IDs default to 1. The InputManager resource and the player controller are created on demand so Lua-first workflows (no C++ recompilation, editor preview with no C++ keybind setup) work. Application::PreUpdate already calls InputManager::Update() every frame, so scripts only query / bind.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry holding the InputManager resource.
function registerEngineAPI¶
Registers every Engine API module into the Lua state.
Called once by ScriptSystem on its first Update. After this returns, Lua scripts can call Entity .*, Transform.*, Component.*, Input .*, Time.*, Scene.*, log.* and print.
Parameters:
LRaw Lua state.registryECS registry handed to the component-backed modules.
function registerEntity¶
Registers the Entity namespace: create/destroy/queueDestroy/find/getName/setName.
queueDestroy defers destruction to FlushQueues (end of frame) and is the only safe destroy inside signal/collision callbacks.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry used for entity creation, lookup, and Name.
function registerInput¶
Registers the Input namespace: keyboard polling, mouse position, and theKEY.* constant table. MirrorsEngine 'sInputPlugin /Controller (keyboard + mouse devices).
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).
function registerLog¶
Registers the log namespace and the globalprint .log.error is a user error: the editor Console shows it and the terminal worker writes it.print ,log.info , andlog.debug go to the terminal only.
Corresponds to the Engine logging subsystem (Logging/Logger.hpp).
Parameters:
luaView of the shared Lua state.
function registerMultiplayer¶
function registerOpacity¶
Registers opacity bindings in the Component namespace. MirrorsEngine 'sOpacityPlugin /Opacity component.
Component.setOpacity(entity, alpha [, inherit])-> bool (creates or updates, alpha clamped to [0, 1])Component.getOpacity(entity)-> alpha number or nilComponent.setOpacityInherit(entity, inherit)/ get flag for the "inherit to children" checkbox
Removal uses the existing generic Component.remove(entity, " Opacity ").
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry holding the entities.
function registerParent¶
Registers parenting bindings in the Component namespace. MirrorsEngine 'sHierarchyPlugin /Parent component.
Component.setParent(child, parent [, relative])-> boolComponent.getParent(entity)-> parent id or nilComponent.getChildren(entity)-> array table of child idsComponent.flipX(entity)-> bool
flipX mirrors a whole rig: the entity's sprite flips and every descendant's footprint is reflected about the entity's centre, so children (front sensors, mounts) swap sides. It is a toggle, meant to be called once per direction change; Component.getSpriteFlip reads the facing back.
Detaching uses the existing generic Component.remove(entity, " Parent "). setParent reuses HierarchyPlugin::AttachChild, so self-parenting and cycles are rejected (returns false). The Parent component type is registered idempotently here so Lua-first games work without HierarchyPlugin init.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry holding the entities.
function registerPool¶
function registerPosition¶
Registers the position half of the Transform namespace: getPosition ({x, y, z}) / setPosition (x, y [, z]) / translate / getZIndex / setZIndex. MirrorsEngine 'sPositionPlugin /PositionSystem .
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry used to read/write the Position component.
function registerRotation¶
Registers the rotation half of the Transform namespace: getRotation / setRotation / rotate. MirrorsEngine 'sRotationPlugin .
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry used to read/write the Rotation component.
function registerScene¶
Registers the Scene namespace:Scene.load(name) andScene.current() .
Both go through the registry's SceneManager resource. load takes a code scene name or a scene file path and switches at the end of the frame. In multiplayer only the server's load counts: clients ignore their own calls and follow the server.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryRegistry holding the SceneManager resource.
function registerScript¶
Registers script-attachment bindings in the Component namespace. MirrorsEngine 'sScriptComponent /ScriptSystem .
Component.addScript(entity, scriptPath [, autoReload])-> boolComponent.getScriptPath(entity)-> string or nil
The path is relative to the project folder (same convention as the scriptPath field of a scene), e.g. "scripts/playerGun.lua". The script is loaded by ScriptSystem on the next tick, so onCreate/onUpdate start running after the current frame.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry holding the entities.
function registerShape¶
Registers Component.addShape . MirrorsEngine 'sShapePlugin /ShapeComponent .
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry used to add the Shape component.
function registerSprite¶
Registers the sprite bindings in the Component namespace. MirrorsEngine 'sSpritePlugin /SpriteComponent .
Getters return nil when the entity has no SpriteComponent; setters return false in that case (setSpritePath also returns false when the texture cannot be loaded). Paths are resolved like everywhere else in the engine: project-relative in built games (whose working directory is the project folder), absolute otherwise.
Component.getSpriteFlip(entity)->{flipX = bool, flipY = bool}or nilComponent.setSpriteFlip(entity, flipX [, flipY])-> bool
The flip flags only mirror the drawn sprite. To mirror a whole rig (sprite plus its children), use Component.flipX.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry; also owns the AssetManager resource.
function registerText¶
Registers Component.addText . MirrorsEngine 'sTextPlugin /Text component.
Parameters:
luaView of the shared Lua state (lambdas capture a copy by value).registryECS registry used to add the Text component.
function registerTime¶
Registers the Time namespace (Time.time ,Time.deltaTime ).
Parameters:
luaView of the shared Lua state.
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Scripting/LuaAPI.hpp