From 47aae7fc07e30c2c5aeb06258f6aa95f3270485f Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 31 Aug 2022 11:28:37 -0300 Subject: [PATCH] [lua] Support expressions like: app.range.slices=app.activeSprite.slices Using lua_geti() we can iterate the SlicesObj as a table. --- src/app/script/range_class.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/script/range_class.cpp b/src/app/script/range_class.cpp index 8861c61d0..e55998157 100644 --- a/src/app/script/range_class.cpp +++ b/src/app/script/range_class.cpp @@ -341,16 +341,14 @@ int Range_set_slices(lua_State* L) { auto obj = get_obj(L, 1); app::Context* ctx = App::instance()->context(); - Site site = ctx->activeSite(); // TODO we should add support to CLI scripts - if (lua_istable(L, -1) && site.sprite() && current_editor) { + if (current_editor) { current_editor->clearSlicesSelection(); - int len = luaL_len(L, -1); + const int len = luaL_len(L, 2); for (int i = 1; i <= len; i++) { - lua_pushnumber(L, i); - if (lua_gettable(L, -2) != LUA_TNIL) + if (lua_geti(L, 2, i) != LUA_TNIL) current_editor->selectSlice(get_docobj(L, -1)); lua_pop(L, 1); }