Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local thisID = os.getComputerID()
- local otherID = "999999"
- local function openRednet()
- local listOfSides = rs.getSides()
- local listofPossibles = {}
- local counter1 = 0
- while true do
- counter1 = counter1 +1
- if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
- table.insert(listofPossibles,tostring(listOfSides[counter1]))
- end
- if counter1 == 6 and table.maxn(listofPossibles) == 0 then
- print("no wifi present")
- return nil
- end
- if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
- rednet.open(listofPossibles[1])
- return listofPossibles[1]
- end
- end
- end
- local function openMonitor()
- local listOfSides = rs.getSides()
- local listofPossibles = {}
- local counter1 = 0
- while true do
- counter1 = counter1 +1
- if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "monitor" then
- table.insert(listofPossibles,tostring(listOfSides[counter1]))
- end
- if counter1 == 6 and table.maxn(listofPossibles) == 0 then
- print("no monitor present")
- return nil
- end
- if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
- monitor = peripheral.wrap(listofPossibles[1])
- return listofPossibles[1]
- end
- end
- end
- modemOn = openRednet()
- monitorOn = openMonitor()
- function newLine()
- _,cY = monitor.getCursorPos()
- monitor.setCursorPos(1,cY+1)
- end
- function printAll(message)
- print(message)
- newLine()
- monitor.write(message)
- end
- function printAll2(message)
- monitor.setCursorPos(1,cY)
- term.clearLine()
- monitor.clearLine()
- print(message)
- monitor.write(message)
- end
- if modemOn == nil then
- printAll("No WIFI Modem")
- printAll("Will shutdown in 3 seconds")
- sleep(3)
- os.shutdown()
- else
- printAll("Opened wifi on "..modemOn.." side")
- printAll("thisId: " .. thisID)
- while not redstone.getInput("bottom") do
- while otherID == "999999" do
- rednet.broadcast(thisID)
- senderId, message, distance = rednet.receive(1)
- if senderId ~= thisID and message ~= nil then
- otherID = message
- end
- end
- sleep(.1)
- end
- sleep(.5)
- rednet.broadcast(thisID)
- printAll("otherId: " .. tostring(otherID))
- newLine()
- newLine()
- while redstone.getInput("bottom") do
- sleep(.1)
- printAll2("Redstone active")
- end
- printAll2("Redstone deactive")
- sleep(2)
- printAll("Will shutdown in 3 seconds")
- sleep(3)
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement