| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include <iostream>
- #include "Crown.h"
- #include "lua.hpp"
- #include <unistd.h>
- using namespace crown;
- static void report_errors(lua_State* state, const int status)
- {
- if (status != 0)
- {
- std::cerr << "-- " << lua_tostring(state, -1) << std::endl;
- lua_pop(state, 1);
- }
- }
- int main(int argc, char** argv)
- {
- lua_State* lua_state;
- Filesystem fs("/home/mikymod/test/res_compiled");
- FileBundle archive(fs);
- ResourceManager res_manager(archive);
- ResourceId script = res_manager.load("lua/hello.lua");
- res_manager.flush();
- while (1)
- {
- if (res_manager.is_loaded(script))
- {
- lua_state = luaL_newstate();
- luaL_openlibs(lua_state);
- ScriptResource* resource = (ScriptResource*)res_manager.data(script);
- int s = luaL_loadbuffer(lua_state, (char*)resource->data(), 47, "");
- if (s == 0)
- {
- s = lua_pcall(lua_state, 0, LUA_MULTRET, 0);
- }
- report_errors(lua_state, s);
- break;
- }
- }
- lua_close(lua_state);
- return 0;
- }
|