From 4f437f9eab22fa9ba21dbcabe253e13de5dde71d Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 21 Feb 2018 05:04:58 +0000 Subject: [PATCH] lualoader: Allow carousel 'items' to be a table as well as a function We don't have any in-tree users of this, but for a static set of carousel options having to define a callback is excessive. --- stand/lua/drawer.lua | 6 ++++-- stand/lua/menu.lua | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index cc75e59648a4..7875a3d90ece 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -190,8 +190,10 @@ drawer.menu_name_handlers = { [core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry) local carid = entry.carousel_id local caridx = config.getCarouselIndex(carid) - local choices = entry.items() - + local choices = entry.items + if type(choices) == "function" then + choices = choices() + end if #choices < caridx then caridx = 1 end diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua index dd12d7fabd2a..e0e7c6c3c055 100644 --- a/stand/lua/menu.lua +++ b/stand/lua/menu.lua @@ -65,8 +65,10 @@ menu.handlers = { -- carousel (rotating) functionality local carid = entry.carousel_id local caridx = config.getCarouselIndex(carid) - local choices = entry.items() - + local choices = entry.items + if type(choices) == "function" then + choices = choices() + end if #choices > 0 then caridx = (caridx % #choices) + 1 config.setCarouselIndex(carid, caridx)