'wp_export' added

master
Och Noe 2021-07-20 20:30:14 +02:00
parent e735475a10
commit 01e27c7757
1 changed files with 35 additions and 9 deletions

View File

@ -4,7 +4,7 @@
local mod_name = minetest.get_current_modname()
local mod_version = "2.11"
local mod_version = "2.13"
local function log(level, message)
minetest.log(level, ('[%s] %s'):format(mod_name, message))
@ -151,7 +151,7 @@ local function stack_pop()
end
local function stack_use()
wp_stack = load_waypoints_stack()
local wp_stack = load_waypoints_stack()
count = 0
if nil ~= wp_stack then count = #wp_stack end
if count<1 then
@ -163,7 +163,7 @@ local function stack_use()
end
local function stack_exch()
wp_stack = load_waypoints_stack()
local wp_stack = load_waypoints_stack()
count = 0
if nil ~= wp_stack then count = #wp_stack end
if count<2 then
@ -179,7 +179,7 @@ end
local function stack_show()
wp_stack = load_waypoints_stack()
local wp_stack = load_waypoints_stack()
count = 0
if nil ~= wp_stack then count = #wp_stack end
if count<1 then
@ -252,17 +252,17 @@ end
local function position_shift2(p)
if not p then return end
param = p:split(" ")
local param = p:split(" ")
shift = {}
local shift = {}
shift.x = 0
shift.y = 0
shift.z = 0
vp = 1
local vp = 1
while (vp+1 <= #param )
do
direction = param[vp]
local direction = param[vp]
d = ""
if direction == "x" or direction == "X" then d = "x" end
if direction == "y" or direction == "Y" then d = "y" end
@ -281,7 +281,7 @@ local function position_shift2(p)
return
end
here = minetest.localplayer:get_pos()
local here = minetest.localplayer:get_pos()
here.x = here.x+shift.x
here.y = here.y+shift.y
@ -425,6 +425,26 @@ local function teleport_bounce(params)
end
local function wp_export(param)
local wpl = load_waypoints()
if not wpl then return end
local list = ""
for k,p in pairsByKeys(wpl,lc_cmp) do
if param == "" or string.find(k,param,1,true) then
local line = "("..p.x..","..p.y..","..p.y..") name = "..k.."\n"
list = list .. line
end
end
minetest.display_chat_message(list)
minetest.show_formspec("cs_waypoints:export",
"size[15,12]" ..
"label[3.5,0;Waypoint List]"..
"textarea[0.3,1;15,11;note;;".. list .."]"..
"button_exit[4.5,11.2;1.4,1;e;Close]")
return
end
--
--
@ -674,6 +694,12 @@ minetest.register_chatcommand('bounce', {
}
)
minetest.register_chatcommand('wp_export', {
params = '[<name part>]',
description = 'Export all waypoints as list',
func = wp_export,
}
)