Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- local os.pullEvent = os.pullEventRaw
- local channel
- function drawScreen()
- term.clear()
- term.setCursorPos(1,1)
- term.write("NanoBank Repeater 1.0")
- term.setCursorPos(3,3)
- end
- drawScreen()
- local modem = peripheral.find("modem")
- if modem == nil then
- print("Failed to initialise modem.")
- else
- print("Initialised modem.")
- end
- term.setCursorPos(3,4)
- if fs.exists("event")==false then shell.run("pastebin get UKPy4iiE event") end
- if os.loadAPI("event")==false then error("Failed to load event API") end
- if fs.exists("data")==false then shell.run("pastebin get LnvzL7ur data") end
- if os.loadAPI("data")==false then error("Failed to load data API") end
- if fs.exists("utils")==false then shell.run("pastebin get dyvydHtK utils") end
- if os.loadAPI("utils")==false then error("Failed to load utils API") end
- term.write("Sucessfully loaded APIs")
- if data.get("channel","channel") == nil then
- term.setCursorPos(3,5)
- term.write("Input channel please: ")
- channel = tonumber(read())
- data.set("channel",channel,"channel")
- modem.open(channel)
- term.setCursorPos(3,5)
- term.write("Channel successfully opened ")
- else
- channel = tonumber(data.get("channel","channel"))
- modem.open(channel)
- term.setCursorPos(3,5)
- term.write("Channel successfully opened ")
- end
- function received(side,receiveChannel,replyChannel,message)
- local target = message[1]
- if target == channel - 1 then
- local message = table.remove(message,1)
- modem.transmit(channel-1,replyChannel,message)
- elseif target == channel + 1 then
- local message = table.remove(message,1)
- modem.transmit(channel+1,replyChannel,message)
- elseif target > channel then
- modem.transmit(channel+1,replyChannel,message)
- elseif target < channel then
- modem.transmit(channel-1,replyChannel,message)
- end
- end
- event.addHandler("modem_message",received)
- while true do
- event.handleCCEvents()
- end
Add Comment
Please, Sign In to add comment