- [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:
@@ -273,7 +273,7 @@ int main(int argc,char*argv[]) {
|
|||||||
load(dropped_filedir);
|
load(dropped_filedir);
|
||||||
}
|
}
|
||||||
if (mini_eve.type == SDL_EVENT_KEY_DOWN) {
|
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()) {
|
if (lua_is_playing()) {
|
||||||
lua_pause();
|
lua_pause();
|
||||||
//lua_quit();
|
//lua_quit();
|
||||||
@@ -393,6 +393,10 @@ int main(int argc,char*argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wintitle(const char* title) {
|
||||||
|
SDL_SetWindowTitle(mini_win, title);
|
||||||
|
}
|
||||||
|
|
||||||
void cls(uint8_t value) {
|
void cls(uint8_t value) {
|
||||||
SDL_memset(char_screen, value, screen_width*screen_height);
|
SDL_memset(char_screen, value, screen_width*screen_height);
|
||||||
if (current_mode != 0) SDL_memset(color_screen, current_color, 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;
|
int pos = cursor_x+cursor_y*screen_width;
|
||||||
if (chr == 8) {
|
if (chr == 8) {
|
||||||
if (cursor_x>1) {
|
if (cursor_x>1) {
|
||||||
char_screen[pos++] = 32;
|
char_screen[pos] = ' ';
|
||||||
char_screen[pos] = 32;
|
char_screen[pos-1] = ' ';
|
||||||
cursor_x--;
|
cursor_x--;
|
||||||
} else {
|
} else {
|
||||||
play("c");
|
play("c");
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ void execute_run();
|
|||||||
|
|
||||||
const char* get_filename();
|
const char* get_filename();
|
||||||
|
|
||||||
|
void wintitle(const char *title);
|
||||||
void cls(uint8_t value=32);
|
void cls(uint8_t value=32);
|
||||||
void ink(uint8_t value); // global::ink
|
void ink(uint8_t value); // global::ink
|
||||||
void paper(uint8_t value); // global::paper
|
void paper(uint8_t value); // global::paper
|
||||||
|
|||||||
@@ -87,6 +87,12 @@ void table_to_str(lua_State *L, int indx) {
|
|||||||
|
|
||||||
extern "C" {
|
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) {
|
static int cpp_cls(lua_State *L) {
|
||||||
uint8_t color = luaL_optinteger(L, 1, 32);
|
uint8_t color = luaL_optinteger(L, 1, 32);
|
||||||
cls(color);
|
cls(color);
|
||||||
@@ -431,7 +437,7 @@ const char boot[] =
|
|||||||
"ink(1) print('G A M E',8,16)"
|
"ink(1) print('G A M E',8,16)"
|
||||||
"ink(4) print('S Y S T E M',20,16)"
|
"ink(4) print('S Y S T E M',20,16)"
|
||||||
"ink(7) print('mini',9,8)"
|
"ink(7) print('mini',9,8)"
|
||||||
"ink(8) print('v0.7.7',34,29)"
|
"ink(8) print('v0.7.8',34,29)"
|
||||||
"w=time() "
|
"w=time() "
|
||||||
"end "
|
"end "
|
||||||
"function update()"
|
"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_cls); lua_setglobal(L, "cls");
|
||||||
lua_pushcfunction(L,cpp_ink); lua_setglobal(L, "ink");
|
lua_pushcfunction(L,cpp_ink); lua_setglobal(L, "ink");
|
||||||
lua_pushcfunction(L,cpp_paper); lua_setglobal(L, "paper");
|
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;
|
lua_state = start_playing ? STATE_PLAYING : STATE_PAUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
void lua_call_cmd(const char* str) {
|
void lua_call_cmd(const char* str) {
|
||||||
if (str[0]=='?') {
|
if (str[0]=='?') {
|
||||||
const int size = strlen(str)+14;
|
const int size = strlen(str)+14;
|
||||||
@@ -685,9 +694,12 @@ void lua_call_cmd(const char* str) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (luaL_dostring(L, str)) {
|
if (luaL_dostring(L, str)) {
|
||||||
debug("ERROR:",false);
|
std::string cmd = std::string(str) + std::string("()");
|
||||||
debug(lua_tostring(L, -1));
|
if (luaL_dostring(L, cmd.c_str())) {
|
||||||
lua_pop(L,1);
|
debug("ERROR:",false);
|
||||||
|
debug(lua_tostring(L, -1));
|
||||||
|
lua_pop(L,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user