-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
|
width=160
|
||||||
height=120
|
height=120
|
||||||
zoom=3
|
zoom=3
|
||||||
files=game.lua
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
other = require("other")
|
other = require "other"
|
||||||
|
|
||||||
x=0
|
x=0
|
||||||
|
|
||||||
17
lua.cpp
17
lua.cpp
@@ -1096,25 +1096,16 @@ int MiniLoader(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_init(char* filenames) {
|
void lua_init() {
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
push_lua_funcs();
|
push_lua_funcs();
|
||||||
lua_register(L, "mini_loader", MiniLoader);
|
lua_register(L, "mini_loader", MiniLoader);
|
||||||
luaL_dostring(L, "table.insert(package.searchers,2,mini_loader)\n");
|
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;
|
int size;
|
||||||
char* buffer = file_getfilebuffer(file_start, size);
|
char* buffer = file_getfilebuffer("main.lua", size);
|
||||||
if (luaL_loadbuffer(L, buffer, size, file_start)) {
|
if (luaL_loadbuffer(L, buffer, size, "main")) {
|
||||||
debug("LOADING ERROR: ");
|
debug("LOADING ERROR: ");
|
||||||
debug("%s\n",lua_tostring(L, -1));
|
debug("%s\n",lua_tostring(L, -1));
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
@@ -1127,8 +1118,6 @@ void lua_init(char* filenames) {
|
|||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (*pointer!=0) *(pointer-1)=',';
|
|
||||||
} while (*pointer!=0);
|
|
||||||
|
|
||||||
// Check if _init and _update exist
|
// Check if _init and _update exist
|
||||||
lua_getglobal(L, "_init");
|
lua_getglobal(L, "_init");
|
||||||
|
|||||||
2
lua.h
2
lua.h
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
bool lua_is_playing();
|
bool lua_is_playing();
|
||||||
void lua_init(char* filenames);
|
void lua_init();
|
||||||
void lua_call_init();
|
void lua_call_init();
|
||||||
void lua_call_update();
|
void lua_call_update();
|
||||||
void lua_quit();
|
void lua_quit();
|
||||||
|
|||||||
10
mini.cpp
10
mini.cpp
@@ -41,7 +41,7 @@ FILE *file = NULL;
|
|||||||
//uint8_t file_mode = 0;
|
//uint8_t file_mode = 0;
|
||||||
bool file_ignore_comma=true;
|
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 DEST(x, y) dest_surface->p[x+y*dest_surface->w]
|
||||||
#define SOURCE(x, y) source_surface->p[x+y*source_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, "height") == 0) screen_height = atoi(value);
|
||||||
else if (strcmp(line, "zoom") == 0) screen_zoom = 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, "fullscreen") == 0) screen_fullscreen = atoi(value);
|
||||||
else if (strcmp(line, "files") == 0) {
|
//else if (strcmp(line, "files") == 0) {
|
||||||
//lua_files = (char*)malloc(strlen(value));
|
//lua_files = (char*)malloc(strlen(value));
|
||||||
strcpy(lua_files, value);
|
// strcpy(lua_files, value);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@@ -280,7 +280,7 @@ int main(int argc,char*argv[]){
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug("MINI v%s\n",MINI_VERSION);
|
debug("MINI v%s\n",MINI_VERSION);
|
||||||
#endif
|
#endif
|
||||||
lua_init(lua_files);
|
lua_init();
|
||||||
lua_call_init();
|
lua_call_init();
|
||||||
|
|
||||||
Uint32 dt=SDL_GetTicks();
|
Uint32 dt=SDL_GetTicks();
|
||||||
|
|||||||
Reference in New Issue
Block a user