From 0f54eaee0b05aa877dd2d3beea735759449dfcdc Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 19 Apr 2025 00:40:09 +0900 Subject: [PATCH] . --- exp_scenario/module/commands/waterfill.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exp_scenario/module/commands/waterfill.lua b/exp_scenario/module/commands/waterfill.lua index 02a32ad8..1adbb29b 100644 --- a/exp_scenario/module/commands/waterfill.lua +++ b/exp_scenario/module/commands/waterfill.lua @@ -65,16 +65,19 @@ Selection.on_selection(SelectionName, function(event) end local tile_count = 0 + local remaining_tiles = 0 local tiles_to_make = {} local chest = surface.find_entities_filtered{ area = area, name = "steel-chest", force = player.force } local tile_to_apply = (surface.planet and planet[surface.planet]) or "water-mud" if #chest > 0 then for _, v in pairs(chest) do - if v.get_inventory(defines.inventory.chest).is_empty() then + if v.get_inventory(defines.inventory.chest).is_empty() and tile_count < item_count_total then tile_count = tile_count + 1 tiles_to_make[tile_count] = { name = tile_to_apply, position = { v.position.x, v.position.y } } v.destroy() + elseif v.get_inventory(defines.inventory.chest).is_empty() then + remaining_tiles = remaining_tiles + 1 end end @@ -85,10 +88,11 @@ Selection.on_selection(SelectionName, function(event) tiles_to_make[tile_count] = { name = tile_to_apply, position = { x, y } } end end + + local remaining_tiles = surface.count_tiles_filtered{ area = area, name = tile_to_apply } end surface.set_tiles(tiles_to_make, true, "abort_on_collision", true, false, player, 0) - local remaining_tiles = surface.count_tiles_filtered{ area = area, name = tile_to_apply } local t_diff = tile_count - remaining_tiles if item_count_cliff >= t_diff and t_diff > 0 then