More work in preparing for lua-based keyboard controller

Modified ScriptManager to decouple adding libraries from registering libraries
Allowing ScriptManager to register libraries to other lua states as well
This commit is contained in:
Alexander Bock
2014-10-14 00:08:26 +02:00
parent 8884f4cc36
commit 86efb3573b
12 changed files with 366 additions and 224 deletions

View File

@@ -26,6 +26,7 @@
#define __SCRIPTENGINE_H__
#include <ghoul/lua/ghoul_lua.h>
#include <set>
/**
@@ -50,19 +51,24 @@ public:
};
ScriptEngine();
bool initialize();
void deinitialize();
bool addLibrary(const LuaLibrary& library);
void initializeLuaState(lua_State* state);
void addLibrary(const LuaLibrary& library);
bool hasLibrary(const std::string& name);
bool runScript(const std::string& script);
bool runScriptFile(const std::string& filename);
private:
bool registerLuaLibrary(lua_State* state, const LuaLibrary& library);
void addLibraryFunctions(lua_State* state, const LuaLibrary& library, bool replace);
bool isLibraryNameAllowed(const std::string& name);
void addLibraryFunctions(const LuaLibrary& library, bool replace);
void addBaseLibrary();
void remapPrintFunction();