ST_engine  0.3-ALPHA
Public Member Functions | Friends | List of all members
lua_backend Class Reference

This class handles all interaction with lua. More...

#include <lua_backend.hpp>

Public Member Functions

int initialize (message_bus *msg_bus, game_manager *game_mngr)
 
void set_global (const std::string &arg)
 
void run_global (const std::string &arg)
 
int8_t run_file (const std::string &file)
 
int8_t load_file (const std::string &)
 
int8_t run_script (const std::string &script)
 
void close ()
 

Friends

class lua_backend_test
 

Detailed Description

This class handles all interaction with lua.

It loads lua scripts and runs them. Also provides Lua with the API to the internal engine code. This is the bridge between gameplay and engine code.

Definition at line 31 of file lua_backend.hpp.

Member Function Documentation

◆ close()

void lua_backend::close ( )

Close the Lua State.

Definition at line 295 of file lua_backend.cpp.

◆ initialize()

int lua_backend::initialize ( message_bus msg_bus,
game_manager game_mngr 
)

Initializes the Lua subsystem.

Parameters
msg_busA pointer to the global msg_bus.
game_mngrA pointer to the game_manager object.
Returns
Returns 0 on success or exits with exit code 1 on failure.

Definition at line 41 of file lua_backend.cpp.

◆ load_file()

int8_t lua_backend::load_file ( const std::string &  file)

Loads a file into the global Lua State, but does not run it.

Parameters
fileThe path to the file.
Returns
ABORTS THE APP on failure or returns 0 on success.

Definition at line 248 of file lua_backend.cpp.

◆ run_file()

int8_t lua_backend::run_file ( const std::string &  file)

Run a lua script inside the global Lua state.

Parameters
fileThe path to the file.
Returns
-1 on failure or 0 on success.

Definition at line 231 of file lua_backend.cpp.

◆ run_global()

void lua_backend::run_global ( const std::string &  arg)

Run a already set global.

Parameters
argThe name of the global.

Definition at line 287 of file lua_backend.cpp.

◆ run_script()

int8_t lua_backend::run_script ( const std::string &  script)

Run a lua script contained in a string.

Parameters
scriptThe Lua Script to run.
Returns
-1 on failure and 0 on success.

Definition at line 265 of file lua_backend.cpp.

◆ set_global()

void lua_backend::set_global ( const std::string &  arg)

Set a loaded script as a global.

Parameters
argThe name of the script to set as global.

Definition at line 279 of file lua_backend.cpp.


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