Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- redstone.setBundledOutput("right",0) -- Reset all bundled cables to off state
- player= peripheral.wrap("left")
- local safestate=0
- -- Function to perform when the door is set to unlock state
- function dlock_off()
- safestate=1
- end
- -- Function to perform when the door is set to lock state
- function dlock_on()
- safestate=0
- end
- function pushBook()
- peripheral.call("bottom","pushItem","up",1,1)
- end
- function pullBook()
- peripheral.call("bottom","pullItem","up",1,1,1)
- end
- while true do
- if (colors.test(redstone.getBundledInput("right"),colors.white)) then
- dlock_off()
- end
- if (colors.test(redstone.getBundledInput("right"),colors.black)) then
- dlock_on()
- end
- if (safestate==1) then pushBook() else
- if (safestate==0 and table.getn(player.getNearbyPlayers(7))>0) then
- pullBook()
- else
- pushBook()
- end
- end
- redstone.setAnalogOutput("front",safestate)
- sleep(1)
- end
Add Comment
Please, Sign In to add comment