mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-12 16:35:11 +09:00
Assert row lookups and narrow force and style reads
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -799,7 +799,7 @@ Event.on_nth_tick(math.floor(60 / config.update_smoothing), function()
|
||||
end
|
||||
|
||||
-- Check if the player is within range
|
||||
local warp_pos = warp.position
|
||||
local warp_pos = warp.position --[[@as MapPosition.struct]]
|
||||
if warp.surface == surface then
|
||||
local dx, dy = px - warp_pos.x, py - warp_pos.y
|
||||
local dist = (dx * dx) + (dy * dy)
|
||||
@@ -842,7 +842,7 @@ end)
|
||||
Event.add(defines.events.on_player_created, function(event)
|
||||
-- If the force has no spawn then make a spawn warp
|
||||
local player = game.players[event.player_index]
|
||||
local force = player.force
|
||||
local force = player.force --[[@as LuaForce]]
|
||||
local spawn_id = Warps.get_spawn_warp_id(force.name)
|
||||
if not spawn_id then
|
||||
local spawn_position = force.get_spawn_position(player.surface)
|
||||
|
||||
@@ -29,7 +29,7 @@ Commands.new("ratio", { "exp-commands_ratio.description" })
|
||||
|
||||
local amount_of_machines = 1
|
||||
if items_per_second then
|
||||
amount_of_machines = math.ceil(products[1].amount * crafts_per_second)
|
||||
amount_of_machines = math.ceil(assert(assert(products[1]).amount) * crafts_per_second)
|
||||
end
|
||||
|
||||
for _, ingredient in ipairs(ingredients) do
|
||||
@@ -43,7 +43,7 @@ Commands.new("ratio", { "exp-commands_ratio.description" })
|
||||
for i, product in ipairs(products) do
|
||||
Commands.print{
|
||||
product.type == "item" and "exp-commands_ratio.item-out" or "exp-commands_ratio.fluid-out",
|
||||
math.round(product.amount * crafts_per_second, 3),
|
||||
math.round(assert(product.amount) * crafts_per_second, 3),
|
||||
product.name
|
||||
}
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ local function create_map_tag(corpse_data)
|
||||
message = message .. " at " .. time
|
||||
end
|
||||
|
||||
corpse_data.tag = player.force.add_chart_tag(corpse_data.corpse.surface, {
|
||||
corpse_data.tag = (player.force --[[@as LuaForce]]).add_chart_tag(corpse_data.corpse.surface, {
|
||||
position = corpse_data.corpse.position,
|
||||
icon = config.map_icon,
|
||||
text = message,
|
||||
|
||||
@@ -276,7 +276,7 @@ local function on_player_created(event)
|
||||
if config.resource_patches.enabled then create_resource_patches(surface, offset) end
|
||||
if config.turrets.enabled then update_turrets() end
|
||||
|
||||
player.force.set_spawn_position(offset, surface)
|
||||
(player.force --[[@as LuaForce]]).set_spawn_position(offset, surface)
|
||||
player.teleport(offset, surface)
|
||||
end
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ end
|
||||
--- @param row_index number
|
||||
--- @param row_data ExpGui_ResearchMilestones.elements.milestone_table.row_data
|
||||
function Elements.milestone_table.refresh_row(milestone_table, row_index, row_data)
|
||||
local row = Elements.milestone_table.data[milestone_table][row_index]
|
||||
local row = assert(Elements.milestone_table.data[milestone_table][row_index])
|
||||
row.name.caption = row_data.name
|
||||
row.target.caption = row_data.target
|
||||
row.achieved.caption = row_data.achieved
|
||||
|
||||
@@ -193,7 +193,7 @@ Elements.science_table = Gui.define("science_production/science_table")
|
||||
local science_table = Gui.elements.scroll_table(parent, 190, 4)
|
||||
local no_production_label = Elements.no_production_label(science_table)
|
||||
Elements.no_production_label.refresh(no_production_label)
|
||||
science_table.style.column_alignments[3] = "right"
|
||||
(science_table.style --[[@as LuaStyle]]).column_alignments[3] = "right"
|
||||
return science_table
|
||||
end)
|
||||
:element_data{} --[[@as any]]
|
||||
@@ -280,7 +280,7 @@ function Elements.science_table.add_row(science_table, row_data)
|
||||
column_count = 2,
|
||||
}
|
||||
delta_table.style.padding = 0
|
||||
delta_table.style.column_alignments[1] = "right"
|
||||
(delta_table.style --[[@as LuaStyle]]).column_alignments[1] = "right"
|
||||
|
||||
-- Draw the net production label
|
||||
local net = Elements.production_label(science_table, row_data.net)
|
||||
|
||||
Reference in New Issue
Block a user