From 7e1be63344d022ff9f7150049596af093c3bb7cb Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sun, 28 Jul 2013 17:07:47 -0400 Subject: [PATCH] Add //fixedpos command and document it. --- Chat Commands.md | 8 ++++++++ worldedit_commands/init.lua | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Chat Commands.md b/Chat Commands.md index e44f242..f661b8d 100644 --- a/Chat Commands.md +++ b/Chat Commands.md @@ -56,6 +56,14 @@ Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching //p set2 //p get +### //fixedpos set1 x y z + +Set a WorldEdit region position to the position at (, , ). + + //fixedpos set1 0, 0, 0 + //fixedpos set1 -30, 5, 28 + //fixedpos set2 1004, -200, 432 + ### //volume Display the volume of the current WorldEdit region. diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 4e23122..40f8ffc 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -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 (, , )", + 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