Skip to content

Struct Engine::ScriptComponent

ClassList > Engine > ScriptComponent

Component that attaches a Lua script to an entity. More...

  • #include <ScriptComponent.hpp>

Public Attributes

Type Name
bool autoReload = true
If true, the script will be reloaded automatically when the file changes.
bool loaded = false
Internal: whether the script has been loaded successfully.
std::string scriptPath
Path to the Lua script file, relative to the project folder.
sol::table scriptTable = sol::lua\_nil
Internal: sol2 table handle returned by the script.

Public Functions

Type Name
ScriptComponent () = default
ScriptComponent (const std::string & path, bool autoReload_=true)

Detailed Description

The script should return a table with optional lifecycle functions: * onCreate(entity) * onUpdate(entity, dt) * onDestroy(entity)

Public Attributes Documentation

variable autoReload

If true, the script will be reloaded automatically when the file changes.

bool Engine::ScriptComponent::autoReload;


variable loaded

Internal: whether the script has been loaded successfully.

bool Engine::ScriptComponent::loaded;


variable scriptPath

Path to the Lua script file, relative to the project folder.

std::string Engine::ScriptComponent::scriptPath;


variable scriptTable

Internal: sol2 table handle returned by the script.

sol::table Engine::ScriptComponent::scriptTable;


Public Functions Documentation

function ScriptComponent [½]

Engine::ScriptComponent::ScriptComponent () = default

function ScriptComponent [2/2]

inline explicit Engine::ScriptComponent::ScriptComponent (
    const std::string & path,
    bool autoReload_=true
) 


The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Scripting/ScriptComponent.hpp