aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOch Noe <och_noe@forksworld.de>2020-06-19 19:18:27 +0200
committerOch Noe <och_noe@forksworld.de>2020-06-19 19:18:27 +0200
commit955ca53ef9a72be7e7f11df3c61a82339864fc4e (patch)
tree10b18875a13d1bfd624a4b66106aff813edf8248
parent873306c06679853d21f4a9668f3e9e3013bea9a7 (diff)
downloadcs_waypoints-955ca53ef9a72be7e7f11df3c61a82339864fc4e.tar.gz
cs_waypoints-955ca53ef9a72be7e7f11df3c61a82339864fc4e.tar.bz2
cs_waypoints-955ca53ef9a72be7e7f11df3c61a82339864fc4e.zip
new command: .wp_grep (written by erstazi, THANKS)
-rw-r--r--README.md2
-rw-r--r--init.lua23
2 files changed, 25 insertions, 0 deletions
diff --git a/README.md b/README.md
index ad3b0b5..ee7e1a1 100644
--- a/README.md
+++ b/README.md
@@ -43,3 +43,5 @@ usage
* .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
+
+* .wp_grep NAME: search for NAME in the waypoint names
diff --git a/init.lua b/init.lua
index 436b210..c400bf8 100644
--- a/init.lua
+++ b/init.lua
@@ -324,3 +324,26 @@ minetest.register_chatcommand('wp_shift', {
)
+
+-- wp_grep written by erstazi (player at Linux-Forks.de )
+minetest.register_chatcommand('wp_grep', {
+ params = '<name>',
+ description = 'lists 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) 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),
+})
+