This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DarkNinja2462's profile picture

[Lua][Error]My Internet, Something Went Wrong!

Started by DarkNinja2462, 14 March 2012 - 11:15 PM
DarkNinja2462 #1
Posted 15 March 2012 - 12:15 AM
Well, I decided to make the Internet. Client/Server style. I use modems and the modems are on the right side.
I made a flie on the server comp called derp.txt and it has:
Spoiler

herp
derp
What I typed:
Spoiler

Server computer:
server
Client computer
client 1 derp
Error:
Spoiler

No error in server.
Client error:
client:18: attempt to index ? (a nil value)
Client program:
Spoiler

local tArgs = {...}
sCId = tArgs[1]
nPage = tArgs[2]
function c()
term.clear()
term.setCursorPos(1,1)
end
if #tArgs ~= 2 then
error("Usage: client <SCid> <page/list>")
else
c()
rednet.open("right")
CId = tonumber(sCID)
rednet.send(CId, nPage)
print("Connecting...")
id, message = redent.recieve(5)
c()
if message == nil then
  print("Connection Error")
end
print(message)



end
Server program:
Spoiler

local tArgs = {...}
sCId = tArgs[1]
nPage = tArgs[2]
function c()
term.clear()
term.setCursorPos(1,1)
end
rednet.open("right")
function mm()
while true do
local event, sId, message = os.pullEvent()
if event == "rednet_message" then
  id = tonumber(sId)
  fs = io.open("/server/"..message..".txt", "r")
  page = fs:read("*a")
  fs:close()
  rednet.send(id, page)
end
end
end
mm()
I DONT KNOW WHAT I DID WRONG
Casper7526 #2
Posted 15 March 2012 - 12:29 AM
redent.recieve(5)
DarkNinja2462 #3
Posted 15 March 2012 - 09:28 PM
Ok I fixed it.
P.S. it is also rednet.receive() not rednet.receive
I finished my internet program too!!!!!!!
CHECK IT OUT