From e117cacb11a1f8f22b9d0134b6a5117a24b791e0 Mon Sep 17 00:00:00 2001 From: Sylvm Date: Tue, 31 Dec 2024 00:54:20 +0100 Subject: [PATCH 1/3] Update toolbar.lua --- exp_legacy/module/modules/gui/toolbar.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exp_legacy/module/modules/gui/toolbar.lua b/exp_legacy/module/modules/gui/toolbar.lua index 190254246b..aaded2007f 100644 --- a/exp_legacy/module/modules/gui/toolbar.lua +++ b/exp_legacy/module/modules/gui/toolbar.lua @@ -7,6 +7,11 @@ ToolbarState:set_metadata{ stringify = function(value) local buttons, favourites = 0, 0 for _, state in ipairs(value) do + -- Check the type of state must be a table + if type(state) ~= "table" then + error("Invalid state type: " .. type(state)) + end + buttons = buttons + 1 if state.favourite then favourites = favourites + 1 From 3bbc5a6f742440279e501958d350ae25d1645b27 Mon Sep 17 00:00:00 2001 From: Sylvm Date: Fri, 3 Jan 2025 09:44:02 +0100 Subject: [PATCH 2/3] Update toolbar.lua added a patch on the error toolbar.lua:388: attempt to index local 'state' (a boolean value) Root cause not found --- exp_legacy/module/modules/gui/toolbar.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/exp_legacy/module/modules/gui/toolbar.lua b/exp_legacy/module/modules/gui/toolbar.lua index aaded2007f..c351d4af1b 100644 --- a/exp_legacy/module/modules/gui/toolbar.lua +++ b/exp_legacy/module/modules/gui/toolbar.lua @@ -7,11 +7,6 @@ ToolbarState:set_metadata{ stringify = function(value) local buttons, favourites = 0, 0 for _, state in ipairs(value) do - -- Check the type of state must be a table - if type(state) ~= "table" then - error("Invalid state type: " .. type(state)) - end - buttons = buttons + 1 if state.favourite then favourites = favourites + 1 @@ -387,7 +382,11 @@ end --- Get the top order based on the players settings Gui.inject_top_flow_order(function(player) local order = ToolbarState:get(player) - + -- Check the type of order must be a table + if type(order) == "bool" then + error("Invalid order type: " .. type(order)) + return {} + end local elements = {} for index, state in ipairs(order) do elements[index] = Gui.defines[state.element_uid] From b368b984da177908b6d4bc2c780d05adedbd7f4f Mon Sep 17 00:00:00 2001 From: Sylvm Date: Fri, 3 Jan 2025 20:42:47 +0100 Subject: [PATCH 3/3] Update toolbar.lua changed logic to compare to expected type --- exp_legacy/module/modules/gui/toolbar.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exp_legacy/module/modules/gui/toolbar.lua b/exp_legacy/module/modules/gui/toolbar.lua index c351d4af1b..53c2916ddb 100644 --- a/exp_legacy/module/modules/gui/toolbar.lua +++ b/exp_legacy/module/modules/gui/toolbar.lua @@ -383,8 +383,8 @@ end Gui.inject_top_flow_order(function(player) local order = ToolbarState:get(player) -- Check the type of order must be a table - if type(order) == "bool" then - error("Invalid order type: " .. type(order)) + if type(order) ~= "table" then + error("Invalid order type (table expected): " .. type(order)) return {} end local elements = {}