-Secció "files" del game.ini obsoleta. Ara sempre obri "main.lua". Els demes arxius s'inclouen amb "require()"
This commit is contained in:
43
lua.cpp
43
lua.cpp
@@ -1096,39 +1096,28 @@ int MiniLoader(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void lua_init(char* filenames) {
|
||||
void lua_init() {
|
||||
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 {
|
||||
// Get next filename...
|
||||
char *file_start=pointer;
|
||||
while (*pointer!=',' && *pointer!=0) pointer++;
|
||||
if (*pointer!=0) *(pointer++)=0;
|
||||
|
||||
// Load and execute file
|
||||
//if (luaL_loadfile(L, file_start)) { // "game.lua"
|
||||
int size;
|
||||
char* buffer = file_getfilebuffer(file_start, size);
|
||||
if (luaL_loadbuffer(L, buffer, size, file_start)) {
|
||||
debug("LOADING ERROR: ");
|
||||
debug("%s\n",lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
return;
|
||||
}
|
||||
free(buffer);
|
||||
if (lua_pcall(L,0, LUA_MULTRET, 0)) {
|
||||
debug("RUNTIME ERROR: ");
|
||||
debug("%s\n",lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
return;
|
||||
}
|
||||
if (*pointer!=0) *(pointer-1)=',';
|
||||
} while (*pointer!=0);
|
||||
int size;
|
||||
char* buffer = file_getfilebuffer("main.lua", size);
|
||||
if (luaL_loadbuffer(L, buffer, size, "main")) {
|
||||
debug("LOADING ERROR: ");
|
||||
debug("%s\n",lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
return;
|
||||
}
|
||||
free(buffer);
|
||||
if (lua_pcall(L,0, LUA_MULTRET, 0)) {
|
||||
debug("RUNTIME ERROR: ");
|
||||
debug("%s\n",lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if _init and _update exist
|
||||
lua_getglobal(L, "_init");
|
||||
|
||||
Reference in New Issue
Block a user