From 3aa77227ca9d9ab17d3eef9962c84055e27b1263 Mon Sep 17 00:00:00 2001 From: badgamernl Date: Wed, 26 Feb 2020 00:35:55 +0100 Subject: [PATCH] Removed goto usage --- expcore/gui/left_flow.lua | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/expcore/gui/left_flow.lua b/expcore/gui/left_flow.lua index 64243932..74003f15 100644 --- a/expcore/gui/left_flow.lua +++ b/expcore/gui/left_flow.lua @@ -160,28 +160,20 @@ function Gui.hide_left_flow(player) local top_flow = Gui.get_top_flow(player) -- Check if the the element has a button attached - if not element_define.toolbar_button then - goto hide_left_flow_end + if element_define.toolbar_button then + -- Check if the topflow contains the button + local button = top_flow[element_define.toolbar_button] + if button then + -- Get the button define from the reverse lookup on the element + local button_define = Gui.defines[element_define.toolbar_button] + -- Raise the custom event if all of the top checks have passed + button_define:raise_custom_event{ + name = Gui.events.on_visibility_changed_by_click, + element = button, + state = false + } + end end - - -- Check if the topflow contains the button - local button = top_flow[element_define.toolbar_button] - if not button then - goto hide_left_flow_end - end - - -- Get the button define from the reverse lookup on the element - local button_define = Gui.defines[element_define.toolbar_button] - - -- Raise the custom event if all of the top checks have passed - button_define:raise_custom_event{ - name = Gui.events.on_visibility_changed_by_click, - element = button, - state = false - } - - -- Label for the end of the loop - ::hide_left_flow_end:: end end