commit fd575280cf5de9b6d2c95ad1b41d635a12df2922
Author: Jon Bell <jondbell@protonmail.com>
AuthorDate: Wed Apr 22 19:18:37 2020 -0600
Commit: Jon Bell <jondbell@protonmail.com>
CommitDate: Wed Apr 22 19:18:37 2020 -0600
Expose cls and pset overloads to lua
---
source/picoluaapi.cpp | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index cea1889..c171431 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -22,17 +22,29 @@ void initPicoApi(Graphics* graphics, Input* input){
/*functions to expose to lua*/
//Graphics
int cls(lua_State *L){
- _graphicsForLuaApi->cls();
+ if (lua_gettop(L) == 0) {
+ _graphicsForLuaApi->cls();
+ }
+ else {
+ short c = lua_tointeger(L,1);
+ _graphicsForLuaApi->cls(c);
+ }
return 0;
}
int pset(lua_State *L){
- double x = lua_tonumber(L,1);
- double y = lua_tonumber(L,2);
- double c = lua_tonumber(L,3);
+ short x = lua_tointeger(L,1);
+ short y = lua_tointeger(L,2);
+
+ if (lua_gettop(L) <= 2) {
+ _graphicsForLuaApi->pset(x, y);
+ return 0;
+ }
+
+ short c = lua_tointeger(L,3);
- _graphicsForLuaApi->pset((short)x, (short)y, (uint8_t)c);
+ _graphicsForLuaApi->pset(x, y, (uint8_t)c);
return 0;
}