Elgskred

bridgeSensor

Aug 2nd, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. s = peripheral.wrap("right")
  2. players = s.getPlayers()
  3.  
  4.  
  5. function checkPos(x, y ,z)
  6. if x > -2 and x < 2 then
  7.     if y > 1 and y < 10 then
  8.         if z > -3 and z < 20 then
  9.             return 1
  10.         end
  11.     end
  12. end
  13. end
  14.  
  15. while true do
  16.  
  17. signal = false
  18. rs.setOutput("back", signal)
  19. rs.setOutput("left", not signal)
  20. override = rs.getInput("front")
  21. players = s.getPlayers()
  22.     if override == false then
  23.         for k, v in pairs(players) do
  24.             if v.name == "elgskred" then
  25.                 pname = s.getPlayerByName(v.name)
  26.                 posInfo = pname.basic()
  27.                 posX = posInfo.position.x
  28.                 posY = posInfo.position.y
  29.                 posZ = posInfo.position.z
  30.                 if checkPos(posX, posY, posZ) == 1 then
  31.                     signal = true
  32.                     rs.setOutput("back", signal)
  33.                     rs.setOutput("left", not signal)
  34.                     sleep(10)
  35.                 end
  36.                
  37.             end
  38.         end
  39.    
  40.     sleep(1)
  41.     else
  42.         signal = true
  43.         rs.setOutput("back", signal)
  44.         rs.setOutput("left", not signal)
  45.         sleep(10)
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment