SHARE
TWEET

[ComputerCraft] Entity Sensor

Frekvens1 Jul 17th, 2019 (edited) 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- FluidCows scanner for Plethora in ComputerCraft
  2.  
  3. interface = peripheral.wrap("back")
  4. local canvas = interface.canvas()
  5. local text
  6. local entities = {}
  7.  
  8. local running = true
  9. while running do
  10.     local data = interface.sense()
  11.     local count = 0
  12.     entities = {}
  13.     canvas.clear()
  14.    
  15.     for _, entity in pairs(data) do
  16.         if (entity["name"] == "fluidcows.fluidcow") then
  17.             entities[entity["id"]] = entity
  18.             count = count + 1
  19.            
  20.             local distance = math.ceil(math.sqrt(math.pow(entity["x"],2)+math.pow(entity["y"],2)+math.pow(entity["z"],2)))
  21.            
  22.             text = canvas.addText({ x = 5, y = (10*count)+15 }, entity["displayName"].." ("..tostring(distance).."m)")
  23.             text.setScale(1)
  24.  
  25.         end
  26.     end
  27.    
  28.     for name, t in pairs(entities) do
  29.        
  30.     end
  31.    
  32.     text = canvas.addText({ x = 5, y = 5 }, "Entities: "..count)
  33.     text.setScale(1)
  34.    
  35.     os.sleep(0.1)
  36. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top