[lua] Alternative Sprite:deleteTile(tileset, tileIndex) syntax

This commit is contained in:
David Capello 2023-01-12 09:32:44 -03:00
parent f82ab4f3d9
commit 9678cc4ac3

View File

@ -708,11 +708,14 @@ int Sprite_newTile(lua_State* L)
int Sprite_deleteTile(lua_State* L)
{
auto sprite = get_docobj<Sprite>(L, 1);
tile_index ti;
Tileset* ts = get_tile_index_from_arg(L, 2, ti);
if (!ts) {
return luaL_error(L, "inexistent Tileset inside of Tile object");
}
tile_index ti = 0;
auto ts = may_get_docobj<Tileset>(L, 2);
if (ts)
ti = lua_tointeger(L, 3);
else
ts = get_tile_index_from_arg(L, 2, ti);
if (!ts)
return luaL_error(L, "Sprite:deleteTile() needs a Tileset or Tile as first argument");
if (ti < 0 || ti >= ts->size())
return luaL_error(L, "index out of bounds");
Tx tx;