I'm not sure exactly what the problem is, but I find this part suspicious:
port2 = 0
port3 = port2 / 32
[spoiler]
[s]
Port3 will always become 0. You will need to calculate Port3 every time you change port2.
You also don't need to re-defined cPrint every time you make a function, you can just put it above these functions, and they will all be able to use it:
local function cPrint() end
function functionThatUsescPrint() end
function otherFunctionThatUsescPrint() end
...
And, there's this:
...
port = read()
port2 = port
loadwebpage()
...
At loadwebpage:
id, message = rednet.receive()
if message == "www." ..nw.. ".com" then -- If someone tries to connect, it will send back the website
rednet.send(id, "If you see this message your connected")
It looks like the computer will just freeze trying to recieve rednet data when you do that.
In addition to that, I'd reccomend not using all these global variables, since you don't really need them:
homepage = "home";
website = "home";
nw = "";
idd = os.computerID()
port1 = idd * 32
port2 = 0
port3 = port2 / 32
You can change it to:
local homepage = "home";
local website = "home";
local nw = "";
...
I changed the code to:
local homepage = "home";
local website = "home";
local nw = "";
local idd = os.computerID()
local port1 = idd * 32
local port2 = 0
local port3 = port2 / 32
rednet.open("right")
local function cPrint(text)
local x,y = term.getSize()
local x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
print(text)
end
function home()
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")
print("Host a website at: ")
print("www.newsite.com! ")
print(" -ComputerCraftFan11 ")
end
function newsite()
cPrint("Rednet Site Manager")
print("")
print("Welcome to the rednet site manager!")
print("To make a new website, enter a domain name (.com will be added for you.):")
end
function newsite2()
cPrint("Rednet Site Manager")
print("")
print("People can connect to this site by going to www." ..nw.. ".com")
print("You can edit this site by going to www." ..nw.. ".com/editor")
print("Your port is " ..port1)
end
function loadwebpage()
id, message = rednet.receive()
if message == "www." ..nw.. ".com" then -- If someone tries to connect, it will send back the website
rednet.send(id, "If you see this message your connected")
end
print (message)
end
function drawScreen()
term.clear()
term.setCursorPos(1,1)
cPrint("Rednet Explorer 1.1")
cPrint("rdnt://"..website)
print("")
if website == "home" then
home()
elseif website == "www.newsite.com" then
newsite()
print("")
write("www.")
nw = read()
newsite = nw
website = "www.newsite.com/nsite/index.php?/"
drawScreen()
elseif website == "www.newsite.com/nsite/index.php?/" then
newsite2()
else
print("")
write("Goto:")
address = read()
website = address
rednet.send(port3, website)
write("Port:")
port = read()
port2 = port
port3 = port2 / 32
drawScreen()
loadwebpage()
end
end
drawScreen()
And it still freezes at:
id, message = rednet.receive()
Because I know that when you do this, it stops the program and stuff until you get a message.
So its getting a problem somewhere at:
rednet.send(port3, website)
EDIT:
At
print("")
write("Goto:")
address = read()
website = address
rednet.send(port3, website)
write("Port:")
port = read()
port2 = port
port3 = port2 / 32
drawScreen()
loadwebpage()
I changed it to:
print("")
write("Goto:")
address = read()
website = address
write("Port:")
port = read()
port2 = port
port3 = port2 / 32
rednet.send(port3, website)
drawScreen()
loadwebpage()
But it still doesn't work
Oops, i broke it
New code:
local homepage = "home";
local website = "home";
local nw = "";
local idd = os.computerID()
local port1 = idd * 32
local port2 = 0
local port3 = port2 / 32
rednet.open("right")
local function cPrint(text)
local x,y = term.getSize()
local x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
print(text)
end
function home()
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")
print("Host a website at: ")
print("www.newsite.com! ")
print(" -ComputerCraftFan11 ")
end
function newsite()
cPrint("Rednet Site Manager")
print("")
print("Welcome to the rednet site manager!")
print("To make a new website, enter a domain name (.com will be added for you.):")
end
function newsite2()
cPrint("Rednet Site Manager")
print("")
print("People can connect to this site by going to www." ..nw.. ".com")
print("You can edit this site by going to www." ..nw.. ".com/editor")
print("Your port is " ..port1)
end
function loadwebpage()
id, message = rednet.receive()
if message == "www." ..nw.. ".com" then -- If someone tries to connect, it will send back the website
rednet.send(id, "If you see this message your connected")
end
print (message)
end
function drawScreen()
term.clear()
term.setCursorPos(1,1)
cPrint("Rednet Explorer 1.1")
cPrint("rdnt://"..website)
print("")
if website == "home" then
home()
elseif website == "www.newsite.com" then
newsite()
elseif website == "www.newsite.com/nsite/index.php?/" then
newsite2()
else
write("Port:")
port = read()
port2 = port
port3 = port2 / 32
rednet.send(port3, website)
loadwebpage()
end
print("")
if website == "www.newsite.com" then
write("www.")
nw = read()
newsite = nw
website = "www.newsite.com/nsite/index.php?/"
drawScreen()
else
write("Goto:")
address = read()
website = address
drawScreen()
end
end
drawScreen()