Advertisement
VGToolBox

Hand Scanner

Oct 25th, 2013
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2.  
  3.  
  4. door = peripheral.wrap("monitor_1")
  5. door.setTextScale(0.5)
  6.  
  7. radar = sensor.wrap("right")
  8.  
  9. --You'll need to alter these to set the names of people you want to allows for
  10. allow = {}
  11. allow.Glitcher = true
  12. allow.buncible = true
  13. allow.nipde = true
  14. allow.DaveChaos = true
  15. allow._gar = false
  16.  
  17. --You'll need to alter these/this to set the names of people you don't want to allow in
  18. avoid = {}
  19. avoid._gar = true
  20.  
  21. --You'll need to alter these to match the distances you want to look for.
  22. xMin = -5
  23. xMax = -1
  24. yMin = -6
  25. yMax = -4
  26.  
  27. term.redirect(door)
  28.  
  29. handGood = paintutils.loadImage("handGood")
  30. handBad = paintutils.loadImage("handBad")
  31. handNormal = paintutils.loadImage("hand")
  32.  
  33.  
  34. paintutils.drawImage(handNormal,1,1)
  35.  
  36.  
  37. local function checkInRange(number, min, max)
  38.  
  39.   return number >= min and number <= max
  40.  
  41. end
  42.  
  43. local function checkTargets(targets, compare)
  44.  
  45.   for k,v in pairs(compare) do
  46.  
  47.     if targets[k] then
  48. --print(targets[k].Position.X," ", targets[k].Position.Z)  
  49. --sleep(8)
  50.             if checkInRange(targets[k].Position.X, xMin, xMax) then
  51.      
  52.         if checkInRange(targets[k].Position.Z, yMin, yMax) then
  53.           return true
  54.         end
  55.      
  56.       end
  57.    
  58.     end
  59.        
  60.   end
  61.  
  62.   return false
  63.  
  64. end
  65.  
  66. while true do
  67.  
  68.   timer = os.startTimer(9)
  69.  
  70.   e, k = os.pullEvent()
  71.  
  72.   if e == "monitor_touch" then
  73.     if checkTargets(radar.getTargets(),allow) and not checkTargets(radar.getTargets(), avoid) then
  74.       paintutils.drawImage(handGood, 1,1)
  75.       rs.setOutput("front", true)
  76.       sleep(2)
  77.       os.reboot()
  78.     else
  79.       paintutils.drawImage(handBad, 1,1)
  80.       sleep(3)
  81.       os.reboot()
  82.    
  83.     end
  84.   end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement