diff --git a/exp_gui/module/toolbar.lua b/exp_gui/module/toolbar.lua index a1f438db..e4a3ebe2 100644 --- a/exp_gui/module/toolbar.lua +++ b/exp_gui/module/toolbar.lua @@ -335,9 +335,10 @@ Below here is the toolbar settings GUI and its associated functions --- @param dst LuaGuiElement local function copy_style(src, dst) dst.style = src.style.name - dst.style.height = toolbar_button_small - dst.style.width = toolbar_button_small - dst.style.padding = -2 + local style = dst.style --[[@as LuaStyle]] + style.height = toolbar_button_small + style.width = toolbar_button_small + style.padding = -2 end --- Reorder the buttons relative to each other, this will update the datastore @@ -365,7 +366,7 @@ local function move_toolbar_button(player, item, offset) local other_element = Gui.get_left_element(other_left_element, player) local left_index = element.get_index_in_parent() local other_index = other_element.get_index_in_parent() - element.parent.swap_children(left_index, other_index) + assert(element.parent).swap_children(left_index, other_index) end -- If we are moving in/out of first/last place we need to update the move buttons @@ -620,7 +621,7 @@ elements.move_item_up = Gui.define("move_item_up") size = toolbar_button_small, }) :on_click(function(def, player, element) - local item = assert(element.parent.parent) + local item = assert(assert(element.parent).parent) move_toolbar_button(player, item, -1) end) @@ -635,7 +636,7 @@ elements.move_item_down = Gui.define("move_item_down") size = toolbar_button_small, }) :on_click(function(def, player, element) - local item = assert(element.parent.parent) + local item = assert(assert(element.parent).parent) move_toolbar_button(player, item, 1) end) diff --git a/exp_legacy/module/config/gui/player_list_actions.lua b/exp_legacy/module/config/gui/player_list_actions.lua index c7cb7919..c6bb968c 100644 --- a/exp_legacy/module/config/gui/player_list_actions.lua +++ b/exp_legacy/module/config/gui/player_list_actions.lua @@ -15,7 +15,8 @@ local Colors = require("modules/exp_util/include/color") local format_player_name = ExpUtil.format_player_name_locale --- Accessors injected by the gui so the actions can read the selected player and set the selected action -local get_selected_player, set_selected_action +local get_selected_player --- @type fun(player: LuaPlayer): LuaPlayer +local set_selected_action --- @type fun(player: LuaPlayer, action: string?) local function set_accessors(player_getter, action_setter) get_selected_player, set_selected_action = player_getter, action_setter end diff --git a/exp_legacy/module/modules/gui/warp-list.lua b/exp_legacy/module/modules/gui/warp-list.lua index 10fcd593..bcb974ef 100644 --- a/exp_legacy/module/modules/gui/warp-list.lua +++ b/exp_legacy/module/modules/gui/warp-list.lua @@ -180,7 +180,7 @@ local warp_icon_button = Gui.define("warp_icon_button") :style(Styles.sprite32) :on_click(function(def, player, element) if element.type == "choose-elem-button" then return end - local warp_id = element.parent.caption + local warp_id = assert(element.parent).caption Warps.teleport_player(warp_id, player) -- Reset the warp cooldown if the player does not have unlimited warps @@ -226,7 +226,7 @@ local warp_label = Gui.define("warp_label") horizontally_stretchable = true, } :on_click(function(def, player, element) - local warp_id = element.parent.caption + local warp_id = assert(element.parent).caption local warp = Warps.get_warp(warp_id) player.set_controller{ type = defines.controllers.remote, position = warp.position, surface = warp.surface } end) @@ -271,9 +271,9 @@ local warp_textfield = Gui.define("warp_textfield") right_margin = 2, } :on_confirmed(function(def, player, element) - local warp_id = element.parent.caption + local warp_id = assert(element.parent).caption local warp_name = element.text - local warp_icon = element.parent.parent["icon-" .. warp_id][warp_icon_editing.name].elem_value --[[@as SignalID]] + local warp_icon = assert(element.parent).parent["icon-" .. warp_id][warp_icon_editing.name].elem_value --[[@as SignalID]] if warp_icon.type == nil then warp_icon.type = "item" end Warps.set_editing(warp_id, player.name) Warps.update_warp(warp_id, warp_name, warp_icon, player.name) @@ -315,7 +315,7 @@ local cancel_edit_button = Gui.define("cancel_edit_button") } :style(Styles.sprite22) :on_click(function(def, player, element) - local warp_id = element.parent.caption + local warp_id = assert(element.parent).caption -- Check if this is the first edit, if so remove the warp. local warp = Warps.get_warp(warp_id) if warp.updates == 1 then @@ -337,7 +337,7 @@ local remove_warp_button = Gui.define("remove_warp_button") } :style(Styles.sprite22) :on_click(function(def, player, element) - local warp_id = element.parent.caption + local warp_id = assert(element.parent).caption Warps.remove_warp(warp_id) end) @@ -353,7 +353,7 @@ local edit_warp_button = Gui.define("edit_warp_button") } :style(Styles.sprite22) :on_click(function(def, player, element) - local warp_id = element.parent.caption + local warp_id = assert(element.parent).caption Warps.set_editing(warp_id, player.name, true) end) @@ -433,8 +433,8 @@ local function update_warp_elements(element, warp, warp_player_is_on, on_cooldow -- Check if button element is valid if not element or not element.valid then return end - local label_style = element.parent.parent["name-" .. warp.warp_id][warp_label.name].style - local warp_status_element = element.parent.parent["name-" .. warp.warp_id][warp_status.name] + local label_style = assert(element.parent).parent["name-" .. warp.warp_id][warp_label.name].style + local warp_status_element = assert(element.parent).parent["name-" .. warp.warp_id][warp_status.name] -- If player is not on a warp if not warp_player_is_on then