Skip to content

Commit

Permalink
[lua] Add Sprite.id and Layer.id properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Jan 5, 2023
1 parent 1ce3e8e commit 8aa4947
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/script/layer_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 },
Expand Down
8 changes: 8 additions & 0 deletions src/app/script/sprite_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 8aa4947

Please sign in to comment.