From b4bd76b8b02996767798b76cc65dee9ea27f1167 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 7 Dec 2018 08:46:17 +0800 Subject: *misc --- src/lua/embed/embed.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/lua/embed') diff --git a/src/lua/embed/embed.h b/src/lua/embed/embed.h index a063e65..4b1c6d9 100644 --- a/src/lua/embed/embed.h +++ b/src/lua/embed/embed.h @@ -14,30 +14,38 @@ namespace JinEngine }; // Embed scripts. -#include "scripts/graphics.lua.h" -#include "scripts/keyboard.lua.h" -#include "scripts/mouse.lua.h" -#include "scripts/boot.lua.h" + #include "scripts/graphics.lua.h" + #include "scripts/keyboard.lua.h" + #include "scripts/mouse.lua.h" + #include "scripts/boot.lua.h" // In order. - static const jin_Embed scripts[] = { + static const jin_Embed modules[] = { { "graphics.lua", graphics_lua }, { "keyboard.lua", keyboard_lua }, { "mouse.lua", mouse_lua }, - { "boot.lua", boot_lua }, { 0, 0 } }; - static void boot(lua_State* L) + static const jin_Embed boot_script = { "boot", boot_lua }; + + static void load(lua_State* L) { - for (int i = 0; scripts[i].file; ++i) + for (int i = 0; modules[i].file; ++i) { - const char* file = scripts[i].file, *source = scripts[i].source; + const char* file = modules[i].file, *source = modules[i].source; if (luax_loadbuffer(L, source, strlen(source), file) == 0) lua_call(L, 0, 0); } } + static void run(lua_State* L) + { + const char* file = boot_script.file, *source = boot_script.source; + if (luax_loadbuffer(L, source, strlen(source), file) == 0) + lua_call(L, 0, 0); + } + } // namespace Embed } // namespace JinEngine -- cgit v1.1-26-g67d0