|
Turbo Engine 0.3
A C++ game engine using Allegro 5
|
A component whose behaviour is defined by a Lua script, à la Unity. More...
#include <LuaComponent.hpp>
Classes | |
| struct | Script |
Public Member Functions | |
| LuaComponent (GameObject *parent, std::string script_path) | |
| ~LuaComponent () | |
| void | load () override |
| Called when the component is loaded into the scene. | |
| void | update (int delta_time) override |
| Logic update. Souldn't be used for anything else than logic. | |
| void | on_enable () override |
| Called when the component is enabled (Not called on the first initialization). | |
| void | on_disable () override |
| Called when the component is disabled. | |
| void | unload () override |
| Called when the component is unloaded. | |
| bool | valid () const |
| Did the script load and return a table without error? | |
| const std::string & | script_path () const |
| Path of the .lua file backing this component. | |
| const std::string & | script_name () const |
| Display name (the script file stem). | |
| void | reload () |
| Re-read the script file from disk and re-run it. | |
| std::vector< ScriptField > | fields () const |
| Public fields (with their current values) for the inspector. | |
| void | set_number (const std::string &name, double value) |
| Set a public number field on the script instance. | |
| void | set_bool (const std::string &name, bool value) |
| Set a public boolean field on the script instance. | |
| void | set_string (const std::string &name, const std::string &value) |
| Set a public string field on the script instance. | |
| Public Member Functions inherited from turbo::Component | |
| Component (GameObject *parent) | |
| Construct a new Component. The component will be automatically added to the GameObject given as parameter. | |
| void | disable () |
| Disable the component. Do nothing if already disabled. | |
| void | enable () |
| Enable the component. Do nothing if already enabled. | |
| bool | is_enabled () |
| Check if the component is enabled. | |
| const char * | get_name () const |
| Display name of the component (used by the editor). | |
Additional Inherited Members | |
| Public Attributes inherited from turbo::Component | |
| ::std::vector< debug::InspectorObserver * > | debug_inspector_observers {} |
| Debug use only. List of observed values in the inspector. | |
| Protected Attributes inherited from turbo::Component | |
| GameObject * | gameObject = nullptr |
| bool | enabled = true |
| const char * | name = "Unknown" |
A component whose behaviour is defined by a Lua script, à la Unity.
The script is a file returning a table with optional lifecycle methods (load, update, on_enable, on_disable, unload). self.gameObject is the owning GameObject. The header keeps sol2/Lua hidden behind a PIMPL so the rest of the engine and the editor can use LuaComponent without pulling in the Lua headers.
| turbo::LuaComponent::LuaComponent | ( | GameObject * | parent, |
| std::string | script_path ) |
|
default |
| std::vector< ScriptField > turbo::LuaComponent::fields | ( | ) | const |
Public fields (with their current values) for the inspector.
|
overridevirtual |
Called when the component is loaded into the scene.
Reimplemented from turbo::Component.
|
overridevirtual |
Called when the component is disabled.
Reimplemented from turbo::Component.
|
overridevirtual |
Called when the component is enabled (Not called on the first initialization).
Reimplemented from turbo::Component.
| void turbo::LuaComponent::reload | ( | ) |
Re-read the script file from disk and re-run it.
|
inline |
Display name (the script file stem).
|
inline |
Path of the .lua file backing this component.
| void turbo::LuaComponent::set_bool | ( | const std::string & | name, |
| bool | value ) |
Set a public boolean field on the script instance.
| void turbo::LuaComponent::set_number | ( | const std::string & | name, |
| double | value ) |
Set a public number field on the script instance.
| void turbo::LuaComponent::set_string | ( | const std::string & | name, |
| const std::string & | value ) |
Set a public string field on the script instance.
|
overridevirtual |
Called when the component is unloaded.
Reimplemented from turbo::Component.
|
overridevirtual |
Logic update. Souldn't be used for anything else than logic.
| delta_time | milliseconds since the last call |
Reimplemented from turbo::Component.
|
inline |
Did the script load and return a table without error?