diff --git a/data/game.lua b/data/game.lua index 170da80..ca512e9 100644 --- a/data/game.lua +++ b/data/game.lua @@ -1,7 +1,9 @@ +other = require("other") + x=0 function _init() - text="HOLA MINI" + text=other.peiv() keyRight = tonumber(getconf("keyright")) or KEY_RIGHT keyLeft = tonumber(getconf("keyleft")) or KEY_LEFT _update=normal_update diff --git a/data/other.lua b/data/other.lua new file mode 100644 index 0000000..eedb8eb --- /dev/null +++ b/data/other.lua @@ -0,0 +1,5 @@ +return { + peiv = function() + return "HOLA OTHER UNIT" + end +} diff --git a/lua.cpp b/lua.cpp index 21500f3..5fbcc83 100644 --- a/lua.cpp +++ b/lua.cpp @@ -1079,10 +1079,29 @@ void push_lua_funcs() { lua_pushinteger(L, 1); lua_setglobal(L, "FILE_WRITE"); } +int MiniLoader(lua_State *L) { + const char *name = luaL_checkstring(L, 1); + char filename[strlen(name)+5]; + strcpy(filename, name); + strcat(filename, ".lua"); + int size; + char* buffer = file_getfilebuffer(filename, size); + if (luaL_loadbuffer(L, buffer, size, filename)) { + debug("REQUIRE LOADING ERROR: "); + debug("%s\n",lua_tostring(L, -1)); + lua_pop(L,1); + //return ; + } + free(buffer); + return 1; +} + void lua_init(char* filenames) { L = luaL_newstate(); luaL_openlibs(L); push_lua_funcs(); + lua_register(L, "mini_loader", MiniLoader); + luaL_dostring(L, "table.insert(package.searchers,2,mini_loader)\n"); char *pointer = filenames; do { diff --git a/version.h b/version.h index e9fad5a..6bc9c64 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "0.9.64d" +#define MINI_VERSION "0.9.72d"