[FEAT] New terminal console system
This commit is contained in:
36
lua.cpp
36
lua.cpp
@@ -417,7 +417,7 @@ void lua_init(const char* filename, const bool start_playing) {
|
||||
|
||||
if (filename == NULL) {
|
||||
if (luaL_loadstring(L, boot)) {
|
||||
debug("BOOT ERROR");
|
||||
debug("BOOT ERROR:", false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
setmode(0);
|
||||
@@ -425,7 +425,7 @@ void lua_init(const char* filename, const bool start_playing) {
|
||||
}
|
||||
} else {
|
||||
if (luaL_loadfile(L, filename)) {
|
||||
debug("ERROR LOADING GAME");
|
||||
debug("ERROR LOADING GAME:",false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
setmode(0);
|
||||
@@ -615,7 +615,7 @@ void lua_init(const char* filename, const bool start_playing) {
|
||||
if (!file_loaded) return;
|
||||
|
||||
if (lua_pcall(L,0, LUA_MULTRET, 0)) {
|
||||
debug("RUNTIME ERROR");
|
||||
debug("RUNTIME ERROR:", false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
setmode(0);
|
||||
@@ -634,20 +634,32 @@ void lua_init(const char* filename, const bool start_playing) {
|
||||
}
|
||||
|
||||
void lua_call_cmd(const char* str) {
|
||||
if (luaL_dostring(L, str)) {
|
||||
//debug(" ");
|
||||
debug("ERROR");
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
if (str[0]=='?') {
|
||||
const int size = strlen(str)+14;
|
||||
char* cmd = (char*)malloc(size);
|
||||
memcpy(cmd, "print(tostr(", 12);
|
||||
memcpy(&cmd[12], &str[1], strlen(str)-1);
|
||||
cmd[size-1]='\0';
|
||||
cmd[size-3]=cmd[size-2]=')';
|
||||
if (luaL_dostring(L, cmd)) {
|
||||
debug("ERROR:",false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
}
|
||||
} else {
|
||||
if (luaL_dostring(L, str)) {
|
||||
debug("ERROR:",false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
}
|
||||
}
|
||||
//debug(" ");
|
||||
}
|
||||
|
||||
void lua_call_init() {
|
||||
if (!init_exists) return;
|
||||
lua_getglobal(L, "init");
|
||||
if (lua_pcall(L, 0, 0, 0)) {
|
||||
debug("RUNTIME ERROR");
|
||||
debug("RUNTIME ERROR:",false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
setmode(0);
|
||||
@@ -656,10 +668,10 @@ void lua_call_init() {
|
||||
}
|
||||
|
||||
void lua_call_update() {
|
||||
if (!update_exists) return;
|
||||
if (!update_exists) { lua_state = STATE_PAUSED; return; }
|
||||
lua_getglobal(L, "update");
|
||||
if (lua_pcall(L, 0, 0, 0)) {
|
||||
debug("RUNTIME ERROR");
|
||||
debug("RUNTIME ERROR:",false);
|
||||
debug(lua_tostring(L, -1));
|
||||
lua_pop(L,1);
|
||||
setmode(0);
|
||||
|
||||
Reference in New Issue
Block a user