-Secció "files" del game.ini obsoleta. Ara sempre obri "main.lua". Els demes arxius s'inclouen amb "require()"
This commit is contained in:
@@ -3,4 +3,3 @@ config=minitest
|
||||
width=160
|
||||
height=120
|
||||
zoom=3
|
||||
files=game.lua
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
other = require("other")
|
||||
other = require "other"
|
||||
|
||||
x=0
|
||||
|
||||
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");
|
||||
|
||||
2
lua.h
2
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();
|
||||
|
||||
10
mini.cpp
10
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();
|
||||
|
||||
Reference in New Issue
Block a user