1 local minetest,os = minetest,os
2 local mod_storage = minetest.get_mod_storage()
4 local home_timeout = 60
6 --this does not terminate data because player's can spam
7 --leave and come back in to reset the home timout
10 minetest.register_chatcommand("sethome", {
12 description = "Use this to set your home. Can be returned to by setting /home",
13 privs = {home = true},
15 local time = minetest.get_us_time()/1000000
16 local player = minetest.get_player_by_name(name)
17 local pos = player:get_pos()
18 if not pool[name] or pool[name] and time-pool[name] > home_timeout then
19 mod_storage:set_string(name.."home", minetest.serialize(pos))
21 minetest.chat_send_player(name, "Home set.")
22 elseif pool[name] then
23 local diff = home_timeout-math.ceil(time-pool[name])+1
28 minetest.chat_send_player(name, diff.." more second"..s.." until you can run that command.")
34 minetest.register_chatcommand("home", {
36 description = "Use this to set your home. Can be returned to by setting /home",
37 privs = {home = true},
39 local time = minetest.get_us_time()/1000000
40 local player = minetest.get_player_by_name(name)
42 if not pool[name] or pool[name] and time-pool[name] > home_timeout then
44 local newpos = minetest.deserialize(mod_storage:get_string(name.."home"))
47 player:add_player_velocity(vector.multiply(player:get_player_velocity(),-1))
48 player:move_to(newpos)
51 minetest.chat_send_player(name, "No home set.")
53 elseif pool[name] then
54 local diff = home_timeout-math.ceil(time-pool[name])+1
59 minetest.chat_send_player(name, diff.." more second"..s.." until you can run that command.")
64 minetest.register_privilege("home", {
65 description = "Player can use /home and /sethome.",
66 give_to_singleplayer = false,