From 873306c06679853d21f4a9668f3e9e3013bea9a7 Mon Sep 17 00:00:00 2001 From: Och Noe Date: Thu, 18 Jun 2020 00:55:33 +0200 Subject: new command: .wp_shift --- README.md | 2 +- init.lua | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 67f4050..ad3b0b5 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,4 @@ usage * .wp_search DELTA: searches for saved waypoints near te current location with the given delta for all coordinates * .wp_search: searches for saved waypoints near te current location with DELTA=10 - +* .wp_shift AXIS DISTANCE: moves you on the given axis the given distance diff --git a/init.lua b/init.lua index 443475c..436b210 100644 --- a/init.lua +++ b/init.lua @@ -170,6 +170,33 @@ local function stack_search(d) return true end +local function position_shift(p) + local param = p + if not p then return end + while p:sub(1,1) == " " and p:len()> 3 do + p = p:sub(2,99) + end + if p:len()<3 then return end + direction = p:sub(1,1) + d = "" + if direction == "x" or direction == "X" then d = "x" end + if direction == "y" or direction == "Y" then d = "y" end + if direction == "z" or direction == "Z" then d = "z" end + if d == "" then return end + + here = minetest.localplayer:get_pos() + + distance = tonumber(p:sub(2,8)) + if not distance then return end + if distance == 0 then return end + + here[d] = here[d] + distance + here.y = here.y - 1 -- correction + + minetest.run_server_chatcommand('teleport', tostring_point(here)) + +end + -- -- @@ -252,8 +279,6 @@ minetest.register_chatcommand('wp_push', { } ) - - minetest.register_chatcommand('tw_pop', { params = '', description = 'return to the last saved position', @@ -291,5 +316,11 @@ minetest.register_chatcommand('wp_search', { ) - +minetest.register_chatcommand('wp_shift', { + params = ' ', + description = '"shift" the player along the given axis and add the given number', + func = position_shift, + } + ) + -- cgit v1.2.3