From 7413d5427cfffbb64dda0603590d378f83b8ebbc Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sat, 1 Jun 2024 16:46:21 +0200 Subject: [PATCH] Fix using #allTabs; it isnt a list --- tabview.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tabview.lua b/tabview.lua index 4828c56..dd22626 100644 --- a/tabview.lua +++ b/tabview.lua @@ -1,4 +1,5 @@ local parent = term.current() +local tabCount = 0 local allTabs = {} local tabOrder = {} local currentTab = nil @@ -26,6 +27,7 @@ local function addTab(tab, order_idx) end allTabs[tab.name] = tab tabOrder[order_idx] = tab.name + tabCount = tabCount + 1 return tab end @@ -43,14 +45,14 @@ local function showTab(name) end local function switchTab() - assert(#allTabs > 0, "tabs need to be registered in order to switch tabs") + assert(tabCount > 0, "tabs need to be registered in order to switch tabs") local idx = 0 if currentTab ~= nil then currentTab.window.setVisible(false) idx = tabOrder[currentTab.name] end idx = idx + 1 - if idx > #allTabs then + if idx > tabCount then idx = 1 end currentTab = allTabs[tabOrder[idx]]