tsargothruneclaw

Untitled

Apr 5th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. redstone.setBundledOutput("right",0) -- Reset all bundled cables to off state
  2. player= peripheral.wrap("left")
  3.  
  4. local safestate=0  
  5.                  
  6. -- Function to perform when the door is set to unlock state
  7. function dlock_off()
  8.     safestate=1
  9. end
  10.  
  11. -- Function to perform when the door is set to lock state
  12. function dlock_on()
  13.     safestate=0
  14. end
  15.  
  16. function pushBook()
  17.     peripheral.call("bottom","pushItem","up",1,1)
  18. end
  19. function pullBook()
  20.     peripheral.call("bottom","pullItem","up",1,1,1)
  21. end
  22.  
  23. while true do
  24.     if (colors.test(redstone.getBundledInput("right"),colors.white)) then
  25.         dlock_off()
  26.     end
  27.     if (colors.test(redstone.getBundledInput("right"),colors.black)) then
  28.         dlock_on()
  29.     end
  30.     if (safestate==1) then pushBook() else
  31.         if (safestate==0 and table.getn(player.getNearbyPlayers(7))>0) then
  32.             pullBook()
  33.         else
  34.             pushBook()
  35.         end
  36.     end
  37.     redstone.setAnalogOutput("front",safestate)
  38.     sleep(1)
  39. end
Add Comment
Please, Sign In to add comment