Added table support for love.graphics.setColor (issue #106)

This commit is contained in:
Bart van Strien
2010-11-16 20:47:28 +01:00
parent 6bfb05359b
commit a47fa1462d
2 changed files with 26 additions and 4 deletions
+1
View File
@@ -20,6 +20,7 @@ LOVE 0.7.0 [Game Slave]
* Added shape:getBody.
* Added love.filesystem.FileData for public usage.
* Added base64 support for love.filesystem.FileData.
* Added table support for love.graphics.setColor.
* Fixed the debug module not being an upvalue of the error handlers. (you can now override debug)
* Fixed some cases when love.audio.pause and friends, were acting on everything, not just the passed Source.
+25 -4
View File
@@ -341,10 +341,31 @@ namespace opengl
int w_setColor(lua_State * L)
{
Color c;
c.r = (unsigned char)luaL_checkint(L, 1);
c.g = (unsigned char)luaL_checkint(L, 2);
c.b = (unsigned char)luaL_checkint(L, 3);
c.a = (unsigned char)luaL_optint(L, 4, 255);
if (lua_istable(L, 1)) {
lua_pushinteger(L, 1);
lua_gettable(L, -2);
c.r = (unsigned char)luaL_checkint(L, -1);
lua_pop(L, 1);
lua_pushinteger(L, 2);
lua_gettable(L, -2);
c.g = (unsigned char)luaL_checkint(L, -1);
lua_pop(L, 1);
lua_pushinteger(L, 3);
lua_gettable(L, -2);
c.b = (unsigned char)luaL_checkint(L, -1);
lua_pop(L, 1);
lua_pushinteger(L, 4);
lua_gettable(L, -2);
c.a = (unsigned char)luaL_optint(L, -1, 255);
lua_pop(L, 1);
}
else
{
c.r = (unsigned char)luaL_checkint(L, 1);
c.g = (unsigned char)luaL_checkint(L, 2);
c.b = (unsigned char)luaL_checkint(L, 3);
c.a = (unsigned char)luaL_optint(L, 4, 255);
}
instance->setColor(c);
return 0;
}