Advertisement
ecco7777

CC Sensor test

Oct 14th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 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. local targets = prox.getTargets()
  9.  
  10. -- loop through them
  11. for name, basicDetails in pairs(targets) do
  12.  
  13.   -- print their name
  14.   print("Found entity: "..name)
  15.  
  16.   -- get more details about them
  17.   local moreDetails = prox.getTargetDetails(name)
  18.  
  19.   -- print their health
  20.   print("Health: "..moreDetails.Health)
  21.   print("Health: "..moreDetails.Position.X)
  22.  
  23.   print("------")
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement