From 647bef69ef48a8d7eee81eeb61f9d4c1e377b4c7 Mon Sep 17 00:00:00 2001 From: Och Noe Date: Wed, 26 Aug 2020 17:53:38 +0200 Subject: .wp/.tw_exch added - exchange top two entries --- init.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 433dd57..6ced16f 100644 --- a/init.lua +++ b/init.lua @@ -12,7 +12,7 @@ end log('action', 'CSM cs_waypoints '..mod_version..' loading...') -minetest.display_chat_message("CSM cs_waypoints loading...") +minetest.display_chat_message("CSM cs_waypoints '..mod_version..' loading...") local mod_storage = minetest.get_mod_storage() @@ -156,6 +156,22 @@ local function stack_use() return true end +local function stack_exch() + wp_stack = load_waypoints_stack() + count = 0 + if nil ~= wp_stack then count = #wp_stack end + if count<2 then + minetest.display_chat_message('less than 2 entries - no change') + return + end + local exch = wp_stack[count] + wp_stack[count] = wp_stack[count-1] + wp_stack[count-1] = exch + mod_storage:set_string('waypoints_stack', minetest.serialize(wp_stack)) + return true +end + + local function stack_show() wp_stack = load_waypoints_stack() count = 0 @@ -407,6 +423,19 @@ minetest.register_chatcommand('wp_use', { } ) +minetest.register_chatcommand('tw_exch', { + params = '', + description = 'exchange the top two stack entried', + func = stack_exch, + } + ) + +minetest.register_chatcommand('wp_exch', { + params = '', + description = 'exchange the top two stack entried', + func = stack_exch, + } + ) minetest.register_chatcommand('wp_stack', { params = '', description = 'shows the stack content', -- cgit v1.2.3