Posted 29 August 2012 - 04:45 PM
I am pretty much a beginner at Lua and ComputerCraft but I have some experience with Lua…
I am making a WiFi program for my friends server but i am having troubles. So far i have looked at the APIs and the ComputerCraft wiki and made it so you can see your messages and respond to them. Right now whenever you type in anything after the initial wifi (which is the programs name) it prints "Turn on your wifi." Please help i can not figure it out. I also realize some one probably had made this before and i could just take theirs but I want to do it myself. I am most likely going to post on this thread more asking for more help so please no hate.
term.clear()
term.setCursorPos(1,1)
local input = read()
–TurnOnWiFi
if input == "TurnOnWiFi" or input == "WiFiOn" then
print("Make sure your modem is on top of your computer or else it wont work. Thanks!")
rednet.open("top")
end
–SeeMessages
if rednet.open("top") == true then
repeat
local event,p1,p2,p3 = os.pullEvent
if event =="rednet_message" then
print("*Message* From: "..p1.."Message:"..p2)
print("To Message back type Respond")
end
until event =="char" and p1=="x"
–Respond
if input == "Respond" then
term.clear()
term.setCursorPos(1,1)
rednet.send(p1, input)
end
else
sleep(5)
print("Turn on your WiFi")
end
also the comments are mostly for me to see where the thing is happening.
I am making a WiFi program for my friends server but i am having troubles. So far i have looked at the APIs and the ComputerCraft wiki and made it so you can see your messages and respond to them. Right now whenever you type in anything after the initial wifi (which is the programs name) it prints "Turn on your wifi." Please help i can not figure it out. I also realize some one probably had made this before and i could just take theirs but I want to do it myself. I am most likely going to post on this thread more asking for more help so please no hate.
term.clear()
term.setCursorPos(1,1)
local input = read()
–TurnOnWiFi
if input == "TurnOnWiFi" or input == "WiFiOn" then
print("Make sure your modem is on top of your computer or else it wont work. Thanks!")
rednet.open("top")
end
–SeeMessages
if rednet.open("top") == true then
repeat
local event,p1,p2,p3 = os.pullEvent
if event =="rednet_message" then
print("*Message* From: "..p1.."Message:"..p2)
print("To Message back type Respond")
end
until event =="char" and p1=="x"
–Respond
if input == "Respond" then
term.clear()
term.setCursorPos(1,1)
rednet.send(p1, input)
end
else
sleep(5)
print("Turn on your WiFi")
end
also the comments are mostly for me to see where the thing is happening.