SHOW:
|
|
- or go back to the newest paste.
| 1 | local function openRednet() | |
| 2 | local listOfSides = rs.getSides() | |
| 3 | local listofPossibles = {}
| |
| 4 | local counter1 = 0 | |
| 5 | while true do | |
| 6 | counter1 = counter1 +1 | |
| 7 | ||
| 8 | if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then | |
| 9 | - | rednet.open("right")
|
| 9 | + | table.insert(listofPossibles,tostring(listOfSides[counter1])) |
| 10 | - | rednet.open("left")
|
| 10 | + | end |
| 11 | - | rednet.open("front")
|
| 11 | + | |
| 12 | - | rednet.open("back")
|
| 12 | + | if counter1 == 6 and table.maxn(listofPossibles) == 0 then |
| 13 | print("no wifi present")
| |
| 14 | return nil | |
| 15 | end | |
| 16 | ||
| 17 | if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then | |
| 18 | rednet.open(listofPossibles[1]) | |
| 19 | return listofPossibles[1] | |
| 20 | - | print("Welcome to RedNet explorer! This requires you to have a wireless modem on your computer. This is the default homepage. A homepage option might be added in 1.3")
|
| 20 | + | end |
| 21 | - | print("Host a website at: ")
|
| 21 | + | |
| 22 | - | print("www.newsite.com! ")
|
| 22 | + | |
| 23 | - | print(" -ComputerCraftFan11 ")
|
| 23 | + | modemOn = openRednet() |
| 24 | local homepage = "home"; | |
| 25 | local website = "home"; | |
| 26 | local nw = ""; | |
| 27 | local idd = os.computerID() | |
| 28 | local port1 = idd * 32 | |
| 29 | local port2 = 0 | |
| 30 | local port3 = port2 / 32 | |
| 31 | local needport = 0 | |
| 32 | local function cPrint(text) | |
| 33 | local x,y = term.getSize() | |
| 34 | local x2,y2 = term.getCursorPos() | |
| 35 | term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2) | |
| 36 | print(text) | |
| 37 | end | |
| 38 | function home() | |
| 39 | print("Welcome to RedNet explorer!")
| |
| 40 | needport = 0 | |
| 41 | end | |
| 42 | function newsite() | |
| 43 | if fs.exists("rns") then
| |
| 44 | shell.run("rns")
| |
| 45 | else | |
| 46 | shell.run("pastebin", "get", "gcPf1FiK", "rns")
| |
| 47 | shell.run("rns")
| |
| 48 | end | |
| 49 | end | |
| 50 | function newsite2() | |
| 51 | cPrint("Rednet Site Manager")
| |
| 52 | print("")
| |
| 53 | print("People can connect to this site by going to www." ..nw.. ".com")
| |
| 54 | print("You can edit this site by going to www." ..nw.. ".com/editor")
| |
| 55 | print("Your port is " ..port1)
| |
| 56 | needport = 0 | |
| 57 | end | |
| 58 | function drawEditor() | |
| 59 | print("Welcome to the site editor! Enter some text and it will be displayed when people connect.")
| |
| 60 | print("---")
| |
| 61 | line1 = read() | |
| 62 | line2 = read() | |
| 63 | line3 = read() | |
| 64 | line4 = read() | |
| 65 | line5 = read() | |
| 66 | rednet.send(id, "Editor " ..website) | |
| 67 | rednet.send(id, line1) | |
| 68 | rednet.send(id, line2) | |
| 69 | rednet.send(id, line3) | |
| 70 | rednet.send(id, line4) | |
| 71 | rednet.send(id, line5) | |
| 72 | print("---")
| |
| 73 | print("Saved!")
| |
| 74 | sleep(1) | |
| 75 | website = homepage | |
| 76 | drawScreen() | |
| 77 | end | |
| 78 | function loadwebpage() | |
| 79 | rednet.broadcast(website) | |
| 80 | print("Connecting...")
| |
| 81 | id, message = rednet.receive() | |
| 82 | term.clear() | |
| 83 | term.setCursorPos(1,1) | |
| 84 | cPrint("Rednet Explorer 1.3")
| |
| 85 | ||
| 86 | cPrint("rdnt://"..website)
| |
| 87 | print("")
| |
| 88 | if message == "epanst" then | |
| 89 | drawEditor() | |
| 90 | else | |
| 91 | print(message) | |
| 92 | id, message = rednet.receive() | |
| 93 | print(message) | |
| 94 | id, message = rednet.receive() | |
| 95 | print(message) | |
| 96 | id, message = rednet.receive() | |
| 97 | print(message) | |
| 98 | id, message = rednet.receive() | |
| 99 | print(message) | |
| 100 | ||
| 101 | print("")
| |
| 102 | ||
| 103 | write("Goto:")
| |
| 104 | address = io.read() | |
| 105 | website = address | |
| 106 | drawScreen() | |
| 107 | end | |
| 108 | end | |
| 109 | function drawScreen() | |
| 110 | term.clear() | |
| 111 | term.setCursorPos(1,1) | |
| 112 | cPrint("Rednet Explorer 1.3")
| |
| 113 | ||
| 114 | cPrint("rdnt://"..website)
| |
| 115 | print("")
| |
| 116 | ||
| 117 | if website == "home" then | |
| 118 | home() | |
| 119 | elseif website == "www.newsite.com" then | |
| 120 | newsite() | |
| 121 | end | |
| 122 | ||
| 123 | ||
| 124 | print("")
| |
| 125 | ||
| 126 | write("Goto:")
| |
| 127 | address = io.read() | |
| 128 | website = address | |
| 129 | needport = 1 | |
| 130 | if website == "home" then | |
| 131 | drawScreen() | |
| 132 | elseif website == "www.newsite.com" then | |
| 133 | drawScreen() | |
| 134 | else | |
| 135 | loadwebpage() | |
| 136 | end | |
| 137 | end | |
| 138 | drawScreen() |