Sethome for beds. Fix bug please
If player which don't slept in a bed yet type anything in public chat he see this message "You haven't slept in a bed yet." but he must see this message only if he type /home. Please fix this because author don't respond.
And if you want add message for /sethome "You must slept in a bad for this". This mod work with colored bed mod instead default sethome mod on my server.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_on_chat_message(function(name, message, playername, player)
local player_spawns = {}
local file = io.open(minetest.get_worldpath().."/beds_player_spawns", "r")
if file then
player_spawns = minetest.deserialize(file:read("*all"))
file:close()
end
local cmd = "/home"
local player = minetest.get_player_by_name(name)
if (player_spawns[name]) then
if message:sub(0, #cmd) == cmd then
if message == '/home' then
minetest.chat_send_player(player:get_player_name(), "Teleporting to bed...")
player:setpos(player_spawns[name])
return true
end
end
else
minetest.chat_send_player(player:get_player_name(), "You haven't slept in a bed yet.")
return true
end
end)
And if you want add message for /sethome "You must slept in a bad for this". This mod work with colored bed mod instead default sethome mod on my server.