aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOch Noe <och_noe@forksworld.de>2020-06-18 00:55:33 +0200
committerOch Noe <och_noe@forksworld.de>2020-06-18 00:55:33 +0200
commit873306c06679853d21f4a9668f3e9e3013bea9a7 (patch)
treed241d253199c80e9366f80b250231b9b148e3389
parenta47859c5e1f4ae5d5cf248770573e4e8539372fe (diff)
downloadcs_waypoints-873306c06679853d21f4a9668f3e9e3013bea9a7.tar.gz
cs_waypoints-873306c06679853d21f4a9668f3e9e3013bea9a7.tar.bz2
cs_waypoints-873306c06679853d21f4a9668f3e9e3013bea9a7.zip
new command: .wp_shift
-rw-r--r--README.md2
-rw-r--r--init.lua37
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 = '<axis> <distance>',
+ description = '"shift" the player along the given axis and add the given number',
+ func = position_shift,
+ }
+ )
+