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

My Internet, Something Went Wrong!

Started by DarkNinja2462, 07 April 2012 - 12:32 AM
DarkNinja2462 #1
Posted 07 April 2012 - 02:32 AM
I made an api and something went wrong.

Here is my code:

rednet.open("right")
function server( sPath )
while true do
  local event, nId, message = os.pullEvent()
  if event == "rednet_message" then
   fs = io.open(sPath..message..".txt", "r")
   page = fs:read("*a")
   fs:close()
   rednet.send(nId, page)
  end
end
end
function client( SCID, sPage )
rednet.send(SCId, sPage)
id, message = rednet.receive(5)
return message
end

Here is the error:

internet:1: attempt to index ? (a nil value)
I don't know where the error is.
Luanub #2
Posted 07 April 2012 - 03:22 AM
Is there more to the code? You probably just need to define sPath prior to the function.
cant_delete_account #3
Posted 07 April 2012 - 04:38 AM
Is there more to the code? You probably just need to define sPath prior to the function.

internet:1: attempt to index ? (a nil value)
internet:1:

It's line one. On rednet.open()
Luanub #4
Posted 07 April 2012 - 05:01 AM
Is there more to the code? You probably just need to define sPath prior to the function.

internet:1: attempt to index ? (a nil value)
internet:1:

It's line one. On rednet.open()

Not necessarily, the line it reports is not always the offending line.

The rednet.open("right") is correct as long as there is a bundled cable or modem attached to that side of the computer.


Hmmmm I realized this is an API… Try moving the rednet.open() into the function, or just remove it from the API and add it to the program.
Wolvan #5
Posted 07 April 2012 - 11:35 AM
Somehow you can't really use other APIs (often) in an custom API. For example shell.run("clear") isn't working either