Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function createFile(name,content)
- if fs.exists(name) then
- return "file exists"
- else
- local file = fs.open(name, "w")
- file.write(content)
- file.flush()
- end
- print("Created file "..name)
- end
- local function listenSwitch()
- -- Listen to switch
- switch.open(channel)
- while true do
- local event, modemSide, senderID, channel, message = os.pullEvent("modem_message")
- if modemSide == switchSide then
- modem.transmit(channel, channel, message)
- print(textutils.serialize(message))
- end
- end
- end
- local function listenModem()
- -- Listen to modem
- modem.open(channel)
- while true do
- local event, modemSide, senderID, channel, message = os.pullEvent("modem_message")
- if modemSide == wiredSide then
- switch.transmit(channel, channel, message)
- print(textutils.serialize(message))
- end
- end
- end
- switchSide = "left"
- wiredSide = "right"
- switch = peripheral.wrap(switchSide)
- modem = peripheral.wrap(wiredSide)
- channel = 65535
- parallel.waitForAny(listenModem, listenSwitch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement