parent
b3a48ed647
commit
e735475a10
70
init.lua
70
init.lua
|
@ -4,7 +4,7 @@
|
|||
|
||||
local mod_name = minetest.get_current_modname()
|
||||
|
||||
local mod_version = "2.8"
|
||||
local mod_version = "2.11"
|
||||
|
||||
local function log(level, message)
|
||||
minetest.log(level, ('[%s] %s'):format(mod_name, message))
|
||||
|
@ -20,6 +20,7 @@ local mod_storage = minetest.get_mod_storage()
|
|||
local search_delta_default = 10
|
||||
|
||||
local daydelay_default = 5
|
||||
local bouncedelay_default = 10
|
||||
|
||||
--
|
||||
--
|
||||
|
@ -320,7 +321,7 @@ end
|
|||
|
||||
local function teleport_day_back(x,y,z)
|
||||
minetest.run_server_chatcommand('teleport',
|
||||
string.format("%d %d %d",x,y+1,z)
|
||||
string.format("%f %f %f",x,y+1,z)
|
||||
)
|
||||
return
|
||||
end
|
||||
|
@ -377,6 +378,54 @@ local function teleport_day(params)
|
|||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local function teleport_bounce(params)
|
||||
|
||||
if not params or
|
||||
params == ""
|
||||
|
||||
then
|
||||
-- no parameter - return
|
||||
minetest.display_chat_message("no waypoint given")
|
||||
return
|
||||
end
|
||||
|
||||
local bouncedelay = mod_storage:get_string('bouncedelay')
|
||||
bouncedelay = (bouncedelay and tonumber(minetest.deserialize(bouncedelay))) or
|
||||
bouncedelay_default
|
||||
|
||||
local sdp = string.find(params,"setdelay",1,false)
|
||||
if sdp and sdp == 1 then
|
||||
local newtime = tonumber(params:sub(10,16))
|
||||
|
||||
if newtime and newtime>0 then
|
||||
mod_storage:set_string('bouncedelay', minetest.serialize(newtime))
|
||||
minetest.display_chat_message("delay saved")
|
||||
else
|
||||
minetest.display_chat_message("delay: "..bouncedelay)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local bouncepos = params
|
||||
local bouncetarget = waypoints[bouncepos]
|
||||
if not bouncetarget then
|
||||
minetest.display_chat_message("unknown waypoint")
|
||||
return
|
||||
end
|
||||
|
||||
local pstr = tostring_point(bouncetarget)
|
||||
local point = minetest.localplayer:get_pos()
|
||||
minetest.after(bouncedelay,teleport_day_back,point.x,point.y,point.z)
|
||||
minetest.display_chat_message("position "..pstr)
|
||||
minetest.run_server_chatcommand('teleport', pstr)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
-- chat commands
|
||||
|
@ -614,3 +663,20 @@ minetest.register_chatcommand('day', {
|
|||
func = teleport_day,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
-- bounce name idea by Maverick2797 on 2021-05-20
|
||||
-- jump to a waypoint and 'bounce' back to the start point after a delay
|
||||
minetest.register_chatcommand('bounce', {
|
||||
params = '[<waypoint>|setdelay [<number>]]',
|
||||
description = 'teleports to the given waypoint and returns after a few seconds ',
|
||||
func = teleport_bounce,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
log('action', 'CSM cs_waypoints '..mod_version..' loaded')
|
||||
minetest.display_chat_message("CSM cs_waypoints "..mod_version.." loaded")
|
||||
|
||||
|
|
Loading…
Reference in New Issue