diff --git a/lua.cpp b/lua.cpp index fedd061..77728bf 100644 --- a/lua.cpp +++ b/lua.cpp @@ -329,6 +329,14 @@ extern "C" { return 0; } + static int cpp_tolocal(lua_State *L) { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + lua_pushinteger(L, x+camx()); + lua_pushinteger(L, y+camy()); + return 2; + } + static int cpp_circ(lua_State *L) { int x = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); @@ -896,6 +904,7 @@ void push_lua_funcs() { lua_pushcfunction(L,cpp_camera); lua_setglobal(L, "camera"); lua_pushcfunction(L,cpp_view); lua_setglobal(L, "view"); lua_pushcfunction(L,cpp_origin); lua_setglobal(L, "origin"); + lua_pushcfunction(L,cpp_tolocal); lua_setglobal(L, "tolocal"); lua_pushcfunction(L,cpp_circ); lua_setglobal(L, "circ"); lua_pushcfunction(L,cpp_circfill); lua_setglobal(L, "circfill"); lua_pushcfunction(L,cpp_oval); lua_setglobal(L, "oval"); diff --git a/mini.cpp b/mini.cpp index 3ce8ebe..70c4eda 100644 --- a/mini.cpp +++ b/mini.cpp @@ -702,6 +702,14 @@ void origin(int x, int y) { ds::cam[1] = -(ds::clip[1]+y); } +int camx() { + return ds::cam[0]; +} + +int camy() { + return ds::cam[1]; +} + void _drawcirc(int xc, int yc, int x, int y) { pset(xc+x, yc+y); pset(xc-x, yc+y); diff --git a/mini.h b/mini.h index 253854f..5d88880 100644 --- a/mini.h +++ b/mini.h @@ -174,6 +174,8 @@ void camera(int x, int y); void view(int x, int y, int w, int h); void view(); void origin(int x, int y); +int camx(); +int camy(); void circ(int x, int y, uint8_t r = 4); void circ(int x, int y, uint8_t r, uint8_t color); diff --git a/version.h b/version.h index 7f5850c..a7d11b1 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "0.9.80d" +#define MINI_VERSION "0.9.81d"