#include "lua.hpp" class lua { private: lua_State* L; public: lua() { L = lua_open(); luaL_openlibs(L); }; lua(lua_State* P) { L = P; }; ~lua() { lua_close(L); }; void dofile(const char* fn); void dostring(const char* str); //stack queriers const char* getstring(int idx); double getnumber(int idx); //stack pushers void pushnumber(double i); void pushstring(const char* str); void register_func(const char* name, int ptr(lua_State*)); //stack etc. void pop(int i); //debug const char* getError(); }; using namespace std; void lua::dofile(const char* fn) { cout<<"Opening: "<getError()<<")"<getError()<<") in string: ("<getError()<<") while running string: ("<stackDump(); err = lua_tostring(L,-1); lua_pop(L,1); return err; } double lua::getnumber(int idx) { return lua_tonumber(L,idx); } const char* lua::getstring(int idx) { return lua_tostring(L,idx); } void lua::pushstring(const char* str) { lua_pushstring(L,str); } void lua::pushnumber(double i) { lua_pushnumber(L,i); } void lua::register_func(const char* name, int ptr(lua_State*)) { lua_register(L,name,ptr); } void lua::pop(int i) { lua_pop(L,i); }