Introduce type parameter for worldedit.player_notify

This commit is contained in:
sfan5 2024-04-22 17:33:16 +02:00
parent d13ba673fe
commit 1d8d9a704f
12 changed files with 235 additions and 212 deletions

View File

@ -9,7 +9,7 @@ local brush_on_use = function(itemstack, placer)
if cmd == "" then if cmd == "" then
worldedit.player_notify(name, worldedit.player_notify(name,
S("This brush is not bound, use @1 to bind a command to it.", S("This brush is not bound, use @1 to bind a command to it.",
minetest.colorize("#00ffff", "//brush"))) minetest.colorize("#00ffff", "//brush")), "info")
return false return false
end end
@ -19,7 +19,7 @@ local brush_on_use = function(itemstack, placer)
local has_privs, missing_privs = minetest.check_player_privs(name, cmddef.privs) local has_privs, missing_privs = minetest.check_player_privs(name, cmddef.privs)
if not has_privs then if not has_privs then
worldedit.player_notify(name, worldedit.player_notify(name,
S("Missing privileges: @1", table.concat(missing_privs, ", "))) S("Missing privileges: @1", table.concat(missing_privs, ", ")), "error")
return false return false
end end
@ -29,7 +29,7 @@ local brush_on_use = function(itemstack, placer)
local ray = minetest.raycast(raybegin, rayend, false, true) local ray = minetest.raycast(raybegin, rayend, false, true)
local pointed_thing = ray:next() local pointed_thing = ray:next()
if pointed_thing == nil then if pointed_thing == nil then
worldedit.player_notify(name, S("Too far away.")) worldedit.player_notify(name, S("Too far away."), "error")
return false return false
end end
@ -38,17 +38,17 @@ local brush_on_use = function(itemstack, placer)
worldedit.pos2[name] = nil worldedit.pos2[name] = nil
worldedit.marker_update(name) worldedit.marker_update(name)
-- this isn't really clean...
local player_notify_old = worldedit.player_notify
worldedit.player_notify = function(name, msg)
if string.match(msg, "^%d") then return end -- discard "1234 nodes added."
return player_notify_old(name, msg)
end
assert(cmddef.require_pos < 2) assert(cmddef.require_pos < 2)
local parsed = {cmddef.parse(meta:get_string("params"))} local parsed = {cmddef.parse(meta:get_string("params"))}
if not table.remove(parsed, 1) then return false end -- shouldn't happen if not table.remove(parsed, 1) then return false end -- shouldn't happen
-- discard success messages
local player_notify_old = worldedit.player_notify
worldedit.player_notify = function(name, msg, typ)
if typ == "ok" then return end
return player_notify_old(name, msg, typ)
end
minetest.log("action", string.format("%s uses WorldEdit brush (//%s) at %s", minetest.log("action", string.format("%s uses WorldEdit brush (//%s) at %s",
name, cmd, minetest.pos_to_string(pointed_thing.under))) name, cmd, minetest.pos_to_string(pointed_thing.under)))
cmddef.func(name, unpack(parsed)) cmddef.func(name, unpack(parsed))
@ -86,29 +86,26 @@ worldedit.register_command("brush", {
func = function(name, cmd, params) func = function(name, cmd, params)
local itemstack = minetest.get_player_by_name(name):get_wielded_item() local itemstack = minetest.get_player_by_name(name):get_wielded_item()
if itemstack == nil or itemstack:get_name() ~= "worldedit:brush" then if itemstack == nil or itemstack:get_name() ~= "worldedit:brush" then
worldedit.player_notify(name, S("Not holding brush item.")) return false, S("Not holding brush item.")
return
end end
cmd = cmd:lower() cmd = cmd:lower()
local meta = itemstack:get_meta() local meta = itemstack:get_meta()
if cmd == "none" then if cmd == "none" then
meta:from_table(nil) meta:from_table(nil)
worldedit.player_notify(name, S("Brush assignment cleared.")) worldedit.player_notify(name, S("Brush assignment cleared."), "ok")
else else
local cmddef = worldedit.registered_commands[cmd] local cmddef = worldedit.registered_commands[cmd]
if cmddef == nil or cmddef.require_pos ~= 1 then if cmddef == nil or cmddef.require_pos ~= 1 then
worldedit.player_notify(name, S("@1 cannot be used with brushes", return false, S("@1 cannot be used with brushes",
minetest.colorize("#00ffff", "//"..cmd))) minetest.colorize("#00ffff", "//"..cmd))
return
end end
-- Try parsing command params so we can give the user feedback -- Try parsing command params so we can give the user feedback
local ok, err = cmddef.parse(params) local ok, err = cmddef.parse(params)
if not ok then if not ok then
err = err or S("invalid usage") err = err or S("invalid usage")
worldedit.player_notify(name, S("Error with command: @1", err)) return false, S("Error with command: @1", err)
return
end end
meta:set_string("command", cmd) meta:set_string("command", cmd)
@ -116,7 +113,7 @@ worldedit.register_command("brush", {
local fullcmd = minetest.colorize("#00ffff", "//"..cmd) .. " " .. params local fullcmd = minetest.colorize("#00ffff", "//"..cmd) .. " " .. params
meta:set_string("description", meta:set_string("description",
minetest.registered_tools["worldedit:brush"].description .. ": " .. fullcmd) minetest.registered_tools["worldedit:brush"].description .. ": " .. fullcmd)
worldedit.player_notify(name, S("Brush assigned to command: @1", fullcmd)) worldedit.player_notify(name, S("Brush assigned to command: @1", fullcmd), "ok")
end end
minetest.get_player_by_name(name):set_wielded_item(itemstack) minetest.get_player_by_name(name):set_wielded_item(itemstack)
end, end,

View File

@ -25,13 +25,13 @@ worldedit.register_command("lua", {
if err == nil then if err == nil then
minetest.log("action", name .. " executed " .. param) minetest.log("action", name .. " executed " .. param)
if ret ~= "nil" then if ret ~= "nil" then
worldedit.player_notify(name, "code successfully executed, returned " .. ret) worldedit.player_notify(name, "code successfully executed, returned " .. ret, "info")
else else
worldedit.player_notify(name, "code successfully executed") worldedit.player_notify(name, "code successfully executed", "ok")
end end
else else
minetest.log("action", name .. " tried to execute " .. param) minetest.log("action", name .. " tried to execute " .. param)
worldedit.player_notify(name, "code error: " .. err) worldedit.player_notify(name, "code error: " .. err, "error")
end end
end, end,
}) })
@ -49,10 +49,10 @@ worldedit.register_command("luatransform", {
func = function(name, param) func = function(name, param)
local err = worldedit.luatransform(worldedit.pos1[name], worldedit.pos2[name], param) local err = worldedit.luatransform(worldedit.pos1[name], worldedit.pos2[name], param)
if err then if err then
worldedit.player_notify(name, "code error: " .. err, false) worldedit.player_notify(name, "code error: " .. err, "error")
minetest.log("action", name.." tried to execute luatransform "..param) minetest.log("action", name.." tried to execute luatransform "..param)
else else
worldedit.player_notify(name, "code successfully executed", false) worldedit.player_notify(name, "code successfully executed", "ok")
minetest.log("action", name.." executed luatransform "..param) minetest.log("action", name.." executed luatransform "..param)
end end
end, end,

View File

@ -249,14 +249,14 @@ worldedit.register_command("cubeapply", {
end, end,
nodes_needed = function(name, sidex, sidey, sidez, cmd, parsed) nodes_needed = function(name, sidex, sidey, sidez, cmd, parsed)
-- its not possible to defer to the target command at this point -- its not possible to defer to the target command at this point
-- FIXME: why not?
return sidex * sidey * sidez return sidex * sidey * sidez
end, end,
func = function(name, sidex, sidey, sidez, cmd, parsed) func = function(name, sidex, sidey, sidez, cmd, parsed)
local cmddef = assert(worldedit.registered_commands[cmd]) local cmddef = assert(worldedit.registered_commands[cmd])
local success, missing_privs = minetest.check_player_privs(name, cmddef.privs) local success, missing_privs = minetest.check_player_privs(name, cmddef.privs)
if not success then if not success then
worldedit.player_notify(name, S("Missing privileges: @1", table.concat(missing_privs, ", "))) return false, S("Missing privileges: @1", table.concat(missing_privs, ", "))
return
end end
-- update region to be the cuboid the user wanted -- update region to be the cuboid the user wanted

View File

@ -31,13 +31,13 @@ local function chatcommand_handler(cmd_name, name, param)
if def.require_pos == 2 then if def.require_pos == 2 then
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then if pos1 == nil or pos2 == nil then
worldedit.player_notify(name, S("no region selected")) worldedit.player_notify(name, S("no region selected"), "error")
return return
end end
elseif def.require_pos == 1 then elseif def.require_pos == 1 then
local pos1 = worldedit.pos1[name] local pos1 = worldedit.pos1[name]
if pos1 == nil then if pos1 == nil then
worldedit.player_notify(name, S("no position 1 selected")) worldedit.player_notify(name, S("no position 1 selected"), "error")
return return
end end
end end
@ -45,14 +45,14 @@ local function chatcommand_handler(cmd_name, name, param)
local parsed = {def.parse(param)} local parsed = {def.parse(param)}
local success = table.remove(parsed, 1) local success = table.remove(parsed, 1)
if not success then if not success then
worldedit.player_notify(name, parsed[1] or S("invalid usage")) worldedit.player_notify(name, parsed[1] or S("invalid usage"), "error")
return return
end end
local run = function() local run = function()
local _, msg = def.func(name, unpack(parsed)) local ok, msg = def.func(name, unpack(parsed))
if msg then if msg then
minetest.chat_send_player(name, msg) worldedit.player_notify(name, msg, ok and "ok" or "error")
end end
end end
@ -71,7 +71,7 @@ local function chatcommand_handler(cmd_name, name, param)
ok = ok and ( (v == nil and old_state[i] == nil) or vector.equals(v, old_state[i]) ) ok = ok and ( (v == nil and old_state[i] == nil) or vector.equals(v, old_state[i]) )
end end
if not ok then if not ok then
worldedit.player_notify(name, S("ERROR: the operation was cancelled because the region has changed.")) worldedit.player_notify(name, S("ERROR: the operation was cancelled because the region has changed."), "error")
return return
end end
@ -149,8 +149,27 @@ do
end end
function worldedit.player_notify(name, message) -- Notifies a player of something related to WorldEdit.
minetest.chat_send_player(name, "WorldEdit -!- " .. message) -- Message types:
-- "error" = An operation did not work as expected.
-- "ok" = An operation completed successfully. Because notifications of this type
-- can be filtered, use this ONLY for generic messages like "1234 nodes set".
-- "info" = Other informational messages
-- @param name Name of player
-- @param message Message text
-- @param typ Type of message (optional but strongly recommend)
function worldedit.player_notify(name, message, typ)
local t = {
"WorldEdit",
"-!-",
tostring(message)
}
if typ == "error" then
t[2] = minetest.colorize("#f22", t[2])
elseif typ == "ok" then
t[2] = minetest.colorize("#2f2", t[2])
end
minetest.chat_send_player(name, table.concat(t, " "))
end end
-- Determines the axis in which a player is facing, returning an axis ("x", "y", or "z") and the sign (1 or -1) -- Determines the axis in which a player is facing, returning an axis ("x", "y", or "z") and the sign (1 or -1)
@ -178,11 +197,92 @@ worldedit.register_command("about", {
"commands, or find more information at @3", "commands, or find more information at @3",
worldedit.version_string, minetest.colorize("#00ffff", "//help"), worldedit.version_string, minetest.colorize("#00ffff", "//help"),
"https://github.com/Uberi/Minetest-WorldEdit" "https://github.com/Uberi/Minetest-WorldEdit"
)) ), "info")
end, end,
}) })
-- initially copied from builtin/chatcommands.lua -- initially copied from builtin/chatcommands.lua
local function help_command(name, param)
local function format_help_line(cmd, def, follow_alias)
local msg = minetest.colorize("#00ffff", "//"..cmd)
if def.name ~= cmd then
msg = msg .. ": " .. S("alias to @1",
minetest.colorize("#00ffff", "//"..def.name))
if follow_alias then
msg = msg .. "\n" .. format_help_line(def.name, def)
end
else
if def.params and def.params ~= "" then
msg = msg .. " " .. def.params
end
if def.description and def.description ~= "" then
msg = msg .. ": " .. def.description
end
end
return msg
end
-- @param cmds list of {cmd, def}
local function sort_cmds(cmds)
table.sort(cmds, function(c1, c2)
local cmd1, cmd2 = c1[1], c2[1]
local def1, def2 = c1[2], c2[2]
-- by category (this puts the empty category first)
if def1.category ~= def2.category then
return def1.category < def2.category
end
-- put aliases last
if (cmd1 ~= def1.name) ~= (cmd2 ~= def2.name) then
return cmd2 ~= def2.name
end
-- then by name
return c1[1] < c2[1]
end)
end
if not minetest.check_player_privs(name, "worldedit") then
return false, S("You are not allowed to use any WorldEdit commands.")
end
if param == "" then
local list = {}
for cmd, def in pairs(worldedit.registered_commands) do
if minetest.check_player_privs(name, def.privs) then
list[#list + 1] = cmd
end
end
table.sort(list)
local help = minetest.colorize("#00ffff", "//help")
return true, S("Available commands: @1@n"
.. "Use '@2' to get more information,"
.. " or '@3' to list everything.",
table.concat(list, " "), help .. " <cmd>", help .. " all")
elseif param == "all" then
local cmds = {}
for cmd, def in pairs(worldedit.registered_commands) do
if minetest.check_player_privs(name, def.privs) then
cmds[#cmds + 1] = {cmd, def}
end
end
sort_cmds(cmds)
local list = {}
local last_cat = ""
for _, e in ipairs(cmds) do
if e[2].category ~= last_cat then
last_cat = e[2].category
list[#list + 1] = "---- " .. last_cat
end
list[#list + 1] = format_help_line(e[1], e[2])
end
return true, S("Available commands:@n") .. table.concat(list, "\n")
else
local def = worldedit.registered_commands[param]
if not def then
return false, S("Command not available: ") .. param
else
return true, format_help_line(param, def, true)
end
end
end
worldedit.register_command("help", { worldedit.register_command("help", {
privs = {}, privs = {},
params = "[all/<cmd>]", params = "[all/<cmd>]",
@ -191,83 +291,9 @@ worldedit.register_command("help", {
return true, param return true, param
end, end,
func = function(name, param) func = function(name, param)
local function format_help_line(cmd, def, follow_alias) local ok, msg = help_command(name, param)
local msg = minetest.colorize("#00ffff", "//"..cmd) if msg then
if def.name ~= cmd then worldedit.player_notify(name, msg, ok and "info" or "error")
msg = msg .. ": " .. S("alias to @1",
minetest.colorize("#00ffff", "//"..def.name))
if follow_alias then
msg = msg .. "\n" .. format_help_line(def.name, def)
end
else
if def.params and def.params ~= "" then
msg = msg .. " " .. def.params
end
if def.description and def.description ~= "" then
msg = msg .. ": " .. def.description
end
end
return msg
end
-- @param cmds list of {cmd, def}
local function sort_cmds(cmds)
table.sort(cmds, function(c1, c2)
local cmd1, cmd2 = c1[1], c2[1]
local def1, def2 = c1[2], c2[2]
-- by category (this puts the empty category first)
if def1.category ~= def2.category then
return def1.category < def2.category
end
-- put aliases last
if (cmd1 ~= def1.name) ~= (cmd2 ~= def2.name) then
return cmd2 ~= def2.name
end
-- then by name
return c1[1] < c2[1]
end)
end
if not minetest.check_player_privs(name, "worldedit") then
return false, S("You are not allowed to use any WorldEdit commands.")
end
if param == "" then
local list = {}
for cmd, def in pairs(worldedit.registered_commands) do
if minetest.check_player_privs(name, def.privs) then
list[#list + 1] = cmd
end
end
table.sort(list)
local help = minetest.colorize("#00ffff", "//help")
return true, S("Available commands: @1@n"
.. "Use '@2' to get more information,"
.. " or '@3' to list everything.",
table.concat(list, " "), help .. " <cmd>", help .. " all")
elseif param == "all" then
local cmds = {}
for cmd, def in pairs(worldedit.registered_commands) do
if minetest.check_player_privs(name, def.privs) then
cmds[#cmds + 1] = {cmd, def}
end
end
sort_cmds(cmds)
local list = {}
local last_cat = ""
for _, e in ipairs(cmds) do
if e[2].category ~= last_cat then
last_cat = e[2].category
list[#list + 1] = "---- " .. last_cat
end
list[#list + 1] = format_help_line(e[1], e[2])
end
return true, S("Available commands:@n") .. table.concat(list, "\n")
else
local def = worldedit.registered_commands[param]
if not def then
return false, S("Command not available: ") .. param
else
return true, format_help_line(param, def, true)
end
end end
end, end,
}) })
@ -285,7 +311,7 @@ worldedit.register_command("reset", {
worldedit.set_pos[name] = nil worldedit.set_pos[name] = nil
--make sure the user does not try to confirm an operation after resetting pos: --make sure the user does not try to confirm an operation after resetting pos:
reset_pending(name) reset_pending(name)
worldedit.player_notify(name, S("region reset")) return true, S("region reset")
end, end,
}) })

View File

@ -16,9 +16,9 @@ worldedit.register_command("deleteblocks", {
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local success = minetest.delete_area(pos1, pos2) local success = minetest.delete_area(pos1, pos2)
if success then if success then
worldedit.player_notify(name, S("Area deleted.")) return true, S("Area deleted.")
else else
worldedit.player_notify(name, S("There was an error during deletion of the area.")) return false, S("There was an error during deletion of the area.")
end end
end, end,
}) })
@ -32,7 +32,7 @@ worldedit.register_command("clearobjects", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name) func = function(name)
local count = worldedit.clear_objects(worldedit.pos1[name], worldedit.pos2[name]) local count = worldedit.clear_objects(worldedit.pos1[name], worldedit.pos2[name])
worldedit.player_notify(name, S("@1 objects cleared", count)) return true, S("@1 objects cleared", count)
end, end,
}) })
@ -52,7 +52,7 @@ worldedit.register_command("set", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name, node) func = function(name, node)
local count = worldedit.set(worldedit.pos1[name], worldedit.pos2[name], node) local count = worldedit.set(worldedit.pos1[name], worldedit.pos2[name], node)
worldedit.player_notify(name, S("@1 nodes set", count)) return true, S("@1 nodes set", count)
end, end,
}) })
@ -74,7 +74,7 @@ worldedit.register_command("param2", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name, param2) func = function(name, param2)
local count = worldedit.set_param2(worldedit.pos1[name], worldedit.pos2[name], param2) local count = worldedit.set_param2(worldedit.pos1[name], worldedit.pos2[name], param2)
worldedit.player_notify(name, S("@1 nodes altered", count)) return true, S("@1 nodes altered", count)
end, end,
}) })
@ -109,7 +109,7 @@ worldedit.register_command("mix", {
func = function(name, nodes) func = function(name, nodes)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local count = worldedit.set(pos1, pos2, nodes) local count = worldedit.set(pos1, pos2, nodes)
worldedit.player_notify(name, S("@1 nodes set", count)) return true, S("@1 nodes set", count)
end, end,
}) })
@ -140,7 +140,7 @@ worldedit.register_command("replace", {
func = function(name, search_node, replace_node) func = function(name, search_node, replace_node)
local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name], local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name],
search_node, replace_node) search_node, replace_node)
worldedit.player_notify(name, S("@1 nodes replaced", count)) return true, S("@1 nodes replaced", count)
end, end,
}) })
@ -155,7 +155,7 @@ worldedit.register_command("replaceinverse", {
func = function(name, search_node, replace_node) func = function(name, search_node, replace_node)
local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name], local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name],
search_node, replace_node, true) search_node, replace_node, true)
worldedit.player_notify(name, S("@1 nodes replaced", count)) return true, S("@1 nodes replaced", count)
end, end,
}) })
@ -168,7 +168,7 @@ worldedit.register_command("fixlight", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name) func = function(name)
local count = worldedit.fixlight(worldedit.pos1[name], worldedit.pos2[name]) local count = worldedit.fixlight(worldedit.pos1[name], worldedit.pos2[name])
worldedit.player_notify(name, S("@1 nodes updated", count)) return true, S("@1 nodes updated", count)
end, end,
}) })
@ -198,7 +198,7 @@ worldedit.register_command("drain", {
end end
end end
end end
worldedit.player_notify(name, S("@1 nodes updated", count)) return true, S("@1 nodes updated", count)
end, end,
}) })
@ -281,7 +281,7 @@ worldedit.register_command("clearcut", {
func = function(name) func = function(name)
local pos1, pos2 = worldedit.sort_pos(worldedit.pos1[name], worldedit.pos2[name]) local pos1, pos2 = worldedit.sort_pos(worldedit.pos1[name], worldedit.pos2[name])
local count = clearcut(pos1, pos2) local count = clearcut(pos1, pos2)
worldedit.player_notify(name, S("@1 nodes removed", count)) return true, S("@1 nodes removed", count)
end, end,
}) })
@ -294,7 +294,7 @@ worldedit.register_command("hide", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name) func = function(name)
local count = worldedit.hide(worldedit.pos1[name], worldedit.pos2[name]) local count = worldedit.hide(worldedit.pos1[name], worldedit.pos2[name])
worldedit.player_notify(name, S("@1 nodes hidden", count)) return true, S("@1 nodes hidden", count)
end, end,
}) })
@ -314,7 +314,7 @@ worldedit.register_command("suppress", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name, node) func = function(name, node)
local count = worldedit.suppress(worldedit.pos1[name], worldedit.pos2[name], node) local count = worldedit.suppress(worldedit.pos1[name], worldedit.pos2[name], node)
worldedit.player_notify(name, S("@1 nodes suppressed", count)) return true, S("@1 nodes suppressed", count)
end, end,
}) })
@ -334,7 +334,7 @@ worldedit.register_command("highlight", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name, node) func = function(name, node)
local count = worldedit.highlight(worldedit.pos1[name], worldedit.pos2[name], node) local count = worldedit.highlight(worldedit.pos1[name], worldedit.pos2[name], node)
worldedit.player_notify(name, S("@1 nodes highlighted", count)) return true, S("@1 nodes highlighted", count)
end, end,
}) })
@ -347,6 +347,6 @@ worldedit.register_command("restore", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name) func = function(name)
local count = worldedit.restore(worldedit.pos1[name], worldedit.pos2[name]) local count = worldedit.restore(worldedit.pos1[name], worldedit.pos2[name])
worldedit.player_notify(name, S("@1 nodes restored", count)) return true, S("@1 nodes restored", count)
end, end,
}) })

View File

@ -25,7 +25,7 @@ worldedit.register_command("hollowcube", {
end, end,
func = function(name, w, h, l, node) func = function(name, w, h, l, node)
local count = worldedit.cube(worldedit.pos1[name], w, h, l, node, true) local count = worldedit.cube(worldedit.pos1[name], w, h, l, node, true)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -41,7 +41,7 @@ worldedit.register_command("cube", {
end, end,
func = function(name, w, h, l, node) func = function(name, w, h, l, node)
local count = worldedit.cube(worldedit.pos1[name], w, h, l, node) local count = worldedit.cube(worldedit.pos1[name], w, h, l, node)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -69,7 +69,7 @@ worldedit.register_command("hollowsphere", {
end, end,
func = function(name, radius, node) func = function(name, radius, node)
local count = worldedit.sphere(worldedit.pos1[name], radius, node, true) local count = worldedit.sphere(worldedit.pos1[name], radius, node, true)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -85,7 +85,7 @@ worldedit.register_command("sphere", {
end, end,
func = function(name, radius, node) func = function(name, radius, node)
local count = worldedit.sphere(worldedit.pos1[name], radius, node) local count = worldedit.sphere(worldedit.pos1[name], radius, node)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -113,7 +113,7 @@ worldedit.register_command("hollowdome", {
end, end,
func = function(name, radius, node) func = function(name, radius, node)
local count = worldedit.dome(worldedit.pos1[name], radius, node, true) local count = worldedit.dome(worldedit.pos1[name], radius, node, true)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -129,7 +129,7 @@ worldedit.register_command("dome", {
end, end,
func = function(name, radius, node) func = function(name, radius, node)
local count = worldedit.dome(worldedit.pos1[name], radius, node) local count = worldedit.dome(worldedit.pos1[name], radius, node)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -169,7 +169,7 @@ worldedit.register_command("hollowcylinder", {
length = length * sign length = length * sign
end end
local count = worldedit.cylinder(worldedit.pos1[name], axis, length, radius1, radius2, node, true) local count = worldedit.cylinder(worldedit.pos1[name], axis, length, radius1, radius2, node, true)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -191,7 +191,7 @@ worldedit.register_command("cylinder", {
length = length * sign length = length * sign
end end
local count = worldedit.cylinder(worldedit.pos1[name], axis, length, radius1, radius2, node) local count = worldedit.cylinder(worldedit.pos1[name], axis, length, radius1, radius2, node)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -224,7 +224,7 @@ worldedit.register_command("hollowpyramid", {
height = height * sign height = height * sign
end end
local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node, true) local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node, true)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -245,7 +245,7 @@ worldedit.register_command("pyramid", {
height = height * sign height = height * sign
end end
local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node) local count = worldedit.pyramid(worldedit.pos1[name], axis, height, node)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })
@ -271,6 +271,6 @@ worldedit.register_command("spiral", {
end, end,
func = function(name, length, height, space, node) func = function(name, length, height, space, node)
local count = worldedit.spiral(worldedit.pos1[name], length, height, space, node) local count = worldedit.spiral(worldedit.pos1[name], length, height, space, node)
worldedit.player_notify(name, S("@1 nodes added", count)) return true, S("@1 nodes added", count)
end, end,
}) })

View File

@ -24,10 +24,10 @@ worldedit.register_command("inspect", {
"inspector: inspection enabled for @1, currently facing the @2 axis", "inspector: inspection enabled for @1, currently facing the @2 axis",
name, name,
axis .. (sign > 0 and "+" or "-") axis .. (sign > 0 and "+" or "-")
)) ), "info")
else else
worldedit.inspect[name] = nil worldedit.inspect[name] = nil
worldedit.player_notify(name, S("inspector: inspection disabled")) worldedit.player_notify(name, S("inspector: inspection disabled"), "info")
end end
end, end,
}) })
@ -61,7 +61,7 @@ minetest.register_on_punchnode(function(pos, node, puncher)
get_node_rlight(pos), get_node_rlight(pos),
axis .. (sign > 0 and "+" or "-") axis .. (sign > 0 and "+" or "-")
) )
worldedit.player_notify(name, message) worldedit.player_notify(name, message, "info")
end end
end) end)
@ -73,7 +73,7 @@ worldedit.register_command("mark", {
privs = {worldedit=true}, privs = {worldedit=true},
func = function(name) func = function(name)
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.player_notify(name, S("region marked")) return true, S("region marked")
end, end,
}) })
@ -89,10 +89,24 @@ worldedit.register_command("unmark", {
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.pos1[name] = pos1 worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2 worldedit.pos2[name] = pos2
worldedit.player_notify(name, S("region unmarked")) return true, S("region unmarked")
end, end,
}) })
local function set_pos1(name, pos)
assert(pos)
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.player_notify(name, S("position @1 set to @2", 1, minetest.pos_to_string(pos)), "ok")
end
local function set_pos2(name, pos)
assert(pos)
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.player_notify(name, S("position @1 set to @2", 2, minetest.pos_to_string(pos)), "ok")
end
worldedit.register_command("pos1", { worldedit.register_command("pos1", {
params = "", params = "",
description = S("Set WorldEdit region position @1 to the player's location", 1), description = S("Set WorldEdit region position @1 to the player's location", 1),
@ -101,9 +115,7 @@ worldedit.register_command("pos1", {
func = function(name) func = function(name)
local pos = minetest.get_player_by_name(name):get_pos() local pos = minetest.get_player_by_name(name):get_pos()
pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5) pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)
worldedit.pos1[name] = pos set_pos1(name, pos)
worldedit.mark_pos1(name)
worldedit.player_notify(name, S("position @1 set to @2", 1, minetest.pos_to_string(pos)))
end, end,
}) })
@ -115,9 +127,7 @@ worldedit.register_command("pos2", {
func = function(name) func = function(name)
local pos = minetest.get_player_by_name(name):get_pos() local pos = minetest.get_player_by_name(name):get_pos()
pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5) pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)
worldedit.pos2[name] = pos set_pos2(name, pos)
worldedit.mark_pos2(name)
worldedit.player_notify(name, S("position @1 set to @2", 2, minetest.pos_to_string(pos)))
end, end,
}) })
@ -133,27 +143,32 @@ worldedit.register_command("p", {
return false, S("unknown subcommand: @1", param) return false, S("unknown subcommand: @1", param)
end, end,
func = function(name, param) func = function(name, param)
local msg
if param == "set" then --set both WorldEdit positions if param == "set" then --set both WorldEdit positions
worldedit.set_pos[name] = "pos1" worldedit.set_pos[name] = "pos1"
worldedit.player_notify(name, S("select positions by punching two nodes")) msg = S("select positions by punching two nodes")
elseif param == "set1" then --set WorldEdit position 1 elseif param == "set1" then --set WorldEdit position 1
worldedit.set_pos[name] = "pos1only" worldedit.set_pos[name] = "pos1only"
worldedit.player_notify(name, S("select position @1 by punching a node", 1)) msg = S("select position @1 by punching a node", 1)
elseif param == "set2" then --set WorldEdit position 2 elseif param == "set2" then --set WorldEdit position 2
worldedit.set_pos[name] = "pos2" worldedit.set_pos[name] = "pos2"
worldedit.player_notify(name, S("select position @1 by punching a node", 2)) msg = S("select position @1 by punching a node", 2)
elseif param == "get" then --display current WorldEdit positions elseif param == "get" then --display current WorldEdit positions
if worldedit.pos1[name] ~= nil then if worldedit.pos1[name] ~= nil then
worldedit.player_notify(name, S("position @1: @2", 1, minetest.pos_to_string(worldedit.pos1[name]))) msg = S("position @1: @2", 1, minetest.pos_to_string(worldedit.pos1[name]))
else else
worldedit.player_notify(name, S("position @1 not set", 1)) msg = S("position @1 not set", 1)
end end
msg = msg .. "\n"
if worldedit.pos2[name] ~= nil then if worldedit.pos2[name] ~= nil then
worldedit.player_notify(name, S("position @1: @2", 2, minetest.pos_to_string(worldedit.pos2[name]))) msg = msg .. S("position @1: @2", 2, minetest.pos_to_string(worldedit.pos2[name]))
else else
worldedit.player_notify(name, S("position @1 not set", 2)) msg = msg .. S("position @1 not set", 2)
end end
end end
if msg then
worldedit.player_notify(name, msg, "info")
end
end, end,
}) })
@ -171,13 +186,9 @@ worldedit.register_command("fixedpos", {
end, end,
func = function(name, flag, pos) func = function(name, flag, pos)
if flag == "set1" then if flag == "set1" then
worldedit.pos1[name] = pos set_pos1(name, pos)
worldedit.mark_pos1(name)
worldedit.player_notify(name, S("position @1 set to @2", 1, minetest.pos_to_string(pos)))
else --flag == "set2" else --flag == "set2"
worldedit.pos2[name] = pos set_pos2(name, pos)
worldedit.mark_pos2(name)
worldedit.player_notify(name, S("position @1 set to @2", 2, minetest.pos_to_string(pos)))
end end
end, end,
}) })
@ -186,20 +197,14 @@ minetest.register_on_punchnode(function(pos, node, puncher)
local name = puncher:get_player_name() local name = puncher:get_player_name()
if name ~= "" and worldedit.set_pos[name] ~= nil then --currently setting position if name ~= "" and worldedit.set_pos[name] ~= nil then --currently setting position
if worldedit.set_pos[name] == "pos1" then --setting position 1 if worldedit.set_pos[name] == "pos1" then --setting position 1
worldedit.pos1[name] = pos set_pos1(name, pos)
worldedit.mark_pos1(name)
worldedit.set_pos[name] = "pos2" --set position 2 on the next invocation worldedit.set_pos[name] = "pos2" --set position 2 on the next invocation
worldedit.player_notify(name, S("position @1 set to @2", 1, minetest.pos_to_string(pos)))
elseif worldedit.set_pos[name] == "pos1only" then --setting position 1 only elseif worldedit.set_pos[name] == "pos1only" then --setting position 1 only
worldedit.pos1[name] = pos set_pos1(name, pos)
worldedit.mark_pos1(name)
worldedit.set_pos[name] = nil --finished setting positions worldedit.set_pos[name] = nil --finished setting positions
worldedit.player_notify(name, S("position @1 set to @2", 1, minetest.pos_to_string(pos)))
elseif worldedit.set_pos[name] == "pos2" then --setting position 2 elseif worldedit.set_pos[name] == "pos2" then --setting position 2
worldedit.pos2[name] = pos set_pos2(name, pos)
worldedit.mark_pos2(name)
worldedit.set_pos[name] = nil --finished setting positions worldedit.set_pos[name] = nil --finished setting positions
worldedit.player_notify(name, S("position @1 set to @2", 2, minetest.pos_to_string(pos)))
elseif worldedit.set_pos[name] == "prob" then --setting Minetest schematic node probabilities elseif worldedit.set_pos[name] == "prob" then --setting Minetest schematic node probabilities
worldedit.prob_pos[name] = pos worldedit.prob_pos[name] = pos
minetest.show_formspec(name, "prob_val_enter", "field[text;;]") minetest.show_formspec(name, "prob_val_enter", "field[text;;]")
@ -224,6 +229,6 @@ worldedit.register_command("volume", {
abs(pos2.x - pos1.x) + 1, abs(pos2.x - pos1.x) + 1,
abs(pos2.y - pos1.y) + 1, abs(pos2.y - pos1.y) + 1,
abs(pos2.z - pos1.z) + 1 abs(pos2.z - pos1.z) + 1
)) ), "info")
end, end,
}) })

