Skip to content

Commit

Permalink
fixed bgColor(g)
Browse files Browse the repository at this point in the history
  • Loading branch information
thacuber2a03 authored Jan 21, 2023
1 parent ffa523a commit d49319a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit d49319a

Please sign in to comment.