| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include "Crown.h"
- #include "Game.h"
- #include "lua.hpp"
- namespace crown
- {
- StringSetting g_boot("boot_file", "lua main file", "lua/game.raw");
- lua_State* L;
- void init()
- {
- L = luaL_newstate();
- luaL_openlibs(L);
- lua_cpcall(L, luaopen_libcrown, NULL);
- const char* path = device()->filesystem()->os_path(g_boot.value());
- if (luaL_loadfile(L, path) || lua_pcall(L, 0, 0, 0))
- {
- os::printf("error: %s", lua_tostring(L, -1));
- }
- lua_getglobal(L, "init");
- lua_pcall(L, 0, 0, 0);
- }
- void shutdown()
- {
- lua_getglobal(L, "shutdown");
- lua_pcall(L, 0, 0, 0);
- lua_close(L);
- }
- void frame(float dt)
- {
- lua_getglobal(L, "frame");
- lua_pushnumber(L, dt);
- lua_pcall(L, 1, 0, 0);
- }
- }
|