- [NEW] Ara desde consola es poden executar funcions que no esperen arguments sense ficar els parentesi

- [NEW] wintitle(text), pa Sergi
- [NEW] ara eixir a consola es amb CTRL+ESC, deixant ESC a seques lliure pa el joc (pa Sergi).
This commit is contained in:
2026-05-17 18:16:05 +02:00
parent 4cc0cb2edc
commit d3052cd026
3 changed files with 24 additions and 7 deletions
+16 -4
View File
@@ -87,6 +87,12 @@ void table_to_str(lua_State *L, int indx) {
extern "C" {
static int cpp_wintitle(lua_State *L) {
const char *text = luaL_checkstring(L, 1);
wintitle(text);
return 0;
}
static int cpp_cls(lua_State *L) {
uint8_t color = luaL_optinteger(L, 1, 32);
cls(color);
@@ -431,7 +437,7 @@ const char boot[] =
"ink(1) print('G A M E',8,16)"
"ink(4) print('S Y S T E M',20,16)"
"ink(7) print('mini',9,8)"
"ink(8) print('v0.7.7',34,29)"
"ink(8) print('v0.7.8',34,29)"
"w=time() "
"end "
"function update()"
@@ -467,6 +473,7 @@ void lua_init(const char* filename, const bool start_playing) {
}
}
lua_pushcfunction(L,cpp_wintitle); lua_setglobal(L, "wintitle");
lua_pushcfunction(L,cpp_cls); lua_setglobal(L, "cls");
lua_pushcfunction(L,cpp_ink); lua_setglobal(L, "ink");
lua_pushcfunction(L,cpp_paper); lua_setglobal(L, "paper");
@@ -670,6 +677,8 @@ void lua_init(const char* filename, const bool start_playing) {
lua_state = start_playing ? STATE_PLAYING : STATE_PAUSED;
}
#include <string>
void lua_call_cmd(const char* str) {
if (str[0]=='?') {
const int size = strlen(str)+14;
@@ -685,9 +694,12 @@ void lua_call_cmd(const char* str) {
}
} else {
if (luaL_dostring(L, str)) {
debug("ERROR:",false);
debug(lua_tostring(L, -1));
lua_pop(L,1);
std::string cmd = std::string(str) + std::string("()");
if (luaL_dostring(L, cmd.c_str())) {
debug("ERROR:",false);
debug(lua_tostring(L, -1));
lua_pop(L,1);
}
}
}
}