|
MochiEngine
|
ScriptingManager is a class containing the necessary methods to load and execute lua scripts binded to the C++ code. More...
#include <ScriptingManager.h>
Public Member Functions | |
| ScriptingManager (FS::PackCatalog *packCatalog) | |
| void | Execute (const std::string_view &code) |
| Executes code on the current environment. | |
| void | ExecuteFile (const std::string &path) |
| Executes the code on a file on the current environment. | |
| void | ExecuteGlobal (const std::string_view &code) |
| Executes code on the global environment. | |
| void | ExecuteFileGlobal (const std::string &path) |
| Executes the code on a file on the global environment. | |
| void | Update (const float &dt) |
| Update internal scripts, like coroutines. | |
| void | CleanEnvironment () |
| Resets the current environment. | |
Public Attributes | |
| sol::state | State |
ScriptingManager is a class containing the necessary methods to load and execute lua scripts binded to the C++ code.
It allows separating script executions by a cleanable environment and global executions, updating script coroutines and executing from plain code or from a file.
It also allows direct use of sol::state, providing advanced and manual use of the lua api. You can for example bind existing sprites from C++ in lua to manage their transforms, or capture lua data in tables directly from C++. This is dangerous and the user should be careful to manage lifetimes correctly when accesing the state directly.
Ownership:
Guarantees:
Non responsible:
Thread safety:
| void Mochi::Scripting::ScriptingManager::Execute | ( | const std::string_view & | code | ) |
Executes code on the current environment.
| code | The code to execute. |
| void Mochi::Scripting::ScriptingManager::ExecuteFile | ( | const std::string & | path | ) |
Executes the code on a file on the current environment.
| path | The path to the file with the code in the catalog. |
| void Mochi::Scripting::ScriptingManager::ExecuteFileGlobal | ( | const std::string & | path | ) |
Executes the code on a file on the global environment.
| path | The path to the file with the code in the catalog. |
| void Mochi::Scripting::ScriptingManager::ExecuteGlobal | ( | const std::string_view & | code | ) |
Executes code on the global environment.
| code | The code to execute. |
| void Mochi::Scripting::ScriptingManager::Update | ( | const float & | dt | ) |
Update internal scripts, like coroutines.
| dt | The delta time. |