diff options
author | Och Noe <och_noe@forksworld.de> | 2020-06-18 00:55:33 +0200 |
---|---|---|
committer | Och Noe <och_noe@forksworld.de> | 2020-06-18 00:55:33 +0200 |
commit | 873306c06679853d21f4a9668f3e9e3013bea9a7 (patch) | |
tree | d241d253199c80e9366f80b250231b9b148e3389 | |
parent | a47859c5e1f4ae5d5cf248770573e4e8539372fe (diff) | |
download | cs_waypoints-873306c06679853d21f4a9668f3e9e3013bea9a7.tar.gz cs_waypoints-873306c06679853d21f4a9668f3e9e3013bea9a7.tar.bz2 cs_waypoints-873306c06679853d21f4a9668f3e9e3013bea9a7.zip |
new command: .wp_shift
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | init.lua | 37 |
2 files changed, 35 insertions, 4 deletions
@@ -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 @@ -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, + } + ) + |