forked from MineClone5/MineClone5
Explicit msgs when respawn pos changed due to bed
This commit is contained in:
parent
ec53db9352
commit
079b09c80f
|
@ -37,7 +37,7 @@ local beduse = "To use a bed, stand close to it and right-click the bed to sleep
|
|||
if minetest.settings:get_bool("enable_bed_respawn") == false then
|
||||
beddesc = beddesc .. "\n" .. "In local folklore, legends are told of other worlds where setting the start point for your next life would be possible. But this world is not one of them."
|
||||
else
|
||||
beddesc = beddesc .. "\n" .. "By sleeping in a bed, you set the starting point for your next life. If you die, you will start your next life at this bed, unless it is obstructed or destroyed."
|
||||
beddesc = beddesc .. "\n" .. "By using a bed, you set the starting point for your next life. If you die, you will start your next life at this bed, unless it is obstructed or destroyed."
|
||||
end
|
||||
if minetest.settings:get_bool("enable_bed_night_skip") == false then
|
||||
beddesc = beddesc .. "\n" .. "In this strange world, going to bed won't skip the night, but you can skip thunderstorms."
|
||||
|
|
|
@ -143,19 +143,27 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||
return false
|
||||
end
|
||||
|
||||
local spawn_changed = false
|
||||
if minetest.get_modpath("mcl_spawn") then
|
||||
local spos = table.copy(bed_pos)
|
||||
spos.y = spos.y + 0.1
|
||||
mcl_spawn.set_spawn_pos(player, spos) -- save respawn position when entering bed
|
||||
spawn_changed = mcl_spawn.set_spawn_pos(player, spos) -- save respawn position when entering bed
|
||||
end
|
||||
|
||||
-- Check day of time and weather
|
||||
local tod = minetest.get_timeofday() * 24000
|
||||
-- Values taken from Minecraft Wiki with offset of +6000
|
||||
if tod < 18541 and tod > 5458 and (not weather_mod or (mcl_weather.get_weather() ~= "thunder")) then
|
||||
minetest.chat_send_player(name, "You can only sleep at night or during a thunderstorm.")
|
||||
if spawn_changed then
|
||||
minetest.chat_send_player(name, "New respawn position set! But you can only sleep at night or during a thunderstorm.")
|
||||
else
|
||||
minetest.chat_send_player(name, "You can only sleep at night or during a thunderstorm.")
|
||||
end
|
||||
return false
|
||||
end
|
||||
if spawn_changed then
|
||||
minetest.chat_send_player(name, "New respawn position set!")
|
||||
end
|
||||
|
||||
mcl_beds.player[name] = 1
|
||||
mcl_beds.pos[name] = pos
|
||||
|
|
|
@ -32,12 +32,32 @@ end
|
|||
|
||||
-- Sets the player's spawn position to pos.
|
||||
-- Set pos to nil to clear the spawn position.
|
||||
mcl_spawn.set_spawn_pos = function(player, pos, type)
|
||||
-- If message is set, informs the player with a chat message when the spawn position
|
||||
-- changed.
|
||||
mcl_spawn.set_spawn_pos = function(player, pos, message)
|
||||
local spawn_changed = false
|
||||
if pos == nil then
|
||||
if player:get_attribute("mcl_beds:spawn") ~= "" then
|
||||
spawn_changed = true
|
||||
if message then
|
||||
minetest.chat_send_player(player:get_player_name(), "Respawn position cleared!")
|
||||
end
|
||||
end
|
||||
player:set_attribute("mcl_beds:spawn", "")
|
||||
else
|
||||
local oldpos = minetest.string_to_pos(player:get_attribute("mcl_beds:spawn"))
|
||||
if oldpos then
|
||||
-- We don't bother sending a message if the new spawn pos is basically the same
|
||||
if vector.distance(pos, oldpos) > 0.1 then
|
||||
spawn_changed = true
|
||||
if message then
|
||||
minetest.chat_send_player(player:get_player_name(), "New respawn position set!")
|
||||
end
|
||||
end
|
||||
end
|
||||
player:set_attribute("mcl_beds:spawn", minetest.pos_to_string(pos))
|
||||
end
|
||||
return spawn_changed
|
||||
end
|
||||
|
||||
-- Respawn player at specified respawn position
|
||||
|
|
Loading…
Reference in New Issue