unigi.ext/test/lua.c

32 lines
717 B
C
Raw Normal View History

2024-09-10 23:53:56 +00:00
#include "unigi/main.h"
#include "unigi.platform.sdl1/main.c"
#include "unigi.ext/main.c"
#include "unigi.ext/main_wrap.c"
#if LUA_VERSION_NUM < 503
#include <lualib.h>
#endif
int main(int argc, char *argv[]) {
lua_State *L = luaL_newstate();
2024-09-25 19:19:25 +00:00
assert(L != NULL);
luaL_openlibs(L);
luaopen_unigi(L); // Load the wrapped module
for (int i = 0; i < argc; i++) {
lua_pushstring(L, argv[i]);
lua_rawseti(L, -2, i + 1);
}
lua_setglobal(L, "arg");
if (luaL_dostring(L,
"main_path = (arg[1]:match(\"(.*[/\\\\])\") or \"./\"):sub(1,-2)\n"
"dofile(main_path .. \"/mods/main/script/main.lua\")"
) != 0) {
fprintf(stderr, "Error running Lua code: %s\n", lua_tostring(L, -1));
return 1;
}
2024-09-10 23:53:56 +00:00
return 0;
}