From b709a392436d4ed17e214cd9e302ddbd23d71c21 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 12 Oct 2017 08:32:21 -0400 Subject: more lua scripting --- include/systems/lua.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'include/systems') diff --git a/include/systems/lua.hpp b/include/systems/lua.hpp index 8c4698a..2df038a 100644 --- a/include/systems/lua.hpp +++ b/include/systems/lua.hpp @@ -13,7 +13,8 @@ private: lua_State* state; std::string script; - void setGlobal(const LuaVariable&); + void setGlobal(const LuaVariable&) const; + void getReturns(std::vector& rets) const; static void replace(std::string& s, const std::string& rid, const std::string& put) { for (unsigned int i = 0; i < s.size(); i++) { @@ -35,8 +36,19 @@ public: lua_pcall(state, 0, 0, 0); } - void operator()(std::vector vars); - void operator()(void); + inline lua_State* getState(void) + { return state; } + + inline void addFunction(const std::string& name, lua_CFunction func) { + lua_pushcclosure(state, func, 0); + lua_setglobal(state, name.c_str()); + } + + void operator()(const std::string& func, std::vector vars) const; + void operator()(const std::string& func, std::vector& rets, std::vector vars) const; + void operator()(std::vector vars) const; + void operator()(std::vector& rets, std::vector vars) const; + void operator()(const std::string& func = "update") const; }; class LuaSystem { -- cgit v1.2.3