- [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
+7 -3
View File
@@ -273,7 +273,7 @@ int main(int argc,char*argv[]) {
load(dropped_filedir);
}
if (mini_eve.type == SDL_EVENT_KEY_DOWN) {
if (mini_eve.key.scancode == SDL_SCANCODE_ESCAPE) {
if ((mini_eve.key.scancode == SDL_SCANCODE_ESCAPE) && (mini_eve.key.mod & SDL_KMOD_LCTRL) ) {
if (lua_is_playing()) {
lua_pause();
//lua_quit();
@@ -393,6 +393,10 @@ int main(int argc,char*argv[]) {
return 0;
}
void wintitle(const char* title) {
SDL_SetWindowTitle(mini_win, title);
}
void cls(uint8_t value) {
SDL_memset(char_screen, value, screen_width*screen_height);
if (current_mode != 0) SDL_memset(color_screen, current_color, screen_width*screen_height);
@@ -561,8 +565,8 @@ void debugchr(const uint8_t chr) {
int pos = cursor_x+cursor_y*screen_width;
if (chr == 8) {
if (cursor_x>1) {
char_screen[pos++] = 32;
char_screen[pos] = 32;
char_screen[pos] = ' ';
char_screen[pos-1] = ' ';
cursor_x--;
} else {
play("c");
+1
View File
@@ -132,6 +132,7 @@ void execute_run();
const char* get_filename();
void wintitle(const char *title);
void cls(uint8_t value=32);
void ink(uint8_t value); // global::ink
void paper(uint8_t value); // global::paper
+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);
}
}
}
}