Turbo Engine 0.3
A C++ game engine using Allegro 5
turbo::script::ScriptEngine Class Reference

Owns the Lua VM and exposes the engine API to scripts. More...

#include <ScriptEngine.hpp>

Public Member Functions

 ScriptEngine ()
 ScriptEngine (const ScriptEngine &)=delete
ScriptEngineoperator= (const ScriptEngine &)=delete
sol::state & state ()
 The shared Lua state (used by LuaComponent to load scripts).
void defer (std::function< void()> fn)
 Queue a structural change (spawn/destroy) to run after the current update pass, so the scene tree isn't mutated while iterated.
void run_deferred ()
 Execute and clear all queued deferred commands.
void run_string (const std::string &code)
 Execute a chunk of Lua (the editor REPL). Errors and non-nil results are printed to the console.

Detailed Description

Owns the Lua VM and exposes the engine API to scripts.

A single Lua state is shared by every LuaComponent; each component runs its script in its own returned table, so instances don't collide.

Constructor & Destructor Documentation

◆ ScriptEngine() [1/2]

turbo::script::ScriptEngine::ScriptEngine ( )

◆ ScriptEngine() [2/2]

turbo::script::ScriptEngine::ScriptEngine ( const ScriptEngine & )
delete

Member Function Documentation

◆ defer()

void turbo::script::ScriptEngine::defer ( std::function< void()> fn)
inline

Queue a structural change (spawn/destroy) to run after the current update pass, so the scene tree isn't mutated while iterated.

◆ operator=()

ScriptEngine & turbo::script::ScriptEngine::operator= ( const ScriptEngine & )
delete

◆ run_deferred()

void turbo::script::ScriptEngine::run_deferred ( )

Execute and clear all queued deferred commands.

◆ run_string()

void turbo::script::ScriptEngine::run_string ( const std::string & code)

Execute a chunk of Lua (the editor REPL). Errors and non-nil results are printed to the console.

◆ state()

sol::state & turbo::script::ScriptEngine::state ( )
inline

The shared Lua state (used by LuaComponent to load scripts).


The documentation for this class was generated from the following files: