mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-17 17:42:51 +00:00
lua: Fix Sprite:newFrame() to copy the given frame and return it (fix aseprite/api#4)
This commit is contained in:
parent
ed1a6233eb
commit
1d78e46bab
@ -265,16 +265,18 @@ int Sprite_newFrame(lua_State* L)
|
||||
{
|
||||
auto sprite = get_docobj<Sprite>(L, 1);
|
||||
doc::frame_t frame = sprite->lastFrame()+1;
|
||||
doc::frame_t copyThis = frame;
|
||||
if (lua_gettop(L) >= 2) {
|
||||
frame = get_frame_number_from_arg(L, 2);
|
||||
if (frame < 0)
|
||||
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
||||
copyThis = frame+1; // addFrame() copies the previous frame of the given one.
|
||||
}
|
||||
|
||||
Doc* doc = static_cast<Doc*>(sprite->document());
|
||||
|
||||
Tx tx;
|
||||
doc->getApi(tx).addFrame(sprite, frame);
|
||||
doc->getApi(tx).addFrame(sprite, copyThis);
|
||||
tx.commit();
|
||||
|
||||
push_sprite_frame(L, sprite, frame);
|
||||
|
Loading…
x
Reference in New Issue
Block a user