From d49319acf6401f6012f6fe6861fe5b39aa156984 Mon Sep 17 00:00:00 2001 From: ThaCuber <70547062+ThaCuber@users.noreply.github.com> Date: Sat, 21 Jan 2023 15:54:37 -0400 Subject: [PATCH] fixed `bgColor(g)` --- src/api.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/api.c b/src/api.c index cfb60b4..b211c0d 100644 --- a/src/api.c +++ b/src/api.c @@ -25,7 +25,8 @@ class TXT { \n\ foreign static exit() \n\ \n\ foreign static clear(char) \n\ - foreign static write(x, y, text) \n\ + static write(x, y, value) { write_(x,y,value.toString) } \n\ + foreign static write_(x,y,text) \n\ foreign static read(x, y) \n\ foreign static color(r,g,b) \n\ foreign static color(g) \n\ @@ -236,11 +237,10 @@ defineForeignMethod(write) { txtEnsureType(1, WREN_TYPE_NUM); txtEnsureType(2, WREN_TYPE_NUM); - txtEnsureType(3, WREN_TYPE_STRING); - int x = wrenGetSlotDouble(G.vm, 1); - int y = wrenGetSlotDouble(G.vm, 2); - const char* text = wrenGetSlotString(G.vm, 3); + int x = wrenGetSlotDouble(vm, 1); + int y = wrenGetSlotDouble(vm, 2); + const char* text = wrenGetSlotString(vm, 3); for (int i = 0; i < strlen(text); i++) txtWriteChar(x+i, y, text[i]); } @@ -293,9 +293,9 @@ defineForeignMethod(bgGrayscale) txtEnsureType(1, WREN_TYPE_NUM); int g = wrenGetSlotDouble(vm, 1); - G.currentColor.r = g; - G.currentColor.g = g; - G.currentColor.b = g; + G.currentBgColor.r = g; + G.currentBgColor.g = g; + G.currentBgColor.b = g; } defineForeignMethod(mousePos) @@ -448,7 +448,9 @@ WrenForeignMethodFn bindTxtMethods(WrenVM* vm, const char* module, const char* c } foreignMethod(clear); - foreignMethod(write); + + if (strstr(signature, "write_")) return txtwrite; + foreignMethod(read); if (strstr(signature, "color"))