From 5897d0743533674566b882e8eb580a1732c599c3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 7 Feb 2019 19:54:12 +0100 Subject: [PATCH] Don't show bed msg if player respawns w/o bed --- mods/PLAYER/mcl_spawn/init.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index 0413219b4..9c9079b9c 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -2,21 +2,26 @@ mcl_spawn = {} -- Returns current spawn position of player. -- If player is nil or not a player, the default spawn point is returned. +-- The second return value is true if spawn point is player-chosen, +-- false otherwise. mcl_spawn.get_spawn_pos = function(player) - local spawn + local spawn, custom_spawn if player ~= nil and player:is_player() then spawn = minetest.string_to_pos(player:get_attribute("mcl_beds:spawn")) + custom_spawn = true end if not spawn or spawn == "" then spawn = minetest.setting_get_pos("static_spawnpoint") + custom_spawn = false end if not spawn then spawn = { x=0, y=0, z=0 } if mg_name == "flat" then spawn.y = mcl_vars.mg_bedrock_overworld_max + 5 end + custom_spawn = false end - return spawn + return spawn, custom_spawn end -- Sets the player's spawn position to pos. @@ -31,8 +36,8 @@ end -- Respawn player at specified respawn position minetest.register_on_respawnplayer(function(player) - local pos = mcl_spawn.get_spawn_pos(player) - if pos then + local pos, custom_spawn = mcl_spawn.get_spawn_pos(player) + if custom_spawn then -- Check if bed is still there -- and the spawning position is free of solid or damaging blocks. local node_bed = minetest.get_node(pos)