fix mob spawning
This commit is contained in:
parent
6afafc0ec5
commit
ea36aca347
@ -168,9 +168,13 @@ minetest.register_globalstep(function(dtime)
|
|||||||
local a = {-1, 1}
|
local a = {-1, 1}
|
||||||
local x = math.random(20, 40)*a[math.random(1,2)] + p.x
|
local x = math.random(20, 40)*a[math.random(1,2)] + p.x
|
||||||
local z = math.random(20, 40)*a[math.random(1,2)] + p.z
|
local z = math.random(20, 40)*a[math.random(1,2)] + p.z
|
||||||
if minetest.get_node(vector.new(x, p.y+2, z)).name == "air" then
|
|
||||||
local n = mobs.get_mob(xp.player_levels[player:get_player_name()])
|
local nodes_under_air = minetest.find_nodes_in_area_under_air({x=x-10, y=p.y-20, z = p.z-10}, {x=x+10, y=p.y+20, z = p.z+10}, {"group:cracky", "group:crumbly", "group:choppy"})
|
||||||
minetest.add_entity(vector.new(x, p.y+2, z), n)
|
if #nodes_under_air > 0 then
|
||||||
|
local spawn_pos = nodes_under_air[math.random(#nodes_under_air)]
|
||||||
|
|
||||||
|
local spawn_mob = mobs.get_mob(xp.player_levels[player:get_player_name()])
|
||||||
|
minetest.add_entity(spawn_pos, spawn_mob)
|
||||||
mobs.count = mobs.count +1
|
mobs.count = mobs.count +1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user