SHOW:
|
|
- or go back to the newest paste.
1 | - | redstone.setBundledOutput("right",0) |
1 | + | redstone.setBundledOutput("right",0) -- Reset all bundled cables to off state |
2 | player= peripheral.wrap("left") | |
3 | ||
4 | - | if (colors.test(redstone.getBundledInput("right"),colors.white)) then |
4 | + | local safestate=0 |
5 | - | peripheral.call("bottom","pushItem","up",1,1) |
5 | + | |
6 | - | redstone.setAnalogOutput("left",1) |
6 | + | -- Function to perform when the door is set to unlock state |
7 | function dlock_off() | |
8 | - | if (colors.test(redstone.getBundledInput("right"),colors.black)) then |
8 | + | safestate=1 |
9 | - | peripheral.call("bottom","pullItem","up",1,1,1) |
9 | + | |
10 | - | redstone.setAnalogOutput("left",0) |
10 | + | |
11 | -- Function to perform when the door is set to lock state | |
12 | - | sleep(5) |
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 |