[lua] Add Sprite.id and Layer.id properties

This commit is contained in:
David Capello 2023-01-05 16:01:42 -03:00
parent 1ce3e8e392
commit 8aa49479b8
2 changed files with 16 additions and 0 deletions

View File

@ -49,6 +49,13 @@ int Layer_cel(lua_State* L)
return 1;
}
int Layer_get_id(lua_State* L)
{
auto layer = get_docobj<Layer>(L, 1);
lua_pushinteger(L, layer->id());
return 1;
}
int Layer_get_sprite(lua_State* L)
{
auto layer = get_docobj<Layer>(L, 1);
@ -383,6 +390,7 @@ const luaL_Reg Layer_methods[] = {
};
const Property Layer_properties[] = {
{ "id", Layer_get_id, nullptr },
{ "sprite", Layer_get_sprite, nullptr },
{ "parent", Layer_get_parent, Layer_set_parent },
{ "layers", Layer_get_layers, nullptr },

View File

@ -610,6 +610,13 @@ int Sprite_get_events(lua_State* L)
return 1;
}
int Sprite_get_id(lua_State* L)
{
auto sprite = get_docobj<Sprite>(L, 1);
lua_pushinteger(L, sprite->id());
return 1;
}
int Sprite_get_filename(lua_State* L)
{
auto sprite = get_docobj<Sprite>(L, 1);
@ -861,6 +868,7 @@ const luaL_Reg Sprite_methods[] = {
};
const Property Sprite_properties[] = {
{ "id", Sprite_get_id, nullptr },
{ "filename", Sprite_get_filename, Sprite_set_filename },
{ "isModified", Sprite_get_isModified, nullptr },
{ "width", Sprite_get_width, Sprite_set_width },