forked from VoxeLibre/VoxeLibre
improved codestyle
This commit is contained in:
parent
f4593cfe7f
commit
0c7d1fa09f
|
@ -453,33 +453,32 @@ function mcl_spawn.get_player_spawn_pos(player)
|
||||||
-- Bed is destroyed:
|
-- Bed is destroyed:
|
||||||
if player and player:is_player() then
|
if player and player:is_player() then
|
||||||
|
|
||||||
checkblock = minetest.string_to_pos(player:get_meta():get_string("mcl_beds:spawn"))
|
local checkpos = minetest.string_to_pos(player:get_meta():get_string("mcl_beds:spawn"))
|
||||||
|
local checknode = minetest.get_node(checkpos)
|
||||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_1" then
|
|
||||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor"})
|
if(string.match(checknode.name, "mcl_beds:respawn_anchor_charged_")) then
|
||||||
player:set_pos(checkblock)
|
local charge_level = tonumber(string.sub(checknode.name, -1))
|
||||||
else
|
if not charge_level then
|
||||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_2" then
|
minetest.log("warning","could not get level of players respawn anchor, sending him back to spawn!")
|
||||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor_charged_1"})
|
player:get_meta():set_string("mcl_beds:spawn", "")
|
||||||
player:set_pos(checkblock)
|
minetest.chat_send_player(player:get_player_name(), S("Couldn't get level of your respawn anchor!"))
|
||||||
else
|
return mcl_spawn.get_world_spawn_pos(), false
|
||||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_3" then
|
elseif charge_level ~= 1 then
|
||||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor_charged_2"})
|
minetest.set_node(checkpos, {name="mcl_beds:respawn_anchor_charged_".. charge_level-1})
|
||||||
player:set_pos(checkblock)
|
return checkpos, false
|
||||||
else
|
else
|
||||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_4" then
|
minetest.set_node(checkpos, {name="mcl_beds:respawn_anchor"})
|
||||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor_charged_3"})
|
return checkpos, false
|
||||||
player:set_pos(checkblock)
|
end
|
||||||
else
|
else
|
||||||
player:get_meta():set_string("mcl_beds:spawn", "")
|
player:get_meta():set_string("mcl_beds:spawn", "")
|
||||||
minetest.chat_send_player(player:get_player_name(), S("Your spawn bed was missing or blocked, and you had no charged respawn anchor"))
|
minetest.chat_send_player(player:get_player_name(), S("Your spawn bed was missing or blocked, and you had no charged respawn anchor!"))
|
||||||
return mcl_spawn.get_world_spawn_pos(), false
|
return mcl_spawn.get_world_spawn_pos(), false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Find spawning position on/near the bed free of solid or damaging blocks iterating a square spiral 15x15:
|
-- Find spawning position on/near the bed free of solid or damaging blocks iterating a square spiral 15x15:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue