Add //fixedpos command and document it.

This commit is contained in:
Anthony Zhang
2013-07-28 17:07:47 -04:00
parent faa4a7b065
commit 7e1be63344
2 changed files with 31 additions and 0 deletions

View File

@ -173,6 +173,29 @@ minetest.register_chatcommand("/p", {
end,
})
minetest.register_chatcommand("/fixedpos", {
params = "set1/set2 x y z",
description = "Set a WorldEdit region position to the position at (<x>, <y>, <z>)",
privs = {worldedit=true},
func = function(name, param)
local found, _, flag, x, y, z = param:find("^(set[12])%s+([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)$")
if found == nil then
worldedit.player_notify(name, "invalid usage: " .. param)
return
end
local pos = {x=x, y=y, z=z}
if flag == "set1" then
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
else --flag == "set2"
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end
end,
})
minetest.register_on_punchnode(function(pos, node, puncher)
local name = puncher:get_player_name()
if name ~= "" and worldedit.set_pos[name] ~= nil then --currently setting position