diff --git a/ascii.cpp b/ascii.cpp index 7824abb..88cf7f5 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -335,6 +335,11 @@ void print(const char *str, int x, int y) { cursor_y = (pos+len)/screen_width; } +void crlf() { + cursor_x=0; + cursor_y = min(cursor_y+1, screen_height-1); +} + bool btn(uint8_t i) { return keys[i]; } diff --git a/ascii.h b/ascii.h index 860a21c..1ef2029 100644 --- a/ascii.h +++ b/ascii.h @@ -120,6 +120,7 @@ void color(uint8_t ink, uint8_t paper, int8_t border=-1); void locate(uint8_t x, uint8_t y); // global::cursorx, global::cursory void print(const char *str, int x = -1, int y = -1); +void crlf(); bool btn(uint8_t i); bool btnp(uint8_t i); diff --git a/lua.cpp b/lua.cpp index 3ec6e48..1636900 100644 --- a/lua.cpp +++ b/lua.cpp @@ -54,6 +54,11 @@ extern "C" { return 0; } + static int cpp_crlf(lua_State *L) { + crlf(); + return 0; + } + static int cpp_btn(lua_State *L) { uint8_t i = luaL_checkinteger(L, 1); lua_pushboolean(L, btn(i)); @@ -326,6 +331,7 @@ void lua_init(const char* filename, const bool start_playing) { lua_pushcfunction(L,cpp_locate); lua_setglobal(L, "locate"); lua_pushcfunction(L,cpp_print); lua_setglobal(L, "print"); + lua_pushcfunction(L,cpp_crlf); lua_setglobal(L, "crlf"); lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn"); lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp");