Make chat messages consistent.

This commit is contained in:
Anthony Zhang 2013-05-15 17:52:12 -04:00
parent d52f3d649e
commit 52c1379bce

View File

@ -7,6 +7,10 @@ worldedit.pos2 = {}
dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua")
worldedit.player_notify = function(name, message)
minetest.chat_send_player(name, "WorldEdit -!- " .. message, false)
end
--determines whether `nodename` is a valid node name, returning a boolean
worldedit.node_is_valid = function(nodename)
return minetest.registered_nodes[nodename] ~= nil
@ -37,7 +41,7 @@ minetest.register_chatcommand("/reset", {
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.set_pos[name] = nil
minetest.chat_send_player(name, "WorldEdit region reset", false)
worldedit.player_notify(name, "region reset")
end,
})
@ -48,7 +52,7 @@ minetest.register_chatcommand("/mark", {
func = function(name, param)
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
minetest.chat_send_player(name, "WorldEdit region marked", false)
worldedit.player_notify(name, "region marked")
end,
})
@ -64,7 +68,7 @@ minetest.register_chatcommand("/unmark", {
worldedit.mark_pos2(name)
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
minetest.chat_send_player(name, "WorldEdit region unmarked", false)
worldedit.player_notify(name, "region unmarked")
end,
})
@ -77,7 +81,7 @@ minetest.register_chatcommand("/pos1", {
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
worldedit.mark_pos1(name)
minetest.chat_send_player(name, "WorldEdit position 1 set to " .. minetest.pos_to_string(pos), false)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
end,
})
@ -90,7 +94,7 @@ minetest.register_chatcommand("/pos2", {
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
worldedit.mark_pos2(name)
minetest.chat_send_player(name, "WorldEdit position 2 set to " .. minetest.pos_to_string(pos), false)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end,
})
@ -101,26 +105,26 @@ minetest.register_chatcommand("/p", {
func = function(name, param)
if param == "set" then --set both WorldEdit positions
worldedit.set_pos[name] = "pos1"
minetest.chat_send_player(name, "Select positions by punching two nodes", false)
worldedit.player_notify(name, "select positions by punching two nodes")
elseif param == "set1" then --set WorldEdit position 1
worldedit.set_pos[name] = "pos1only"
minetest.chat_send_player(name, "Select position 1 by punching a node", false)
worldedit.player_notify(name, "select position 1 by punching a node")
elseif param == "set2" then --set WorldEdit position 2
worldedit.set_pos[name] = "pos2"
minetest.chat_send_player(name, "Select position 2 by punching a node", false)
worldedit.player_notify(name, "select position 2 by punching a node")
elseif param == "get" then --display current WorldEdit positions
if worldedit.pos1[name] ~= nil then
minetest.chat_send_player(name, "WorldEdit position 1: " .. minetest.pos_to_string(worldedit.pos1[name]), false)
worldedit.player_notify(name, "position 1: " .. minetest.pos_to_string(worldedit.pos1[name]))
else
minetest.chat_send_player(name, "WorldEdit position 1 not set", false)
worldedit.player_notify(name, "position 1 not set")
end
if worldedit.pos2[name] ~= nil then
minetest.chat_send_player(name, "WorldEdit position 2: " .. minetest.pos_to_string(worldedit.pos2[name]), false)
worldedit.player_notify(name, "position 2: " .. minetest.pos_to_string(worldedit.pos2[name]))
else
minetest.chat_send_player(name, "WorldEdit position 2 not set", false)
worldedit.player_notify(name, "position 2 not set")
end
else
minetest.chat_send_player(name, "Unknown subcommand: " .. param, false)
worldedit.player_notify(name, "unknown subcommand: " .. param)
end
end,
})
@ -132,17 +136,17 @@ minetest.register_on_punchnode(function(pos, node, puncher)
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.set_pos[name] = "pos2" --set position 2 on the next invocation
minetest.chat_send_player(name, "WorldEdit position 1 set to " .. minetest.pos_to_string(pos), false)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
elseif worldedit.set_pos[name] == "pos1only" then --setting position 1 only
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.set_pos[name] = nil --finished setting positions
minetest.chat_send_player(name, "WorldEdit position 1 set to " .. minetest.pos_to_string(pos), false)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
elseif worldedit.set_pos[name] == "pos2" then --setting position 2
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.set_pos[name] = nil --finished setting positions
minetest.chat_send_player(name, "WorldEdit position 2 set to " .. minetest.pos_to_string(pos), false)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end
end
end)
@ -154,12 +158,12 @@ minetest.register_chatcommand("/volume", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local volume = worldedit.volume(pos1, pos2)
minetest.chat_send_player(name, "Current WorldEdit region has a volume of " .. volume .. " nodes (" .. pos2.x - pos1.x .. "*" .. pos2.y - pos1.y .. "*" .. pos2.z - pos1.z .. ")", false)
worldedit.player_notify(name, "current region has a volume of " .. volume .. " nodes (" .. pos2.x - pos1.x .. "*" .. pos2.y - pos1.y .. "*" .. pos2.z - pos1.z .. ")")
end,
})
@ -170,12 +174,12 @@ minetest.register_chatcommand("/set", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
if param == "" or not worldedit.node_is_valid(param) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -183,8 +187,9 @@ minetest.register_chatcommand("/set", {
if worldedit.ENABLE_QUEUE then
tenv = worldedit.quene_aliasenv
end
local count = worldedit.set(pos1, pos2, param, tenv)
minetest.chat_send_player(name, count .. " nodes set", false)
local count = worldedit.set(pos1, pos2, param, tenv)
worldedit.player_notify(name, count .. " nodes set")
end,
})
@ -195,21 +200,21 @@ minetest.register_chatcommand("/replace", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(searchnode) then
minetest.chat_send_player(name, "Invalid search node name: " .. searchnode, false)
worldedit.player_notify(name, "invalid search node name: " .. searchnode)
return
end
if not worldedit.node_is_valid(replacenode) then
minetest.chat_send_player(name, "Invalid replace node name: " .. replacenode, false)
worldedit.player_notify(name, "invalid replace node name: " .. replacenode)
return
end
@ -218,7 +223,7 @@ minetest.register_chatcommand("/replace", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.replace(pos1, pos2, searchnode, replacenode, tenv)
minetest.chat_send_player(name, count .. " nodes replaced", false)
worldedit.player_notify(name, count .. " nodes replaced")
end,
})
@ -229,21 +234,21 @@ minetest.register_chatcommand("/replaceinverse", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(searchnode) then
minetest.chat_send_player(name, "Invalid search node name: " .. searchnode, false)
worldedit.player_notify(name, "invalid search node name: " .. searchnode)
return
end
if not worldedit.node_is_valid(replacenode) then
minetest.chat_send_player(name, "Invalid replace node name: " .. replacenode, false)
worldedit.player_notify(name, "invalid replace node name: " .. replacenode)
return
end
@ -252,7 +257,7 @@ minetest.register_chatcommand("/replaceinverse", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode, tenv)
minetest.chat_send_player(name, count .. " nodes replaced", false)
worldedit.player_notify(name, count .. " nodes replaced")
end,
})
@ -263,17 +268,17 @@ minetest.register_chatcommand("/hollowsphere", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -282,7 +287,7 @@ minetest.register_chatcommand("/hollowsphere", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.hollow_sphere(pos, tonumber(radius), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -293,17 +298,17 @@ minetest.register_chatcommand("/sphere", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -312,7 +317,7 @@ minetest.register_chatcommand("/sphere", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.sphere(pos, tonumber(radius), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -323,17 +328,17 @@ minetest.register_chatcommand("/hollowdome", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -342,7 +347,7 @@ minetest.register_chatcommand("/hollowdome", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.hollow_dome(pos, tonumber(radius), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -353,17 +358,17 @@ minetest.register_chatcommand("/dome", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, radius, nodename = param:find("^(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -372,7 +377,7 @@ minetest.register_chatcommand("/dome", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.dome(pos, tonumber(radius), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -383,13 +388,13 @@ minetest.register_chatcommand("/hollowcylinder", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis == "?" then
@ -397,7 +402,7 @@ minetest.register_chatcommand("/hollowcylinder", {
length = length * sign
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -406,7 +411,7 @@ minetest.register_chatcommand("/hollowcylinder", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.hollow_cylinder(pos, axis, tonumber(length), tonumber(radius), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -417,13 +422,13 @@ minetest.register_chatcommand("/cylinder", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis == "?" then
@ -431,7 +436,7 @@ minetest.register_chatcommand("/cylinder", {
length = length * sign
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -440,7 +445,7 @@ minetest.register_chatcommand("/cylinder", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -451,17 +456,17 @@ minetest.register_chatcommand("/pyramid", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, size, nodename = param:find("(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -470,7 +475,7 @@ minetest.register_chatcommand("/pyramid", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.pyramid(pos, tonumber(size), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes added", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -481,17 +486,17 @@ minetest.register_chatcommand("/spiral", {
func = function(name, param)
local pos = worldedit.pos1[name]
if pos == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, width, height, space, nodename = param:find("(%d+)%s+(%d+)%s+(%d+)%s+([^%s]+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if not worldedit.node_is_valid(nodename) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -500,7 +505,7 @@ minetest.register_chatcommand("/spiral", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.spiral(pos, tonumber(width), tonumber(height), tonumber(space), nodename, tenv)
minetest.chat_send_player(name, count .. " nodes changed", false)
worldedit.player_notify(name, count .. " nodes added")
end,
})
@ -511,13 +516,13 @@ minetest.register_chatcommand("/copy", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis == "?" then
@ -530,7 +535,7 @@ minetest.register_chatcommand("/copy", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.copy(pos1, pos2, axis, tonumber(amount), tenv)
minetest.chat_send_player(name, count .. " nodes copied", false)
worldedit.player_notify(name, count .. " nodes copied")
end,
})
@ -541,13 +546,13 @@ minetest.register_chatcommand("/move", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis == "?" then
@ -567,7 +572,7 @@ minetest.register_chatcommand("/move", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.copy(pos1, pos2, axis, tonumber(amount), tenv)
minetest.chat_send_player(name, count .. " nodes moved", false)
worldedit.player_notify(name, count .. " nodes moved")
end,
})
@ -578,13 +583,13 @@ minetest.register_chatcommand("/stack", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis, count = param:find("^([xyz%?])%s+([+-]?%d+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis == "?" then
@ -597,7 +602,7 @@ minetest.register_chatcommand("/stack", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.stack(pos1, pos2, axis, tonumber(count), tenv)
minetest.chat_send_player(name, count .. " nodes stacked", false)
worldedit.player_notify(name, count .. " nodes stacked")
end,
})
@ -608,13 +613,13 @@ minetest.register_chatcommand("/transpose", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis1, axis2 = param:find("^([xyz%?])%s+([xyz%?])$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis1 == "?" then
@ -624,7 +629,7 @@ minetest.register_chatcommand("/transpose", {
axis2 = worldedit.player_axis(name)
end
if axis1 == axis2 then
minetest.chat_send_player(name, "Invalid usage: axes are the same", false)
worldedit.player_notify(name, "invalid usage: axes must be different")
return
end
@ -640,7 +645,7 @@ minetest.register_chatcommand("/transpose", {
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
minetest.chat_send_player(name, count .. " nodes transposed", false)
worldedit.player_notify(name, count .. " nodes transposed")
end,
})
@ -651,7 +656,7 @@ minetest.register_chatcommand("/flip", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
@ -659,7 +664,7 @@ minetest.register_chatcommand("/flip", {
param = worldedit.player_axis(name)
end
if param ~= "x" and param ~= "y" and param ~= "z" then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
@ -668,7 +673,7 @@ minetest.register_chatcommand("/flip", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.flip(pos1, pos2, param, tenv)
minetest.chat_send_player(name, count .. " nodes flipped", false)
worldedit.player_notify(name, count .. " nodes flipped")
end,
})
@ -679,20 +684,20 @@ minetest.register_chatcommand("/rotate", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, axis, angle = param:find("^([xyz%?])%s+([+-]?%d+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if axis == "?" then
axis = worldedit.player_axis(name)
end
if angle % 90 ~= 0 then
minetest.chat_send_player(name, "Invalid usage: angle must be multiple of 90", false)
worldedit.player_notify(name, "invalid usage: angle must be multiple of 90")
return
end
@ -708,7 +713,7 @@ minetest.register_chatcommand("/rotate", {
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
minetest.chat_send_player(name, count .. " nodes rotated", false)
worldedit.player_notify(name, count .. " nodes rotated")
end,
})
@ -719,17 +724,17 @@ minetest.register_chatcommand("/orient", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local found, _, angle = param:find("^([+-]?%d+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
if angle % 90 ~= 0 then
minetest.chat_send_player(name, "Invalid usage: angle must be multiple of 90", false)
worldedit.player_notify(name, "invalid usage: angle must be multiple of 90")
return
end
@ -739,7 +744,7 @@ minetest.register_chatcommand("/orient", {
end
local count = worldedit.orient(pos1, pos2, angle, tenv)
minetest.chat_send_player(name, count .. " nodes oriented", false)
worldedit.player_notify(name, count .. " nodes oriented")
end,
})
@ -750,7 +755,7 @@ minetest.register_chatcommand("/fixlight", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
@ -759,7 +764,7 @@ minetest.register_chatcommand("/fixlight", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.fixlight(pos1, pos2, tenv)
minetest.chat_send_player(name, count .. " nodes updated", false)
worldedit.player_notify(name, count .. " nodes updated")
end,
})
@ -770,7 +775,7 @@ minetest.register_chatcommand("/hide", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
@ -779,7 +784,7 @@ minetest.register_chatcommand("/hide", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.hide(pos1, pos2, tenv)
minetest.chat_send_player(name, count .. " nodes hidden", false)
worldedit.player_notify(name, count .. " nodes hidden")
end,
})
@ -790,12 +795,12 @@ minetest.register_chatcommand("/suppress", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
if param == "" or not worldedit.node_is_valid(param) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -804,7 +809,7 @@ minetest.register_chatcommand("/suppress", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.suppress(pos1, pos2, param, tenv)
minetest.chat_send_player(name, count .. " nodes suppressed", false)
worldedit.player_notify(name, count .. " nodes suppressed")
end,
})
@ -815,12 +820,12 @@ minetest.register_chatcommand("/highlight", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
if param == "" or not worldedit.node_is_valid(param) then
minetest.chat_send_player(name, "Invalid node name: " .. param, false)
worldedit.player_notify(name, "invalid node name: " .. param)
return
end
@ -829,7 +834,7 @@ minetest.register_chatcommand("/highlight", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.highlight(pos1, pos2, param, tenv)
minetest.chat_send_player(name, count .. " nodes highlighted", false)
worldedit.player_notify(name, count .. " nodes highlighted")
end,
})
@ -840,7 +845,7 @@ minetest.register_chatcommand("/restore", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
@ -849,7 +854,7 @@ minetest.register_chatcommand("/restore", {
tenv = worldedit.quene_aliasenv
end
local count = worldedit.restore(pos1, pos2, tenv)
minetest.chat_send_player(name, count .. " nodes restored", false)
worldedit.player_notify(name, count .. " nodes restored")
end,
})
@ -860,12 +865,12 @@ minetest.register_chatcommand("/save", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
if param == "" then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
@ -876,14 +881,14 @@ minetest.register_chatcommand("/save", {
os.execute("mkdir \"" .. path .. "\"") --create directory if it does not already exist
local file, err = io.open(filename, "wb")
if err ~= nil then
minetest.chat_send_player(name, "Could not save file to \"" .. filename .. "\"", false)
worldedit.player_notify(name, "could not save file to \"" .. filename .. "\"")
return
end
file:write(result)
file:flush()
file:close()
minetest.chat_send_player(name, count .. " nodes saved", false)
worldedit.player_notify(name, count .. " nodes saved")
end,
})
@ -894,26 +899,26 @@ minetest.register_chatcommand("/allocate", {
func = function(name, param)
local pos1 = worldedit.pos1[name]
if pos1 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
if param == "" then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
local filename = minetest.get_worldpath() .. "/schems/" .. param .. ".we"
local file, err = io.open(filename, "rb")
if err ~= nil then
minetest.chat_send_player(name, "Could not open file \"" .. filename .. "\"", false)
worldedit.player_notify(name, "could not open file \"" .. filename .. "\"")
return
end
local value = file:read("*a")
file:close()
if worldedit.valueversion(value) == 0 then --unknown version
minetest.chat_send_player(name, "Invalid file: file is invalid or created with newer version of WorldEdit", false)
worldedit.player_notify(name, "invalid file: file is invalid or created with newer version of WorldEdit")
return
end
local nodepos1, nodepos2, count = worldedit.allocate(pos1, value)
@ -923,7 +928,7 @@ minetest.register_chatcommand("/allocate", {
worldedit.pos2[name] = nodepos2
worldedit.mark_pos2(name)
minetest.chat_send_player(name, count .. " nodes allocated", false)
worldedit.player_notify(name, count .. " nodes allocated")
end,
})
@ -934,12 +939,12 @@ minetest.register_chatcommand("/load", {
func = function(name, param)
local pos1 = worldedit.pos1[name]
if pos1 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
if param == "" then
minetest.chat_send_player(name, "Invalid usage: " .. param, false)
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
@ -957,14 +962,14 @@ minetest.register_chatcommand("/load", {
end
end
if err then
minetest.chat_send_player(name, "Could not open file \"" .. param .. "\"", false)
worldedit.player_notify(name, "could not open file \"" .. param .. "\"")
return
end
local value = file:read("*a")
file:close()
if worldedit.valueversion(value) == 0 then --unknown version
minetest.chat_send_player(name, "Invalid file: file is invalid or created with newer version of WorldEdit", false)
worldedit.player_notify(name, "invalid file: file is invalid or created with newer version of WorldEdit")
return
end
@ -974,7 +979,7 @@ minetest.register_chatcommand("/load", {
end
local count = worldedit.deserialize(pos1, value, tenv)
minetest.chat_send_player(name, count .. " nodes loaded", false)
worldedit.player_notify(name, count .. " nodes loaded")
end,
})
@ -985,9 +990,9 @@ minetest.register_chatcommand("/lua", {
func = function(name, param)
local err = worldedit.lua(param)
if err then
minetest.chat_send_player(name, "Code error: " .. err, false)
worldedit.player_notify(name, "code error: " .. err)
else
minetest.chat_send_player(name, "Code successfully executed", false)
worldedit.player_notify(name, "code successfully executed", false)
end
end,
})
@ -999,15 +1004,15 @@ minetest.register_chatcommand("/luatransform", {
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
minetest.chat_send_player(name, "No WorldEdit region selected", false)
worldedit.player_notify(name, "no region selected")
return
end
local err = worldedit.luatransform(pos1, pos2, param)
if err then
minetest.chat_send_player(name, "Code error: " .. err, false)
worldedit.player_notify(name, "code error: " .. err, false)
else
minetest.chat_send_player(name, "Code successfully executed", false)
worldedit.player_notify(name, "code successfully executed", false)
end
end,
})