From bbe25ec120c5bac6b0fd36a1063f141eba335ce5 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Tue, 28 Jan 2025 17:05:23 +0900 Subject: [PATCH] . --- exp_scenario/module/commands/waterfill.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/exp_scenario/module/commands/waterfill.lua b/exp_scenario/module/commands/waterfill.lua index 20d84005..6ca7a005 100644 --- a/exp_scenario/module/commands/waterfill.lua +++ b/exp_scenario/module/commands/waterfill.lua @@ -43,8 +43,9 @@ Selection.on_selection(SelectionName, function(event) local item_count_cliff = player.get_item_count("cliff-explosives") local item_count_craft = math.min(math.floor(player.get_item_count("explosives") / 10), player.get_item_count("barrel"), player.get_item_count("grenade")) + local item_count_total = item_count_cliff + item_count_craft - if (item_count_cliff < area_size) and (item_count_craft < area_size) then + if item_count_total < area_size then player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count_cliff }, Commands.print_settings.error) return end @@ -68,9 +69,11 @@ Selection.on_selection(SelectionName, function(event) if item_count_cliff >= t_diff then player.remove_item{ name = "cliff-explosives", count = t_diff } else - player.remove_item{ name = "explosives", count = 10 * t_diff } - player.remove_item{ name = "barrel", count = t_diff } - player.remove_item{ name = "grenade", count = t_diff } + local item_count_needed = t_diff - item_count_cliff + player.remove_item{ name = "cliff-explosives", count = item_count_cliff } + player.remove_item{ name = "explosives", count = 10 * item_count_needed } + player.remove_item{ name = "barrel", count = item_count_needed } + player.remove_item{ name = "grenade", count = item_count_needed } end if remaining_tiles > 0 then