diff options
| author | Jacob1 <jfu614@gmail.com> | 2012-05-10 21:44:43 (GMT) |
|---|---|---|
| committer | Jacob1 <jfu614@gmail.com> | 2012-05-24 17:09:32 (GMT) |
| commit | bdc94208d22dd65d5796264b62d275114489b35e (patch) | |
| tree | ff70c235cb5a5e9adad9f2c13fa763ea6aae2e73 /src | |
| parent | 5edd224344b427f75f0740217e10cb4e44313a5d (diff) | |
| download | powder-bdc94208d22dd65d5796264b62d275114489b35e.zip powder-bdc94208d22dd65d5796264b62d275114489b35e.tar.gz | |
finish custom lua graphics functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 14 | ||||
| -rw-r--r-- | src/luaconsole.c | 33 |
2 files changed, 34 insertions, 13 deletions
diff --git a/src/graphics.c b/src/graphics.c index 60d23b0..0c4c965 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1860,7 +1860,19 @@ void render_parts(pixel *vid) #ifdef LUACONSOLE if (lua_gr_func[t]) { - colr = luacon_graphics_update(t,i); + if (luacon_graphics_update(t,i, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) + { + graphicscache[t].isready = 1; + graphicscache[t].pixel_mode = pixel_mode; + graphicscache[t].cola = cola; + graphicscache[t].colr = colr; + graphicscache[t].colg = colg; + graphicscache[t].colb = colb; + graphicscache[t].firea = firea; + graphicscache[t].firer = firer; + graphicscache[t].fireg = fireg; + graphicscache[t].fireb = fireb; + } } else if (ptypes[t].graphics_func) { diff --git a/src/luaconsole.c b/src/luaconsole.c index 46168af..d32147c 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -788,19 +788,28 @@ int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) } return retval; } -int luacon_graphics_update(int t, int i) +int luacon_graphics_update(int t, int i, int *pixel_mode, int *cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb) { - int retval = 0; - if(lua_gr_func[t]){ - lua_rawgeti(l, LUA_REGISTRYINDEX, lua_gr_func[t]); - lua_pushinteger(l, i); - lua_pcall(l, 1, 1, 0); - if(lua_isnumber(l, -1)){ - retval = (int)lua_tonumber(l, -1); - } - lua_pop(l, 1); - } - return retval; + int cache = 0; + lua_rawgeti(l, LUA_REGISTRYINDEX, lua_gr_func[t]); + lua_pushinteger(l, i); + lua_pushinteger(l, *colr); + lua_pushinteger(l, *colg); + lua_pushinteger(l, *colb); + lua_pcall(l, 4, 10, 0); + + cache = luaL_optint(l, 2, 0); + *pixel_mode = luaL_optint(l, 3, *pixel_mode); + *cola = luaL_optint(l, 4, *cola); + *colr = luaL_optint(l, 5, *colr); + *colg = luaL_optint(l, 6, *colg); + *colb = luaL_optint(l, 7, *colb); + *firea = luaL_optint(l, 8, *firea); + *firer = luaL_optint(l, 9, *firer); + *fireg = luaL_optint(l, 10, *fireg); + *fireb = luaL_optint(l, 11, *fireb); + lua_pop(l, 10); + return cache; } char *luacon_geterror(){ char *error = lua_tostring(l, -1); |
