Skip to content

Commit 61ab240

Browse files
committed
Add //drain
1 parent b06e004 commit 61ab240

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ChatCommands.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ Fixes the lighting in the current WorldEdit region.
291291

292292
//fixlight
293293

294+
### `//drain`
295+
296+
Removes any fluid node within the current WorldEdit region.
297+
298+
//drain
299+
294300
### `//hide`
295301

296302
Hide all nodes in the current WorldEdit region non-destructively.

worldedit_commands/init.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,30 @@ minetest.register_chatcommand("/fixlight", {
838838
end),
839839
})
840840

841+
minetest.register_chatcommand("/drain", {
842+
params = "",
843+
description = "Remove any fluid node within the current WorldEdit region",
844+
privs = {worldedit=true},
845+
func = safe_region(function(name, param)
846+
-- TODO: make an API function for this
847+
local count = 0
848+
local pos1, pos2 = worldedit.sort_pos(worldedit.pos1[name], worldedit.pos2[name])
849+
for x = pos1.x, pos2.x do
850+
for y = pos1.y, pos2.y do
851+
for z = pos1.z, pos2.z do
852+
local n = minetest.get_node({x=x, y=y, z=z}).name
853+
local d = minetest.registered_nodes[n]
854+
if d ~= nil and (d["drawtype"] == "liquid" or d["drawtype"] == "flowingliquid") then
855+
minetest.remove_node({x=x, y=y, z=z})
856+
count = count + 1
857+
end
858+
end
859+
end
860+
end
861+
worldedit.player_notify(name, count .. " nodes updated")
862+
end),
863+
})
864+
841865
minetest.register_chatcommand("/hide", {
842866
params = "",
843867
description = "Hide all nodes in the current WorldEdit region non-destructively",

0 commit comments

Comments
 (0)