diff options
author | Och Noe <och_noe@forksworld.de> | 2021-05-20 04:11:44 +0200 |
---|---|---|
committer | Och Noe <och_noe@forksworld.de> | 2021-05-20 04:11:44 +0200 |
commit | 7f7493738fc43f91e88a77c3cf0374f4b5b50a48 (patch) | |
tree | 75b3ebfa3482ba80103d62debd9a4f5781e9928a | |
parent | 33647ef72dba244388263189c510a26e79a01399 (diff) | |
download | cs_waypoints-7f7493738fc43f91e88a77c3cf0374f4b5b50a48.tar.gz cs_waypoints-7f7493738fc43f91e88a77c3cf0374f4b5b50a48.tar.bz2 cs_waypoints-7f7493738fc43f91e88a77c3cf0374f4b5b50a48.zip |
nasty bug removed, .day works now
-rw-r--r-- | init.lua | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -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 |