Scripts¶
-
namespace
tnt
-
namespace
doo
Variables
-
struct tnt::doo::scripts_sys
scripts
¶
-
struct
scripts_sys
¶ - #include <Scripts.hpp>
The system that handles the scripts of the objects.
Public Functions
-
void
add_object
(object const &id, std::string_view filename, tnt::lua::lib const &libs = tnt::lua::lib::core)¶ The name of the *.lua script to attach to the next object.
- Parameters
id
: The id of the object to add to the scripting system.filename
: The name of the .lua script file.libs
: The desired libraries you need for this object. Defaults to tnt::lua::lib::core.
-
void
Init
(object const &id)¶ Run
init()
from the object’s lua script. If no function named init() is found, it does nothing.- Parameters
id
: The id of the object to init().
-
void
reload
(object const &id) noexcept¶ Reload the script data of the desired object.
- Parameters
id
: The id of the desired object.
-
template<typename ...
Args
>
decltype(auto)call
(object const &id, std::string_view fn, Args&&... args)¶ Call the desired function from the lua state of the given object.
- Parameters
id
: The id of the object that has the function.fn
: The name of the function.args
: The arguments to pass to the function.
-
void
Update
(object const &id, float time_)¶ Run update() from the script.
- Parameters
id
: The id of the object to update.time_
: The elapsed time since the last update call.
-
void
from_json
(object const &id, nlohmann::json const &j)¶ Load script data from a json chunk.
- Parameters
id
: The id of the object to load from json.j
: The json chunk that holds the data.
-
void
to_json
(object const &id, nlohmann::json &j)¶ Store scripts data of a specific object to a json chunk.
- Parameters
id
: The id of the object to serialize to json.j
: The json chunk where the data will be saved.
-
void
draw_imgui
(object const &id, Window const &win) noexcept¶ Draw widgets on the given window to modify the datas of the system.
- Parameters
id
: The id of the active object.win
: The window where to draw the widgets.
-
void
remove
(object const &id) noexcept¶ Remove the desired object from the scripts system.
- Parameters
id
: The id of the object you want to remove.
-
void
clear
() noexcept¶ Remove all the objects from the scripts system.
-
void
-
struct tnt::doo::scripts_sys
-
namespace
lua
¶
-
namespace