diff --git a/exp_scenario/module/commands/waterfill.lua b/exp_scenario/module/commands/waterfill.lua index 6d9cc9d2..a9313f92 100644 --- a/exp_scenario/module/commands/waterfill.lua +++ b/exp_scenario/module/commands/waterfill.lua @@ -70,7 +70,7 @@ SelectArea:on_selection(function(event) if #chests > 0 then for _, chest in pairs(chests) do tile_count = tile_count + 1 - if chest.get_inventory(defines.inventory.chest).is_empty() and tile_count <= item_count_total then + if assert(chest.get_inventory(defines.inventory.chest)).is_empty() and tile_count <= item_count_total then tiles_to_make[tile_count] = { name = tile_to_apply, position = { chest.position.x, chest.position.y } } chest.destroy() else diff --git a/exp_scenario/module/control/custom_start.lua b/exp_scenario/module/control/custom_start.lua index 1c4e64ff..62d59a1a 100644 --- a/exp_scenario/module/control/custom_start.lua +++ b/exp_scenario/module/control/custom_start.lua @@ -8,7 +8,7 @@ local floor = math.floor --- Give a player their starting items --- @param player LuaPlayer local function give_starting_items(player) - local get_prod_stats = player.force.get_item_production_statistics(player.physical_surface) + local get_prod_stats = (player.force --[[@as LuaForce]]).get_item_production_statistics(player.physical_surface) local get_input_count = get_prod_stats.get_input_count local insert_param = { name = "", count = 0 } local insert = player.insert diff --git a/exp_scenario/module/control/damage_popups.lua b/exp_scenario/module/control/damage_popups.lua index 54dfc0e1..146a94fe 100644 --- a/exp_scenario/module/control/damage_popups.lua +++ b/exp_scenario/module/control/damage_popups.lua @@ -26,11 +26,12 @@ local function on_entity_damaged(event) -- Outputs the message as floating text if message then + local entity_position = entity.position --[[@as MapPosition.struct]] local entity_radius = max(1, entity.get_radius()) local offset = (random() - 0.5) * entity_radius * config.damage_location_variance - local position = { x = entity.position.x + offset, y = entity.position.y - entity_radius } + local position = { x = entity_position.x + offset, y = entity_position.y - entity_radius } - local health_percentage = entity.get_health_ratio() + local health_percentage = assert(entity.get_health_ratio()) local color = { r = 1 - health_percentage, g = health_percentage, b = 0 } FlyingText.create{ diff --git a/exp_scenario/module/control/deconstruction_log.lua b/exp_scenario/module/control/deconstruction_log.lua index 98ceb9ea..5d1743be 100644 --- a/exp_scenario/module/control/deconstruction_log.lua +++ b/exp_scenario/module/control/deconstruction_log.lua @@ -42,7 +42,7 @@ local function format_position(pos) end --- Convert an area to a string ---- @param area BoundingBox +--- @param area ExpUtil_AABB.Box --- @return string local function format_area(area) return format_string("%.1f,%.1f,%.1f,%.1f", area.left_top.x, area.left_top.y, area.right_bottom.x, area.right_bottom.y) diff --git a/exp_scenario/module/control/extra_logging.lua b/exp_scenario/module/control/extra_logging.lua index d469c390..07055245 100644 --- a/exp_scenario/module/control/extra_logging.lua +++ b/exp_scenario/module/control/extra_logging.lua @@ -23,7 +23,7 @@ end --- @param event EventData.on_cargo_pod_finished_ascending local function on_cargo_pod_finished_ascending(event) if event.launched_by_rocket then - local force = event.cargo_pod.force + local force = event.cargo_pod.force --[[@as LuaForce]] if force.rockets_launched >= config.rocket_launch_display_rate and force.rockets_launched % config.rocket_launch_display_rate == 0 then add_log_line("[ROCKET]", force.rockets_launched, "rockets launched") elseif config.rocket_launch_display[force.rockets_launched] then @@ -38,7 +38,7 @@ local function on_pre_player_died(event) local cause = event.cause if cause then if cause.type == "character" then - add_log_line("[DEATH]", player.name, "died because of", cause.player.name) + add_log_line("[DEATH]", player.name, "died because of", assert(cause.player).name) else add_log_line("[DEATH]", player.name, "died because of", cause.name) end diff --git a/exp_util/module/selection.lua b/exp_util/module/selection.lua index c6695ca7..461963f6 100644 --- a/exp_util/module/selection.lua +++ b/exp_util/module/selection.lua @@ -54,7 +54,7 @@ local selection_tool = { name = "selection-tool" } --- @param player LuaPlayer --- @return boolean? local function has_selection_tool_in_hand(player) - return player.cursor_stack and player.cursor_stack.valid_for_read and player.cursor_stack.name == "selection-tool" + return assert(player.cursor_stack) and assert(player.cursor_stack).valid_for_read and assert(player.cursor_stack).name == "selection-tool" end --- Give a selection tool to a player if they don't have one @@ -62,7 +62,7 @@ end local function give_selection_tool(player) if has_selection_tool_in_hand(player) then return end player.clear_cursor() - player.cursor_stack.set_stack(selection_tool) + assert(player.cursor_stack).set_stack(selection_tool) -- This does not work for selection planners, will make a feature request for it --player.cursor_stack_temporary = true @@ -84,7 +84,7 @@ end local function remove_selection_tool(player, old_character) -- Remove the selection tool if has_selection_tool_in_hand(player) then - player.cursor_stack.clear() + assert(player.cursor_stack).clear() else player.remove_item(selection_tool) end