diff --git a/data/game.ini b/data/game.ini index f697ae5..397f023 100644 --- a/data/game.ini +++ b/data/game.ini @@ -3,4 +3,3 @@ config=minitest width=160 height=120 zoom=3 -files=game.lua diff --git a/data/game.lua b/data/main.lua similarity index 98% rename from data/game.lua rename to data/main.lua index ca512e9..7a89220 100644 --- a/data/game.lua +++ b/data/main.lua @@ -1,4 +1,4 @@ -other = require("other") +other = require "other" x=0 diff --git a/lua.cpp b/lua.cpp index 5fbcc83..c701a87 100644 --- a/lua.cpp +++ b/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"); diff --git a/lua.h b/lua.h index 41f7d75..f991050 100644 --- a/lua.h +++ b/lua.h @@ -1,7 +1,7 @@ #pragma once bool lua_is_playing(); -void lua_init(char* filenames); +void lua_init(); void lua_call_init(); void lua_call_update(); void lua_quit(); diff --git a/mini.cpp b/mini.cpp index a614c0c..19dd471 100644 --- a/mini.cpp +++ b/mini.cpp @@ -41,7 +41,7 @@ FILE *file = NULL; //uint8_t file_mode = 0; bool file_ignore_comma=true; -char lua_files[1024]; +//char lua_files[1024]; #define DEST(x, y) dest_surface->p[x+y*dest_surface->w] #define SOURCE(x, y) source_surface->p[x+y*source_surface->w] @@ -119,10 +119,10 @@ void read_ini() { else if (strcmp(line, "height") == 0) screen_height = atoi(value); else if (strcmp(line, "zoom") == 0) screen_zoom = atoi(value); else if (strcmp(line, "fullscreen") == 0) screen_fullscreen = atoi(value); - else if (strcmp(line, "files") == 0) { + //else if (strcmp(line, "files") == 0) { //lua_files = (char*)malloc(strlen(value)); - strcpy(lua_files, value); - } + // strcpy(lua_files, value); + //} } } fclose(f); @@ -280,7 +280,7 @@ int main(int argc,char*argv[]){ #ifdef DEBUG debug("MINI v%s\n",MINI_VERSION); #endif - lua_init(lua_files); + lua_init(); lua_call_init(); Uint32 dt=SDL_GetTicks(); diff --git a/version.h b/version.h index 6bc9c64..b02db80 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "0.9.72d" +#define MINI_VERSION "0.9.73d"