mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
.
This commit is contained in:
@@ -36,15 +36,26 @@ Selection.on_selection(SelectionName, function(event)
|
||||
]]
|
||||
|
||||
local area_size = (area.right_bottom.x - area.left_top.x) * (area.right_bottom.y - area.left_top.y)
|
||||
|
||||
if area_size > 1000 then
|
||||
player.print({ "exp-commands_waterfill.area-too-large", 1000, area_size }, Commands.print_settings.error)
|
||||
return
|
||||
end
|
||||
|
||||
local item_count = player.get_item_count("cliff-explosives")
|
||||
if item_count < area_size then
|
||||
player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count }, Commands.print_settings.error)
|
||||
local item_count_cliff = player.get_item_count("cliff-explosives")
|
||||
local item_count_cliff_craft = math.min(math.floor(player.get_item_count("explosives") / 10), player.get_item_count("barrel"), player.get_item_count("grenade"))
|
||||
local item_count_type_bool = true
|
||||
|
||||
if item_count_cliff > 0 and item_count_cliff < area_size then
|
||||
player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count_cliff }, Commands.print_settings.error)
|
||||
return
|
||||
elseif item_count_cliff_craft > 0 then
|
||||
if item_count_cliff_craft < area_size then
|
||||
player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count_cliff_craft }, Commands.print_settings.error)
|
||||
return
|
||||
else
|
||||
item_count_type_bool = false
|
||||
end
|
||||
end
|
||||
|
||||
local tile_count = 0
|
||||
@@ -61,7 +72,14 @@ Selection.on_selection(SelectionName, function(event)
|
||||
|
||||
surface.set_tiles(tiles_to_make, true, "abort_on_collision", true, false, player, 0)
|
||||
local remaining_tiles = surface.count_tiles_filtered{ area = area, name = "water-mud" }
|
||||
player.remove_item{ name = "cliff-explosives", count = tile_count - remaining_tiles }
|
||||
|
||||
if item_count_type_bool then
|
||||
player.remove_item{ name = "cliff-explosives", count = tile_count - remaining_tiles }
|
||||
else
|
||||
player.remove_item{ name = "explosives", count = 10 * (tile_count - remaining_tiles) }
|
||||
player.remove_item{ name = "barrel", count = tile_count - remaining_tiles }
|
||||
player.remove_item{ name = "grenade", count = tile_count - remaining_tiles }
|
||||
end
|
||||
|
||||
if remaining_tiles > 0 then
|
||||
player.print({ "exp-commands_waterfill.part-complete", tile_count, remaining_tiles }, Commands.print_settings.default)
|
||||
|
||||
Reference in New Issue
Block a user