ls_mobs = {}

local modpath = core.get_modpath('ls_mobs')
dofile(modpath..'/api.lua')
dofile(modpath..'/womble.lua')

core.register_abm({
   label = 'Spawn Wombles',
   name = 'ls_mobs:womble_spawn',
   nodenames = {'ls_map:dirt_4'},
   neighbors = 'air',
   interval = 60,
   chance = 150,
   action = function(pos)
      local objects = core.get_objects_inside_radius(pos, 35)
      if #objects < 3 then
         local above_pos = vector.add(pos, {x=0,y=1,z=0})
         local light_level = core.get_node_light(pos)
         if light_level < 5 then
            core.add_entity(above_pos, 'ls_mobs:womble')
         end
      end
   end
})
