SHOW:
|
|
- or go back to the newest paste.
| 1 | local homepage = "home"; | |
| 2 | - | local website = "www.newsite.com"; |
| 2 | + | local website = "luit03.nl"; |
| 3 | local nw = ""; | |
| 4 | local idd = os.computerID() | |
| 5 | local port1 = idd * 32 | |
| 6 | local port2 = 0 | |
| 7 | local port3 = port2 / 32 | |
| 8 | ||
| 9 | local line1 = "This website is currently down or has not been edited. If you are the owner of this website please check your webservers or contact your webserver manager for further assistance." | |
| 10 | local line2 = "" | |
| 11 | local line3 = "" | |
| 12 | local line4 = "" | |
| 13 | local line5 = "" | |
| 14 | ||
| 15 | - | rednet.open("right")
|
| 15 | + | local function openRednet() |
| 16 | - | rednet.open("left")
|
| 16 | + | local listOfSides = rs.getSides() |
| 17 | - | rednet.open("front")
|
| 17 | + | local listofPossibles = {}
|
| 18 | - | rednet.open("back")
|
| 18 | + | local counter1 = 0 |
| 19 | while true do | |
| 20 | counter1 = counter1 +1 | |
| 21 | ||
| 22 | if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then | |
| 23 | table.insert(listofPossibles,tostring(listOfSides[counter1])) | |
| 24 | end | |
| 25 | ||
| 26 | if counter1 == 6 and table.maxn(listofPossibles) == 0 then | |
| 27 | print("no wifi present")
| |
| 28 | return nil | |
| 29 | - | print("Host a website at: ")
|
| 29 | + | end |
| 30 | - | print("www.newsite.com! ")
|
| 30 | + | |
| 31 | - | print(" -ComputerCraftFan11 ")
|
| 31 | + | if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then |
| 32 | rednet.open(listofPossibles[1]) | |
| 33 | return listofPossibles[1] | |
| 34 | end | |
| 35 | end | |
| 36 | end | |
| 37 | modemOn = openRednet() | |
| 38 | ||
| 39 | local function cPrint(text) | |
| 40 | local x,y = term.getSize() | |
| 41 | local x2,y2 = term.getCursorPos() | |
| 42 | term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2) | |
| 43 | print(text) | |
| 44 | end | |
| 45 | ||
| 46 | function home() | |
| 47 | print("Welcome to RedNet explorer! This requires you to have a wireless modem on the right side of your computer. This is the default homepage. A homepage option might be added in 1.2")
| |
| 48 | end | |
| 49 | ||
| 50 | function newsite() | |
| 51 | cPrint("Rednet Site Manager")
| |
| 52 | print("")
| |
| 53 | print("Welcome to the rednet site manager!")
| |
| 54 | print("To make a new website, enter a domain name (.com will NOT be added for you.):")
| |
| 55 | end | |
| 56 | ||
| 57 | function newsite2() | |
| 58 | cPrint("Rednet Site Manager")
| |
| 59 | print("")
| |
| 60 | print("People can connect to this site by going to www." ..nw.. "")
| |
| 61 | print("You can edit this site by going to www." ..nw.. "/editor/" ..idd)
| |
| 62 | id, message = rednet.receive() | |
| 63 | if message == "www." ..nw.. "" then -- If someone tries to connect, it will send back the website | |
| 64 | sleep(1) | |
| 65 | rednet.send(id, line1) | |
| 66 | rednet.send(id, line2) | |
| 67 | rednet.send(id, line3) | |
| 68 | rednet.send(id, line4) | |
| 69 | rednet.send(id, line5) | |
| 70 | elseif message == "www." ..nw.. "/editor/" ..idd then -- If someone tries to connect, it will send back the website | |
| 71 | sleep(1) | |
| 72 | rednet.send(id, "epanst") | |
| 73 | else | |
| 74 | line1 = message | |
| 75 | id, message = rednet.receive() | |
| 76 | line2 = message | |
| 77 | id, message = rednet.receive() | |
| 78 | line3 = message | |
| 79 | id, message = rednet.receive() | |
| 80 | line4 = message | |
| 81 | id, message = rednet.receive() | |
| 82 | line5 = message | |
| 83 | end | |
| 84 | drawScreen() | |
| 85 | end | |
| 86 | ||
| 87 | function drawScreen() | |
| 88 | term.clear() | |
| 89 | term.setCursorPos(1,1) | |
| 90 | ||
| 91 | cPrint("Rednet Explorer 1.2")
| |
| 92 | ||
| 93 | cPrint("rdnt://"..website)
| |
| 94 | ||
| 95 | print("")
| |
| 96 | ||
| 97 | if website == "www.newsite.com" then | |
| 98 | newsite() | |
| 99 | elseif website == "www.newsite.com/nsite/index.php?/" then | |
| 100 | newsite2() | |
| 101 | else | |
| 102 | write("Port:")
| |
| 103 | port = read() | |
| 104 | port2 = port | |
| 105 | port3 = port2 / 32 | |
| 106 | end | |
| 107 | ||
| 108 | ||
| 109 | print("")
| |
| 110 | ||
| 111 | if website == "www.newsite.com" then | |
| 112 | write("www.")
| |
| 113 | nw = read() | |
| 114 | newsite = nw | |
| 115 | website = "www.newsite.com/nsite/index.php?/" | |
| 116 | drawScreen() | |
| 117 | end | |
| 118 | end | |
| 119 | ||
| 120 | drawScreen() |