From 42d33d92a7365c58f944bd42100ab775dc1e872a Mon Sep 17 00:00:00 2001 From: Och Noe Date: Tue, 18 May 2021 19:51:46 +0200 Subject: wp_fgrep added --- init.lua | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 787ce45..51f1021 100644 --- a/init.lua +++ b/init.lua @@ -235,7 +235,7 @@ local function position_shift(p) if distance == 0 then return end here[d] = here[d] + distance - here.y = here.y - 1 -- correction + -- here.y = here.y - 1 -- correction minetest.run_server_chatcommand('teleport', tostring_point(here)) @@ -281,7 +281,7 @@ local function position_shift2(p) here.y = here.y+shift.y here.z = here.z+shift.z - here.y = here.y - 1 -- correction + -- here.y = here.y - 1 -- correction minetest.run_server_chatcommand('teleport', tostring_point(here)) @@ -503,7 +503,7 @@ minetest.register_chatcommand('tp', { -- wp_grep written by erstazi (player at Linux-Forks.de ) minetest.register_chatcommand('wp_grep', { params = '', - description = 'lists waypoints', + description = 'lists matching waypoints', func = safe(function(param) local wpname = param local count = 0 @@ -522,3 +522,28 @@ minetest.register_chatcommand('wp_grep', { end), }) + +minetest.register_chatcommand('wp_fgrep', { + params = '', + description = 'lists matching waypoints', + func = safe(function(param) + local wpname = param + local count = 0 + for name, point in pairsByKeys(waypoints, lc_cmp) do + if string.find(name, wpname,1,true) then + count = count + 1 + minetest.display_chat_message( + ('%s -> %s'):format(name, tostring_point(point)) + ) + end + end + + if count == 0 then + minetest.display_chat_message(('waypoint "%s" not found.'):format(wpname)) + end + end), +}) + + + + -- cgit v1.2.3