Advertisement
Guest User

Untitled

a guest
Dec 24th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. use_mesecons = false
  2.  
  3. function npc_spawner(pos)
  4. minetest.env:add_entity({x=pos.x+math.random(-1,1),y=pos.y+math.random(2,3),z=pos.z+math.random(-1,1)}, "peaceful_npc:npc")
  5.  
  6.     -- Count the number of times a value occurs in a table
  7.     function table_count(tt, item)
  8.       local count
  9.       count = 0
  10.       for ii,xx in pairs(tt) do
  11.         if item == xx then count = count + 1 end
  12.       end
  13.       return count
  14.     end
  15.  
  16. --[[    local count = minetest.env:get_objects_inside_radius(pos, 20)
  17.         local MAX_NPC = 3
  18.  
  19.         if count>MAX_NPC then
  20.                 action_off = minetest.env:add_entity({x=pos.x+math.random(-1,1),y=pos.y+math.random(2,3),z=pos.z+math.random(-1,1)}, "peaceful_npc:npc")
  21.                 end
  22.         end]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement