From 0d0fb9a49a99051588f1221ba57ec0a70271933d Mon Sep 17 00:00:00 2001 From: Och Noe Date: Wed, 26 Aug 2020 17:33:10 +0200 Subject: wp_use, tw_use - use the top of the stack but don't remove it --- init.lua | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 5f4d90b..433dd57 100644 --- a/init.lua +++ b/init.lua @@ -4,11 +4,13 @@ local mod_name = minetest.get_current_modname() +local mod_version = "2.5" + local function log(level, message) minetest.log(level, ('[%s] %s'):format(mod_name, message)) end -log('action', 'CSM cs_waypoints loading...') +log('action', 'CSM cs_waypoints '..mod_version..' loading...') minetest.display_chat_message("CSM cs_waypoints loading...") @@ -142,6 +144,18 @@ local function stack_pop() return true end +local function stack_use() + wp_stack = load_waypoints_stack() + count = 0 + if nil ~= wp_stack then count = #wp_stack end + if count<1 then + minetest.display_chat_message('stack empty - no teleporting') + return + end + minetest.run_server_chatcommand('teleport', tostring_point(wp_stack[count])) + return true +end + local function stack_show() wp_stack = load_waypoints_stack() count = 0 @@ -379,6 +393,20 @@ minetest.register_chatcommand('wp_pop', { } ) +minetest.register_chatcommand('tw_use', { + params = '', + description = "use the last saved position but don't remove it", + func = stack_use, + } + ) + +minetest.register_chatcommand('wp_use', { + params = '', + description = "use the last saved position but don't remove it", + func = stack_use, + } + ) + minetest.register_chatcommand('wp_stack', { params = '', description = 'shows the stack content', -- cgit v1.2.3