aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOch Noe <och_noe@forksworld.de>2020-08-26 17:53:38 +0200
committerOch Noe <och_noe@forksworld.de>2020-08-26 17:53:38 +0200
commit647bef69ef48a8d7eee81eeb61f9d4c1e377b4c7 (patch)
tree8daf554af03800c40e11747a4196a236b936f7a3
parent0d0fb9a49a99051588f1221ba57ec0a70271933d (diff)
downloadcs_waypoints-647bef69ef48a8d7eee81eeb61f9d4c1e377b4c7.tar.gz
cs_waypoints-647bef69ef48a8d7eee81eeb61f9d4c1e377b4c7.tar.bz2
cs_waypoints-647bef69ef48a8d7eee81eeb61f9d4c1e377b4c7.zip
.wp/.tw_exch added - exchange top two entries
-rw-r--r--init.lua31
1 files changed, 30 insertions, 1 deletions
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',