71 posts
Posted 05 February 2015 - 07:45 PM
I have multiple computers connected together and I have one that is called a router.
I am trying to use the modem API to write data to a file however I get an error that I don't really understand. I have encountered it many times but I don't understand how it is applicable here. I get the error on the server.
Files
Edited on 05 February 2015 - 06:45 PM
7083 posts
Location
Tasmania (AU)
Posted 05 February 2015 - 08:49 PM
The error is stating that on the 24th line of the router script, you attempted to index into an object as if it were a table - only it's not a table, it's nil, and so you can't do that.
ev is a table - it has to be, because your get() function will only return once it has a valid modem message - but ev[5] isn't. This is because your client has "data" set to nil when it attempts to send it, due to the variable being localised in the wrong scope within the client script. Use a forward declaration:
local data
if opened == true then
data = {"LOG_BANK",true,ev[3]}
opened = false
else
data = {"LOG_BANK",false}
end
rou.send(data)
See
this guide for more information.
71 posts
Posted 05 February 2015 - 09:14 PM
The error is stating that on the 24th line of the router script, you attempted to index into an object as if it were a table - only it's not a table, it's nil, and so you can't do that.
ev is a table - it has to be, because your get() function will only return once it has a valid modem message - but ev[5] isn't. This is because your client has "data" set to nil when it attempts to send it, due to the variable being localised in the wrong scope within the client script. Use a forward declaration:
local data
if opened == true then
data = {"LOG_BANK",true,ev[3]}
opened = false
else
data = {"LOG_BANK",false}
end
rou.send(data)
See
this guide for more information.
First of all. 2,799 posts. Let's make that 2,800 :D/>
Second of all, I need to include 'local data'?
7083 posts
Location
Tasmania (AU)
Posted 05 February 2015 - 09:16 PM
Call this 2,800 then. :P/>
Yes, you should pre-declare data - while more importantly, also removing the local keyword from within your "if" blocks.