Tesseract-Engine/assets/scripts/engine.lua

77 lines
2.6 KiB
Lua

--@module Engine
--[[
Engine.lua serves as the Lua interface for your engine's functionalities.
It maps C++ bound functions from `_T_Engine_Table` to a Lua `Engine` table,
enriched with EmmyLua annotations for enhanced IntelliSense support.
]]
---@class Color
---@field r number Red component (0-1)
---@field g number Green component (0-1)
---@field b number Blue component (0-1)
---@field a number Alpha component (0-1)
---@class Vector3
---@field x number
---@field y number
---@field z number
---@class Transform
---@field position Vector3 The position of the Transform.
---@field rotation Vector3 The rotation of the Transform.
---@field scale Vector3 The scale of the Transform.
---@class Camera
---@field fieldOfView number The camera's field of view.
---@field nearClipPlane number The near clipping plane distance.
---@field farClipPlane number The far clipping plane distance.
---@class Mesh
---@field vertices Vector3[] The vertices of the mesh.
---@field indices number[] The indices defining the mesh's triangles.
---@class GameObject
local GameObject = {}
---Retrieves a component attached to the GameObject.
---@param componentName string The name of the component to retrieve ("Transform", "Camera", "Mesh")
---@return Transform|Camera|Mesh|nil The requested component or `nil` if not found.
function GameObject:GetComponent(componentName)
-- The actual implementation is bound in C++.
-- This is just for IntelliSense support.
end
---@class Engine
local Engine = {}
---Logs a message with an optional color and alpha.
---@param message string The message to log.
---@param color? Color Optional color and alpha for the log message.
---@return void
Engine.Log = _T_Engine_Table.Log
---Exposes a variable to the engine.
---@param name string The identifier name of the variable.
---@param label string A human-readable label for the variable.
---@param value number|string|boolean|nil The value to expose (int, float, bool, string, nil).
---@return void
Engine.Expose = _T_Engine_Table.Expose
---Checks if a specific key is currently pressed.
---@param keyCode KeyCode The key code to check.
---@return boolean True if the key is pressed, false otherwise.
Engine.KeyDown = _T_Engine_Table.KeyDown
---Retrieves the name of the current script.
---@return string The name of the script.
Engine.ScriptName = _T_Engine_Table.ScriptName
---Gets a GameObject by its tag.
---@param tag string The tag associated with the GameObject.
---@return GameObject|nil The GameObject with the specified tag, or `nil` if not found.
Engine.GetGameObjectByTag = _T_Engine_Table.GetGameObjectByTag
return Engine