SHOW:
|
|
- or go back to the newest paste.
1 | local function Pulse() | |
2 | - | |
2 | + | redstone.setOutput("back", not redstone.getOutput("back")) |
3 | end | |
4 | ||
5 | - | local connect = peripheral.find("modem") |
5 | + | local function Pulse2() |
6 | - | connect.open(43) |
6 | + | redstone.setOutput("right", not redstone.getOutput("right")) |
7 | end | |
8 | ||
9 | function bool_to_number(value) | |
10 | return value and 1 or 0 | |
11 | end | |
12 | - | event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") |
12 | + | |
13 | - | if message == "hi" then |
13 | + | local modem = peripheral.find("modem") |
14 | - | redstone.output |
14 | + | |
15 | ||
16 | modem.open(43) | |
17 | ||
18 | while true do | |
19 | event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") | |
20 | if message == "swap" then | |
21 | Pulse() | |
22 | modem.transmit(replyChannel, 43, redstone.getOutput("back")) | |
23 | end | |
24 | if message == "stop" then | |
25 | Pulse2() | |
26 | modem.transmit(replyChannel, 43, bool_to_number(redstone.getOutput("right")) + 2) | |
27 | end | |
28 | print(message) | |
29 | end |