Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local TobiasId = 21
  2. local YannikId = 17
  3. local RobertId = 20
  4.  
  5. local rednetSide = 'top'
  6. local closeSide = 'right'
  7. local openSide = 'left'
  8.  
  9. local doorOpenTime = 200
  10.  
  11. local doorSize = 3
  12.  
  13. --Do not change, otherwise you will have problems!
  14. local counter = 0
  15.  
  16. local function isValid(id)
  17.     if id == TobiasId then
  18.         return true
  19.     end
  20.     if id == YannikId then
  21.         return true
  22.     end
  23.     if id == RobertId then
  24.         return true
  25.     end
  26. return false
  27. end
  28.  
  29. local function openDoor()
  30.     while counter < doorSize do
  31.     redstone.setOutput(openSide, true)
  32.     sleep(5)
  33.     redstone.setOutput(openSide, false)
  34.     counter = counter + 1
  35.     end
  36.     counter = 0
  37. end
  38.  
  39. local function closeDoor()
  40.     while counter < doorSize do
  41.     redstone.setOutput(closeSide, true)
  42.     sleep(5)
  43.     redstone.setOutput(closeSide, false)
  44.     counter = counter + 1
  45.     end
  46.     counter = 0
  47. end
  48.  
  49.  
  50.  
  51. --Hauptprogramm
  52. rednet.open(rednetSide)
  53.  
  54. id,message,distance = rednet.receive()
  55.  
  56. if isValid(id) == true then
  57.     if distance < 500 then
  58.         openDoor
  59.         sleep(doorOpenTime)
  60.         closeDoor
  61.         sleep(10)
  62.     end
  63. end
  64. rednet.close(rednetSide)
  65. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement