nasty bug removed, .day works now
parent
33647ef72d
commit
7f7493738f
20
init.lua
20
init.lua
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
local mod_name = minetest.get_current_modname()
|
local mod_name = minetest.get_current_modname()
|
||||||
|
|
||||||
local mod_version = "2.6"
|
local mod_version = "2.7"
|
||||||
|
|
||||||
local function log(level, message)
|
local function log(level, message)
|
||||||
minetest.log(level, ('[%s] %s'):format(mod_name, message))
|
minetest.log(level, ('[%s] %s'):format(mod_name, message))
|
||||||
|
@ -93,7 +93,10 @@ end
|
||||||
|
|
||||||
|
|
||||||
local function tostring_point(point)
|
local function tostring_point(point)
|
||||||
return ('%i %i.5 %i'):format(round(point.x), round(point.y), round(point.z))
|
if not point then
|
||||||
|
return " - - - "
|
||||||
|
end
|
||||||
|
return ('%i %i %i'):format(round(point.x), round(point.y), round(point.z))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,19 +329,22 @@ end
|
||||||
local function teleport_day(params)
|
local function teleport_day(params)
|
||||||
local daypos = mod_storage:get_string('daypos')
|
local daypos = mod_storage:get_string('daypos')
|
||||||
local daydelay = mod_storage:get_string('daydelay')
|
local daydelay = mod_storage:get_string('daydelay')
|
||||||
daypos = minetest.deserialize(daypos) or ""
|
daypos = minetest.deserialize(daypos)
|
||||||
daydelay = (daydelay and tonumber(minetest.deserialize(daydelay))) or
|
daydelay = (daydelay and tonumber(minetest.deserialize(daydelay))) or
|
||||||
daydelay_default
|
daydelay_default
|
||||||
|
|
||||||
if not params or
|
if not params or
|
||||||
params == ""
|
params == ""
|
||||||
|
|
||||||
then
|
then
|
||||||
-- no parameter - execute the function
|
-- no parameter - execute the function
|
||||||
if daypos == "" then
|
if not daypos then
|
||||||
minetest.display_chat_message("no saved position")
|
minetest.display_chat_message("no saved position")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.run_server_chatcommand('teleport', tostring_point(daypos))
|
local pstr = tostring_point(daypos)
|
||||||
|
minetest.display_chat_message("position "..pstr)
|
||||||
|
minetest.run_server_chatcommand('teleport', pstr)
|
||||||
local point = minetest.localplayer:get_pos()
|
local point = minetest.localplayer:get_pos()
|
||||||
minetest.after(daydelay,teleport_day_back,point.x,point.y,point.z)
|
minetest.after(daydelay,teleport_day_back,point.x,point.y,point.z)
|
||||||
return
|
return
|
||||||
|
@ -351,7 +357,9 @@ local function teleport_day(params)
|
||||||
end
|
end
|
||||||
if params == "setpos" then
|
if params == "setpos" then
|
||||||
local point = minetest.localplayer:get_pos()
|
local point = minetest.localplayer:get_pos()
|
||||||
mod_storage:set_string('daypos', minetest.serialize(tostring_point(point)))
|
local pstr = tostring_point(point)
|
||||||
|
minetest.display_chat_message("position "..pstr)
|
||||||
|
mod_storage:set_string('daypos', minetest.serialize(point))
|
||||||
minetest.display_chat_message("position saved")
|
minetest.display_chat_message("position saved")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue