mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
Added table support for love.graphics.setColor (issue #106)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user