Advertisement
Guest User

derpb

a guest
Jun 16th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. -- load the API
  2. os.loadAPI("ocs/apis/sensor")
  3.  
  4. -- wrap the sensor
  5. prox = sensor.wrap("left")
  6.  
  7. -- get the targets
  8. function getTarg()
  9.   targets = prox.getTargets()
  10. end
  11.  
  12. function nl()
  13.   currX, currY = m.getCursorPos()
  14.   m.setCursorPos(1, currY + 1)
  15. end
  16.  
  17.  
  18. m = peripheral.wrap("top")
  19.  
  20. function monInit()
  21.   m.clear()
  22.   m.setCursorPos(1,1)
  23.   m.setTextColor(colors.blue)
  24. end
  25.  
  26. monInit()
  27.  
  28. function derp1()
  29.  
  30. -- loop through them
  31.  for name, basicDetails in pairs(targets) do
  32.  
  33.   -- print their name
  34.   m.write("Found entity: "..name)
  35.   nl()
  36.  
  37.   -- get more details about them
  38.   local moreDetails = prox.getTargetDetails(name)
  39.  
  40.   -- print their health
  41.   m.write("Health: "..moreDetails.Health)
  42.   nl()
  43.  
  44.   m.write("------")
  45.   nl()
  46.  end
  47.  
  48. end
  49.  
  50. x = 1
  51.  
  52. function loop()
  53.  if x > 0 then
  54.   getTarg()
  55.   derp1()
  56.   sleep(2.9)
  57.   monInit()
  58.   loop()
  59.  end
  60. end
  61.  
  62. loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement