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:
|
||||
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"})
|
||||
player:set_pos(checkblock)
|
||||
if(string.match(checknode.name, "mcl_beds:respawn_anchor_charged_")) then
|
||||
local charge_level = tonumber(string.sub(checknode.name, -1))
|
||||
if not charge_level then
|
||||
minetest.log("warning","could not get level of players respawn anchor, sending him back to spawn!")
|
||||
player:get_meta():set_string("mcl_beds:spawn", "")
|
||||
minetest.chat_send_player(player:get_player_name(), S("Couldn't get level of your respawn anchor!"))
|
||||
return mcl_spawn.get_world_spawn_pos(), false
|
||||
elseif charge_level ~= 1 then
|
||||
minetest.set_node(checkpos, {name="mcl_beds:respawn_anchor_charged_".. charge_level-1})
|
||||
return checkpos, false
|
||||
else
|
||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_2" then
|
||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor_charged_1"})
|
||||
player:set_pos(checkblock)
|
||||
else
|
||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_3" then
|
||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor_charged_2"})
|
||||
player:set_pos(checkblock)
|
||||
else
|
||||
if minetest.get_node(checkblock).name == "mcl_beds:respawn_anchor_charged_4" then
|
||||
minetest.set_node(checkblock, {name="mcl_beds:respawn_anchor_charged_3"})
|
||||
player:set_pos(checkblock)
|
||||
minetest.set_node(checkpos, {name="mcl_beds:respawn_anchor"})
|
||||
return checkpos, false
|
||||
end
|
||||
else
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Find spawning position on/near the bed free of solid or damaging blocks iterating a square spiral 15x15:
|
||||
|
||||
|
|
Loading…
Reference in New Issue