Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wireless Repeater for ComputerCraft
- --
- -- HOW TO USE
- -- ##########
- -- RUN AND TYPE IN THE SIDE OF THE MODEM
- -- THE SIDE WILL BE SAVED IN A FILE
- -- TO CHANGE THE SIDE AGAIN
- -- RUN AND PRESS S WHILE RUNNING
- --
- -- HOW TO SEND TO THE REPEATER
- -- ###########################
- -- FIRST SEND THE ADDRESS OF THE RECEIVING COMPUTER TO THE REPEATER
- -- THEN SEND THE MESSAGE TO THE REPEATER
- --
- -- 2014(c) by Microstar301
- -- VERSION
- Vers = "0.46"
- -- UPDATER
- term.clear()
- term.setCursorPos(1,1)
- write("DOWNLOADING CHECK FILE")
- textutils.slowWrite("...")
- local response = http.get("http://pastebin.com/raw/mrEBZSdc")
- if response then
- print( "Success." )
- local Resp = response.readAll()
- response.close()
- if Resp == Vers then
- TERMA = 1
- else
- TERMA = 0
- end
- else
- print( "Failed." )
- TERMA = 1
- end
- if TERMA==0 then
- print("RENEWED")
- shell.run("rm",tostring(shell.getRunningProgram()))
- shell.run("pastebin","get","A768VK2G",tostring(shell.getRunningProgram()))
- os.reboot()
- else
- print("UP TO DATE")
- end
- sleep(2)
- term.setCursorPos(1,1)
- term.clear()
- textutils.slowPrint("*** INIZIALIZING REPEATER ***")
- print("ID: ",os.getComputerID())
- if fs.exists("REPCONF") == true then
- fexists = "1"
- local file = fs.open("REPCONF","r")
- SSIDE = file.readAll()
- file.close()
- else
- fexists = "0"
- print(" POSSIBLE SIDES:")
- print(" top, bottom, left, right, back, front")
- print("")
- write(" SET MODEM SIDE : ")
- USERINPUT = read()
- end
- if USERINPUT == "top" or USERINPUT == "bottom" or USERINPUT == "left" or USERINPUT == "right" or USERINPUT == "front" or USERINPUT == "back" or fexists=="1" then
- if fexists == "0" then
- SSIDE = USERINPUT
- local file = fs.open("/REPCONF","w")
- file.write(USERINPUT)
- file.close()
- end
- rednet.open(SSIDE)
- else
- error("SIDE DOES NOT EXIST")
- end
- local function REPEATER()
- while true do
- sender, address = rednet.receive()
- address = tonumber(address)
- sender, MSG = rednet.receive()
- print("GOT MSG: ",MSG," FROM: ",sender)
- rednet.send(address, MSG)
- print("SENT MSG TO: ", address)
- end
- end
- local function SETTINGS()
- while true do
- E , K = os.pullEvent("char")
- if K == "s" then
- SET = "1"
- while SET == "1" do
- print("SETUP:")
- print("1. RESET SETTING 2. REBOOT 3. EXIT")
- E, K = os.pullEvent("char")
- if K == "1" then
- if fs.delete("/REPCONF") == nil then
- print("DONE")
- end
- end
- if K == "2" then
- os.reboot()
- end
- if K == "3" then
- SET = "0"
- end
- end
- else
- print("PRESS S FOR SETUP")
- end
- end
- end
- parallel.waitForAll(SETTINGS,REPEATER)
Advertisement
Add Comment
Please, Sign In to add comment