davidsiaw / luacppinterface

A Simple C++ Interface to Lua
MIT License
168 stars 28 forks source link

loading compiled lua scripts #36

Open alexribeirodesa opened 8 years ago

alexribeirodesa commented 8 years ago

I made this small code to load the file using the lua lib, with this you can open both raw and binary lua script.

luacppinterface.h: // run a Lua script std::string LoadScript(std::string script);

luacppinterface.cpp: std::string Lua::LoadScript(std::string script) { if (luaL_loadfile(state.get(), script.c_str())) { return LuaGetLastError(state.get()); } lua_pcall(state.get(), 0, LUA_MULTRET, 0);

return "No errors";

}