nasty bug removed, .day works now

master
Och Noe 2021-05-20 04:11:44 +02:00
parent 33647ef72d
commit 7f7493738f
1 changed files with 14 additions and 6 deletions

View File

@ -4,7 +4,7 @@
local mod_name = minetest.get_current_modname()
local mod_version = "2.6"
local mod_version = "2.7"
local function log(level, message)
minetest.log(level, ('[%s] %s'):format(mod_name, message))
@ -93,7 +93,10 @@ end
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
@ -326,19 +329,22 @@ end
local function teleport_day(params)
local daypos = mod_storage:get_string('daypos')
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_default
if not params or
params == ""
then
-- no parameter - execute the function
if daypos == "" then
if not daypos then
minetest.display_chat_message("no saved position")
return
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()
minetest.after(daydelay,teleport_day_back,point.x,point.y,point.z)
return
@ -351,7 +357,9 @@ local function teleport_day(params)
end
if params == "setpos" then
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")
return
end