mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-13 00:45: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
|
end
|
||||||
|
|
||||||
-- Check if the player is within range
|
-- 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
|
if warp.surface == surface then
|
||||||
local dx, dy = px - warp_pos.x, py - warp_pos.y
|
local dx, dy = px - warp_pos.x, py - warp_pos.y
|
||||||
local dist = (dx * dx) + (dy * dy)
|
local dist = (dx * dx) + (dy * dy)
|
||||||
@@ -842,7 +842,7 @@ end)
|
|||||||
Event.add(defines.events.on_player_created, function(event)
|
Event.add(defines.events.on_player_created, function(event)
|
||||||
-- If the force has no spawn then make a spawn warp
|
-- If the force has no spawn then make a spawn warp
|
||||||
local player = game.players[event.player_index]
|
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)
|
local spawn_id = Warps.get_spawn_warp_id(force.name)
|
||||||
if not spawn_id then
|
if not spawn_id then
|
||||||
local spawn_position = force.get_spawn_position(player.surface)
|
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
|
local amount_of_machines = 1
|
||||||
if items_per_second then
|
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
|
end
|
||||||
|
|
||||||
for _, ingredient in ipairs(ingredients) do
|
for _, ingredient in ipairs(ingredients) do
|
||||||
@@ -43,7 +43,7 @@ Commands.new("ratio", { "exp-commands_ratio.description" })
|
|||||||
for i, product in ipairs(products) do
|
for i, product in ipairs(products) do
|
||||||
Commands.print{
|
Commands.print{
|
||||||
product.type == "item" and "exp-commands_ratio.item-out" or "exp-commands_ratio.fluid-out",
|
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
|
product.name
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ local function create_map_tag(corpse_data)
|
|||||||
message = message .. " at " .. time
|
message = message .. " at " .. time
|
||||||
end
|
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,
|
position = corpse_data.corpse.position,
|
||||||
icon = config.map_icon,
|
icon = config.map_icon,
|
||||||
text = message,
|
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.resource_patches.enabled then create_resource_patches(surface, offset) end
|
||||||
if config.turrets.enabled then update_turrets() 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)
|
player.teleport(offset, surface)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ end
|
|||||||
--- @param row_index number
|
--- @param row_index number
|
||||||
--- @param row_data ExpGui_ResearchMilestones.elements.milestone_table.row_data
|
--- @param row_data ExpGui_ResearchMilestones.elements.milestone_table.row_data
|
||||||
function Elements.milestone_table.refresh_row(milestone_table, row_index, 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.name.caption = row_data.name
|
||||||
row.target.caption = row_data.target
|
row.target.caption = row_data.target
|
||||||
row.achieved.caption = row_data.achieved
|
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 science_table = Gui.elements.scroll_table(parent, 190, 4)
|
||||||
local no_production_label = Elements.no_production_label(science_table)
|
local no_production_label = Elements.no_production_label(science_table)
|
||||||
Elements.no_production_label.refresh(no_production_label)
|
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
|
return science_table
|
||||||
end)
|
end)
|
||||||
:element_data{} --[[@as any]]
|
:element_data{} --[[@as any]]
|
||||||
@@ -280,7 +280,7 @@ function Elements.science_table.add_row(science_table, row_data)
|
|||||||
column_count = 2,
|
column_count = 2,
|
||||||
}
|
}
|
||||||
delta_table.style.padding = 0
|
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
|
-- Draw the net production label
|
||||||
local net = Elements.production_label(science_table, row_data.net)
|
local net = Elements.production_label(science_table, row_data.net)
|
||||||
|
|||||||
Reference in New Issue
Block a user