summaryrefslogtreecommitdiff
path: root/worldedit_commands/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'worldedit_commands/init.lua')
-rw-r--r--worldedit_commands/init.lua47
1 files changed, 35 insertions, 12 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index 08a9811..b9313cc 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -10,6 +10,7 @@ if minetest.place_schematic then
worldedit.prob_list = {}
end
+dofile(minetest.get_modpath("worldedit_commands") .. "/cuboid.lua")
dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua")
local safe_region, check_region = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
@@ -588,7 +589,7 @@ minetest.register_chatcommand("/spiral", {
end
local node = get_node(name, nodename)
if not node then return nil end
- return check_region(name, param)
+ return 1 -- TODO: return an useful value
end),
})
@@ -856,6 +857,30 @@ minetest.register_chatcommand("/fixlight", {
end),
})
+minetest.register_chatcommand("/drain", {
+ params = "",
+ description = "Remove any fluid node within the current WorldEdit region",
+ privs = {worldedit=true},
+ func = safe_region(function(name, param)
+ -- TODO: make an API function for this
+ local count = 0
+ local pos1, pos2 = worldedit.sort_pos(worldedit.pos1[name], worldedit.pos2[name])
+ for x = pos1.x, pos2.x do
+ for y = pos1.y, pos2.y do
+ for z = pos1.z, pos2.z do
+ local n = minetest.get_node({x=x, y=y, z=z}).name
+ local d = minetest.registered_nodes[n]
+ if d ~= nil and (d["drawtype"] == "liquid" or d["drawtype"] == "flowingliquid") then
+ minetest.remove_node({x=x, y=y, z=z})
+ count = count + 1
+ end
+ end
+ end
+ end
+ worldedit.player_notify(name, count .. " nodes updated")
+ end),
+})
+
minetest.register_chatcommand("/hide", {
params = "",
description = "Hide all nodes in the current WorldEdit region non-destructively",
@@ -1145,8 +1170,8 @@ minetest.register_chatcommand("/mtschemprob", {
return
end
for k,v in pairs(problist) do
- local prob = math.floor(((v["prob"] / 256) * 100) * 100 + 0.5) / 100
- text = text .. minetest.pos_to_string(v["pos"]) .. ": " .. prob .. "% | "
+ local prob = math.floor(((v.prob / 256) * 100) * 100 + 0.5) / 100
+ text = text .. minetest.pos_to_string(v.pos) .. ": " .. prob .. "% | "
end
worldedit.player_notify(name, "currently set node probabilities:")
worldedit.player_notify(name, text)
@@ -1156,16 +1181,14 @@ minetest.register_chatcommand("/mtschemprob", {
end,
})
-minetest.register_on_player_receive_fields(
- function(player, formname, fields)
- if (formname == "prob_val_enter") and (fields.text ~= "") then
- local name = player:get_player_name()
- local prob_entry = {pos=worldedit.prob_pos[name], prob=tonumber(fields.text)}
- local index = table.getn(worldedit.prob_list[name]) + 1
- worldedit.prob_list[name][index] = prob_entry
- end
+minetest.register_on_player_receive_fields(function(player, formname, fields)
+ if formname == "prob_val_enter" and not (fields.text == "" or fields.text == nil) then
+ local name = player:get_player_name()
+ local prob_entry = {pos=worldedit.prob_pos[name], prob=tonumber(fields.text)}
+ local index = table.getn(worldedit.prob_list[name]) + 1
+ worldedit.prob_list[name][index] = prob_entry
end
-)
+end)
minetest.register_chatcommand("/clearobjects", {
params = "",