Phoenix_Tekkit

doorControl

Jul 15th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. function APILoader(apiName, apiPastebin)
  2.         os.unloadAPI(apiName)
  3.         if fs.exists(apiName)
  4.         then
  5.                 os.loadAPI(apiName)
  6.         else
  7.                 shell.run("pastebin","get",apiPastebin,apiName)
  8.                 os.loadAPI(apiName)
  9.         end
  10. end
  11.  
  12. APILoader("commonFunctions","x5Ve1KSK")
  13.  
  14. os.unloadAPI("sensor")
  15. os.loadAPI("/ocs/apis/sensor")
  16.  
  17.  
  18. function main()
  19.         periphs = commonFunctions.getPeripherals()
  20.         if periphs["sensor"] == nil -- check for a sensor and that it has the right card
  21.         then
  22.             return("No sensor found!")
  23.         else
  24.                         sens = sensor.wrap(periphs["sensor"])
  25.                         if sens.getSensorName() == "proximityCard"
  26.                         then
  27.                                 print("Found a proximity sensor on the " .. periphs["sensor"] .. " and wrapped it")
  28.                         else
  29.                                 return("Sensor card is not a proximity sensor")
  30.                         end
  31.         end
  32.         if periphs["monitor"] ~= nil
  33.         then
  34.                 mon = peripheral.wrap(periphs["monitor"])
  35.         end
  36.         readLoop()
  37.         return("End of program reached")
  38. end
  39.  
  40. function findPlayer(targets)
  41.     for k, v in pairs(targets) do
  42.         if v.Name == "Player"
  43.         then return false end
  44.     end
  45.     return true
  46. end
  47.  
  48. function readLoop()
  49.         continue = true
  50.         while continue do
  51.                 targs = sens.getTargets()
  52.                 regionData = {}
  53.                 redstone.setOutput("back",findPlayer(targs))
  54.                 sleep(1)
  55.         end
  56. end
  57.  
  58. print(main())
Advertisement
Add Comment
Please, Sign In to add comment