Allow Waterfill with Recipe (#364)

* Update waterfill.lua

* Update en.cfg

* Update zh-CN.cfg

* Update zh-TW.cfg

* Update zh-CN.cfg

* Update zh-TW.cfg

* Update waterfill.lua

* Update waterfill.lua

* Update waterfill.lua

* Update tool.lua

* Update waterfill.lua
This commit is contained in:
2025-02-04 06:43:40 +09:00
committed by GitHub
parent 7adf4a4477
commit a041fe0a38
5 changed files with 42 additions and 15 deletions

View File

@@ -13,11 +13,16 @@ Commands.new("waterfill", { "exp-commands_waterfill.description" })
if Selection.is_selecting(player, SelectionName) then
Selection.stop(player)
return Commands.status.success{ "exp-commands_waterfill.exit" }
elseif player.get_item_count("cliff-explosives") == 0 then
return Commands.status.error{ "exp-commands_waterfill.requires-explosives" }
else
Selection.start(player, SelectionName)
return Commands.status.success{ "exp-commands_waterfill.enter" }
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_total == 0 then
return player.print{ "exp-commands_waterfill.requires-explosives" }
else
Selection.start(player, SelectionName)
return player.print{ "exp-commands_waterfill.enter" }
end
end
end)
@@ -39,9 +44,12 @@ Selection.on_selection(SelectionName, function(event)
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_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_total < area_size then
player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count_total }, Commands.print_settings.error)
return
end
@@ -59,7 +67,21 @@ 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 }
local t_diff = tile_count - remaining_tiles
if item_count_cliff >= t_diff then
player.remove_item{ name = "cliff-explosives", count = t_diff }
else
if item_count_cliff > 0 then
player.remove_item{ name = "cliff-explosives", count = item_count_cliff }
end
local item_count_needed = t_diff - item_count_cliff
if item_count_needed > 0 then
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
end
if remaining_tiles > 0 then
player.print({ "exp-commands_waterfill.part-complete", tile_count, remaining_tiles }, Commands.print_settings.default)

View File

@@ -278,6 +278,6 @@ enter=Entered waterfill selection mode, select the area to fill with water.
exit=Exited waterfill selection mode.
nauvis-only=Can only waterfill on Nauvis, this may change in the future.
area-too-large=Selected area is too large, must be less than __1__ tiles, selected __2__.
too-few-explosives=Requires __1__ __ITEM__cliff-explosives__ you have __2__.
too-few-explosives=Requires __1__ __ITEM__cliff-explosives__ or its ingredients, you have __2__.
part-complete=__1__ tiles were filled with water, but entities are blocking __2__ tiles.
complete=__1__ tiles were filled with water.

View File

@@ -278,6 +278,6 @@ enter=現在進入挖水區域選擇
exit=已進入挖水區域選擇
nauvis-only=只可在地星上填水,之後可能會再改變。
area-too-large=區域太大了,需少過 __1__ 格,你選了 __2__ 格。
too-few-explosives=需要 __1__ 個 __ITEM__cliff-explosives__你現在有 __2__ 個。
too-few-explosives=需要 __1__ 個 __ITEM__cliff-explosives__ 或其材料,你現在有 __2__ 個。
part-complete=__1__ 格已填水,但有 __2__ 格有東西擋著。
complete=__1__ 格已經轉換好。

View File

@@ -278,6 +278,6 @@ enter=現在進入挖水區域選擇
exit=已進入挖水區域選擇
nauvis-only=只可在地星上填水,之後可能會再改變。
area-too-large=區域太大了,需少過 __1__ 格,你選了 __2__ 格。
too-few-explosives=需要 __1__ 個 __ITEM__cliff-explosives__你現在有 __2__ 個。
too-few-explosives=需要 __1__ 個 __ITEM__cliff-explosives__ 或其材料,你現在有 __2__ 個。
part-complete=__1__ 格已填水,但有 __2__ 格有東西擋著。
complete=__1__ 格已經轉換好。