Advertisement
Arc13

Entity Count Detector

Aug 25th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. function getEntityCount(range, x, y, z, entity)
  2.   local t = peripheral.find("EntityDetector")
  3.   if not t then
  4.     error("No EntityDetector detected !")
  5.   end
  6.  
  7.   if not entity then
  8.     return false
  9.   end
  10.  
  11.   local tEntities = {}
  12.   local nEntityCount = 0
  13.   local f = t.getEntityList(range, x, y, z)
  14.  
  15.   for k, v in pairs(f) do
  16.     if v.type == entity then
  17.       nEntityCount = nEntityCount + 1
  18.       table.insert(tEntities, v.type)
  19.     end
  20.   end
  21.  
  22.   return nEntityCount, tEntities
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement