mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-13 00:45:11 +09:00
Assert optional api results across the scenario modules
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user