initial protection checks.
This commit is contained in:
parent
f09834b5ba
commit
1fc90a27fe
14
init.lua
14
init.lua
@ -2,10 +2,10 @@ random_spawn = {}
|
|||||||
|
|
||||||
function random_spawn(player)
|
function random_spawn(player)
|
||||||
local elevation = 15
|
local elevation = 15
|
||||||
local radius = 1000
|
local radius = 5
|
||||||
local posx = math.random(-radius, radius)
|
local posx = math.random(-radius, radius)
|
||||||
local posz = math.random(-radius, radius)
|
local posz = math.random(-radius, radius)
|
||||||
local new_spawn = {x = posx, y = elevation, z = posz}
|
local new_spawn = {x = -174 + posx, y = elevation, z = 178 + posz}
|
||||||
local node = minetest.get_node_or_nil(new_spawn)
|
local node = minetest.get_node_or_nil(new_spawn)
|
||||||
if not node or node.name == 'ignore' then
|
if not node or node.name == 'ignore' then
|
||||||
minetest.emerge_area({x = new_spawn.x, y = new_spawn.y+30, z = new_spawn.z}, {x = new_spawn.x, y = new_spawn.y-30, z = new_spawn.z})
|
minetest.emerge_area({x = new_spawn.x, y = new_spawn.y+30, z = new_spawn.z}, {x = new_spawn.x, y = new_spawn.y-30, z = new_spawn.z})
|
||||||
@ -27,14 +27,15 @@ function find_ground(pos, player)
|
|||||||
random_spawn(player)
|
random_spawn(player)
|
||||||
end
|
end
|
||||||
if node.name ~= 'air' and node.name ~= 'ignore' then
|
if node.name ~= 'air' and node.name ~= 'ignore' then
|
||||||
local protection = minetest.is_protected({x = pos.x, y = pos.y - i + 2, z = pos.z})
|
local protection = minetest.is_protected({x = pos.x, y = pos.y - i + 2, z = pos.z}, player)
|
||||||
if protection then
|
if protection then
|
||||||
random_spawn(player)
|
random_spawn(player)
|
||||||
end
|
else
|
||||||
player:setpos({x = pos.x, y = pos.y - i + 2, z = pos.z})
|
player:setpos({x = pos.x, y = pos.y - i + 2, z = pos.z})
|
||||||
minetest.set_node({x = pos.x, y = pos.y + i +1, z = pos.z}, {name = 'default:torch', param2 = 1})
|
minetest.set_node({x = pos.x, y = pos.y + i +1, z = pos.z}, {name = 'default:torch', param2 = 1})
|
||||||
finished = true
|
finished = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
until finished == true or i < -40
|
until finished == true or i < -40
|
||||||
elseif node.name ~= 'air' or node.name ~= 'ignore' then --Theoretically below ground
|
elseif node.name ~= 'air' or node.name ~= 'ignore' then --Theoretically below ground
|
||||||
local i = 1
|
local i = 1
|
||||||
@ -45,14 +46,15 @@ function find_ground(pos, player)
|
|||||||
random_spawn(player)
|
random_spawn(player)
|
||||||
end
|
end
|
||||||
if node.name == 'air' then
|
if node.name == 'air' then
|
||||||
local protection = minetest.is_protected({x = pos.x, y = pos.y + i, z = pos.z})
|
local protection = minetest.is_protected({x = pos.x, y = pos.y + i, z = pos.z}, player)
|
||||||
if protection then
|
if protection then
|
||||||
random_spawn(player)
|
random_spawn(player)
|
||||||
end
|
else
|
||||||
player:setpos({x = pos.x, y = pos.y + i, z = pos.z})
|
player:setpos({x = pos.x, y = pos.y + i, z = pos.z})
|
||||||
minetest.set_node({x = pos.x, y = pos.y + i -1, z = pos.z}, {name = 'default:torch', param2 = 1})
|
minetest.set_node({x = pos.x, y = pos.y + i -1, z = pos.z}, {name = 'default:torch', param2 = 1})
|
||||||
i = 45
|
i = 45
|
||||||
end
|
end
|
||||||
|
end
|
||||||
until node.name == 'air' or i >= 40
|
until node.name == 'air' or i >= 40
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user