1 --this is where mob spawning is defined
3 --spawn mob in a square doughnut shaped radius
7 --inner and outer part of square donut radius
11 --for debug testing to isolate mobs
14 local spawn_table = {"pig","slime"}
15 local aether_spawn_table = {"flying_pig"}
16 minetest.register_globalstep(function(dtime)
19 if timer >= tick and math.random(1,chance) == chance then
22 --check through players
23 for _,player in ipairs(minetest.get_connected_players()) do
24 --don't spawn near dead players
25 if player:get_hp() > 0 then
27 --local mob_number = math.random(0,2)
30 local pos = vector.floor(vector.add(player:getpos(),0.5))
34 --this is used to determine the axis buffer from the player
35 local axis = math.random(0,1)
37 --cast towards the direction
39 x = pos.x + math.random(inner,outer)*int[math.random(1,2)]
40 z = pos.z + math.random(-outer,outer)
42 z = pos.z + math.random(inner,outer)*int[math.random(1,2)]
43 x = pos.x + math.random(-outer,outer)
47 if pos.y >= 21000 then
48 spawner = minetest.find_nodes_in_area_under_air(vector.new(x,pos.y-32,z), vector.new(x,pos.y+32,z), {"aether:grass"})
50 spawner = minetest.find_nodes_in_area_under_air(vector.new(x,pos.y-32,z), vector.new(x,pos.y+32,z), {"main:grass","main:sand","main:water"})
53 --print(dump(spawner))
54 if table.getn(spawner) > 0 then
55 local mob_pos = spawner[1]
57 if mob_pos.y >= 21000 then
58 mob_pos.y = mob_pos.y + 1
59 local mob_spawning = aether_spawn_table[1]
60 print("Spawning "..mob_spawning.." at: "..minetest.pos_to_string(mob_pos))
61 minetest.add_entity(mob_pos,"mob:"..mob_spawning)
64 mob_pos.y = mob_pos.y + 1
65 local mob_spawning = spawn_table[math.random(1,2)]
66 print("Spawning "..mob_spawning.." at: "..minetest.pos_to_string(mob_pos))
67 minetest.add_entity(mob_pos,"mob:"..mob_spawning)
72 elseif timer > tick then