View File

@ -12,7 +12,7 @@ local function safe_region(name, count, callback)
--save callback to call later --save callback to call later
safe_region_callback[name] = callback safe_region_callback[name] = callback
worldedit.player_notify(name, S("WARNING: this operation could affect up to @1 nodes; type @2 to continue or @3 to cancel", worldedit.player_notify(name, S("WARNING: this operation could affect up to @1 nodes; type @2 to continue or @3 to cancel",
count, minetest.colorize("#00ffff", "//y"), minetest.colorize("#00ffff", "//n"))) count, minetest.colorize("#00ffff", "//y"), minetest.colorize("#00ffff", "//n")), "info")
end end
local function reset_pending(name) local function reset_pending(name)
@ -25,7 +25,7 @@ minetest.register_chatcommand("/y", {
func = function(name) func = function(name)
local callback = safe_region_callback[name] local callback = safe_region_callback[name]
if not callback then if not callback then
worldedit.player_notify(name, S("no operation pending")) worldedit.player_notify(name, S("no operation pending"), "error")
return return
end end
@ -39,7 +39,7 @@ minetest.register_chatcommand("/n", {
description = S("Abort a pending operation"), description = S("Abort a pending operation"),
func = function(name) func = function(name)
if not safe_region_callback[name] then if not safe_region_callback[name] then
worldedit.player_notify(name, S("no operation pending")) worldedit.player_notify(name, S("no operation pending"), "error")
return return
end end

View File

@ -26,7 +26,7 @@ local function open_schematic(name, param)
end end
end end
if err then if err then
worldedit.player_notify(name, S("Could not open file \"@1\"", param)) worldedit.player_notify(name, S("Could not open file \"@1\"", param), "error")
return return
end end
local value = file:read("*a") local value = file:read("*a")
@ -34,10 +34,10 @@ local function open_schematic(name, param)
local version = worldedit.read_header(value) local version = worldedit.read_header(value)
if version == nil or version == 0 then if version == nil or version == 0 then
worldedit.player_notify(name, S("Invalid file format!")) worldedit.player_notify(name, S("Invalid file format!"), "error")
return return
elseif version > worldedit.LATEST_SERIALIZATION_VERSION then elseif version > worldedit.LATEST_SERIALIZATION_VERSION then
worldedit.player_notify(name, S("Schematic was created with a newer version of WorldEdit.")) worldedit.player_notify(name, S("Schematic was created with a newer version of WorldEdit."), "error")
return return
end end
@ -90,14 +90,13 @@ worldedit.register_command("save", {
local filename = path .. "/" .. param .. ".we" local filename = path .. "/" .. param .. ".we"
local file, err = io.open(filename, "wb") local file, err = io.open(filename, "wb")
if err ~= nil then if err ~= nil then
worldedit.player_notify(name, S("Could not save file to \"@1\"", filename)) return false, S("Could not save file to \"@1\"", filename)
return
end end
file:write(result) file:write(result)
file:flush() file:flush()
file:close() file:close()
worldedit.player_notify(name, S("@1 nodes saved", count)) return true, S("@1 nodes saved", count)
end, end,
}) })
@ -126,15 +125,14 @@ worldedit.register_command("allocate", {
local nodepos1, nodepos2, count = worldedit.allocate(pos, value) local nodepos1, nodepos2, count = worldedit.allocate(pos, value)
if not nodepos1 then if not nodepos1 then
worldedit.player_notify(name, S("Schematic empty, nothing allocated")) return false, S("Schematic empty, nothing allocated")
return false
end end
worldedit.pos1[name] = nodepos1 worldedit.pos1[name] = nodepos1
worldedit.pos2[name] = nodepos2 worldedit.pos2[name] = nodepos2
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.player_notify(name, S("@1 nodes allocated", count)) return true, S("@1 nodes allocated", count)
end, end,
}) })
@ -163,10 +161,9 @@ worldedit.register_command("load", {
local count = worldedit.deserialize(pos, value) local count = worldedit.deserialize(pos, value)
if count == nil then if count == nil then
worldedit.player_notify(name, S("Loading failed!")) return false, S("Loading failed!")
return false
end end
worldedit.player_notify(name, S("@1 nodes loaded", count)) return true, S("@1 nodes loaded", count)
end, end,
}) })
@ -197,12 +194,11 @@ worldedit.register_command("mtschemcreate", {
local ret = minetest.create_schematic(worldedit.pos1[name], local ret = minetest.create_schematic(worldedit.pos1[name],
worldedit.pos2[name], worldedit.prob_list[name], worldedit.pos2[name], worldedit.prob_list[name],
filename) filename)
if ret == nil then
worldedit.player_notify(name, S("Failed to create Minetest schematic"))
else
worldedit.player_notify(name, S("Saved Minetest schematic to @1", param))
end
worldedit.prob_list[name] = {} worldedit.prob_list[name] = {}
if ret == nil then
return false, S("Failed to create Minetest schematic")
end
return true, S("Saved Minetest schematic to @1", param)
end, end,
}) })
@ -226,10 +222,10 @@ worldedit.register_command("mtschemplace", {
local path = minetest.get_worldpath() .. "/schems/" .. param .. ".mts" local path = minetest.get_worldpath() .. "/schems/" .. param .. ".mts"
if minetest.place_schematic(pos, path) == nil then if minetest.place_schematic(pos, path) == nil then
worldedit.player_notify(name, S("failed to place Minetest schematic")) return false, S("failed to place Minetest schematic")
else
worldedit.player_notify(name, S("placed Minetest schematic @1 at @2", param, minetest.pos_to_string(pos)))
end end
return true, S("placed Minetest schematic @1 at @2",
param, minetest.pos_to_string(pos))
end, end,
}) })
@ -248,10 +244,10 @@ worldedit.register_command("mtschemprob", {
if param == "start" then --start probability setting if param == "start" then --start probability setting
worldedit.set_pos[name] = "prob" worldedit.set_pos[name] = "prob"
worldedit.prob_list[name] = {} worldedit.prob_list[name] = {}
worldedit.player_notify(name, S("select Minetest schematic probability values by punching nodes")) worldedit.player_notify(name, S("select Minetest schematic probability values by punching nodes"), "info")
elseif param == "finish" then --finish probability setting elseif param == "finish" then --finish probability setting
worldedit.set_pos[name] = nil worldedit.set_pos[name] = nil
worldedit.player_notify(name, S("finished Minetest schematic probability selection")) worldedit.player_notify(name, S("finished Minetest schematic probability selection"), "info")
elseif param == "get" then --get all nodes that had probabilities set on them elseif param == "get" then --get all nodes that had probabilities set on them
local text = "" local text = ""
local problist = worldedit.prob_list[name] local problist = worldedit.prob_list[name]
@ -262,8 +258,7 @@ worldedit.register_command("mtschemprob", {
local prob = math.floor(((v.prob / 256) * 100) * 100 + 0.5) / 100 local prob = math.floor(((v.prob / 256) * 100) * 100 + 0.5) / 100
text = text .. minetest.pos_to_string(v.pos) .. ": " .. prob .. "% | " text = text .. minetest.pos_to_string(v.pos) .. ": " .. prob .. "% | "
end end
worldedit.player_notify(name, S("currently set node probabilities:")) worldedit.player_notify(name, S("currently set node probabilities:") .. "\n" .. text, "info")
worldedit.player_notify(name, text)
end end
end, end,
}) })
@ -277,7 +272,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
local e = {pos=worldedit.prob_pos[name], prob=tonumber(fields.text)} local e = {pos=worldedit.prob_pos[name], prob=tonumber(fields.text)}
if e.pos == nil or e.prob == nil or e.prob < 0 or e.prob > 256 then if e.pos == nil or e.prob == nil or e.prob < 0 or e.prob > 256 then
worldedit.player_notify(name, S("invalid node probability given, not saved")) worldedit.player_notify(name, S("invalid node probability given, not saved"), "error")
return return
end end
problist[#problist+1] = e problist[#problist+1] = e

View File

@ -29,7 +29,7 @@ worldedit.register_command("copy", {
end end
local count = worldedit.copy(worldedit.pos1[name], worldedit.pos2[name], axis, amount) local count = worldedit.copy(worldedit.pos1[name], worldedit.pos2[name], axis, amount)
worldedit.player_notify(name, S("@1 nodes copied", count)) return true, S("@1 nodes copied", count)
end, end,
}) })
@ -62,7 +62,7 @@ worldedit.register_command("move", {
pos1[axis] = pos1[axis] + amount pos1[axis] = pos1[axis] + amount
pos2[axis] = pos2[axis] + amount pos2[axis] = pos2[axis] + amount
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.player_notify(name, S("@1 nodes moved", count)) return true, S("@1 nodes moved", count)
end, end,
}) })
@ -92,7 +92,7 @@ worldedit.register_command("stack", {
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local count = worldedit.volume(pos1, pos2) * math.abs(repetitions) local count = worldedit.volume(pos1, pos2) * math.abs(repetitions)
worldedit.stack(pos1, pos2, axis, repetitions, function() worldedit.stack(pos1, pos2, axis, repetitions, function()
worldedit.player_notify(name, S("@1 nodes stacked", count)) worldedit.player_notify(name, S("@1 nodes stacked", count), "ok")
end) end)
end, end,
}) })
@ -122,7 +122,7 @@ worldedit.register_command("stack2", {
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
local count = worldedit.volume(pos1, pos2) * repetitions local count = worldedit.volume(pos1, pos2) * repetitions
worldedit.stack2(pos1, pos2, offset, repetitions, function() worldedit.stack2(pos1, pos2, offset, repetitions, function()
worldedit.player_notify(name, S("@1 nodes stacked", count)) worldedit.player_notify(name, S("@1 nodes stacked", count), "ok")
end) end)
end, end,
}) })
@ -156,7 +156,7 @@ worldedit.register_command("stretch", {
worldedit.pos2[name] = pos2 worldedit.pos2[name] = pos2
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.player_notify(name, S("@1 nodes stretched", count)) return true, S("@1 nodes stretched", count)
end, end,
}) })
@ -187,7 +187,7 @@ worldedit.register_command("transpose", {
worldedit.pos2[name] = pos2 worldedit.pos2[name] = pos2
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.player_notify(name, S("@1 nodes transposed", count)) return true, S("@1 nodes transposed", count)
end, end,
}) })
@ -207,7 +207,7 @@ worldedit.register_command("flip", {
func = function(name, param) func = function(name, param)
if param == "?" then param = worldedit.player_axis(name) end if param == "?" then param = worldedit.player_axis(name) end
local count = worldedit.flip(worldedit.pos1[name], worldedit.pos2[name], param) local count = worldedit.flip(worldedit.pos1[name], worldedit.pos2[name], param)
worldedit.player_notify(name, S("@1 nodes flipped", count)) return true, S("@1 nodes flipped", count)
end, end,
}) })
@ -239,7 +239,7 @@ worldedit.register_command("rotate", {
worldedit.pos2[name] = pos2 worldedit.pos2[name] = pos2
worldedit.marker_update(name) worldedit.marker_update(name)
worldedit.player_notify(name, S("@1 nodes rotated", count)) return true, S("@1 nodes rotated", count)
end, end,
}) })
@ -263,7 +263,7 @@ worldedit.register_command("orient", {
nodes_needed = check_region, nodes_needed = check_region,
func = function(name, angle) func = function(name, angle)
local count = worldedit.orient(worldedit.pos1[name], worldedit.pos2[name], angle) local count = worldedit.orient(worldedit.pos1[name], worldedit.pos2[name], angle)
worldedit.player_notify(name, S("@1 nodes oriented", count)) return true, S("@1 nodes oriented", count)
end, end,
}) })

View File

@ -140,7 +140,7 @@ local function execute_worldedit_command(command_name, player_name, params)
assert(chatcmd, "unknown command: " .. command_name) assert(chatcmd, "unknown command: " .. command_name)
local _, msg = chatcmd.func(player_name, params) local _, msg = chatcmd.func(player_name, params)
if msg then if msg then
worldedit.player_notify(player_name, msg) minetest.chat_send_player(player_name, msg)
end end
end end

View File

@ -264,7 +264,7 @@ worldedit.register_gui_handler("worldedit_gui", function(name, fields)
--ensure player has permission to perform action --ensure player has permission to perform action
local has_privs, missing_privs = minetest.check_player_privs(name, entry.privs) local has_privs, missing_privs = minetest.check_player_privs(name, entry.privs)
if not has_privs then if not has_privs then
worldedit.player_notify(name, "you are not allowed to use this function (missing privileges: " .. table.concat(missing_privs, ", ") .. ")") worldedit.player_notify(name, "you are not allowed to use this function (missing privileges: " .. table.concat(missing_privs, ", ") .. ")", "error")
return false return false
end end
if entry.on_select then if entry.on_select then