56 posts
Posted 29 January 2016 - 11:24 AM
I've been working on a remote and a control program for a while now and i've recently ran into
this error. the pastebin for the control program is
here and the remote's pastebin is
here.
To recreate the error with the programs, firstly have 2 seperate computers running each of the programs, next in the remote computer run "ls" and it should list available control computers to connect with. Once you have done this run "connect *id of the control computer that you want to connect with*" (the id is displayed in the list command). Then run "help" in the remote command line and it should display "no message received" (i have found that it sometimes errors and sometimes works and am not sure why).
Other information: I was running the control program with my
farmTurtle plugin aswell as my
minerTurtle plugin - i have tried printing out the help string with both plugins running in the control program and it has everything so i don't think it is the problem (although i could be wrong). I also tried using the other commands that the control program has and everything else works, its just the help command that seems to be erroring.
Edited on 29 January 2016 - 10:38 AM
2427 posts
Location
UK
Posted 29 January 2016 - 11:30 AM
For some reason, without looking at the code, I'm thinking that the script is trying to use the distance value which rednet had but replaced with the protocol system.
Will investigate properly.
Edit:
Other way round, script is using protocols and rednet can't do that?
What version of CC are you using?
Edited on 29 January 2016 - 10:33 AM
56 posts
Posted 29 January 2016 - 11:34 AM
For some reason, without looking at the code, I'm thinking that the script is trying to use the distance value which rednet had but replaced with the protocol system.
Will investigate properly.
Edit:
Other way round, script is using protocols and rednet can't do that?
What version of CC are you using?
I was using 1.74 when i got that error
2427 posts
Location
UK
Posted 29 January 2016 - 11:35 AM
Then it's neither of my suggestions.
I can decompose the error message for you.
rednet:87: Expected number
rednet is the name of the file which errored, this usually tells you the program but in this case it's the rednet API.
87 is the line number of the error.
Expected number is a description of the error, whatever was above line 87 did some data type checking and found that what should have been a number was some other type (such as a string or table)
if it needs saying, the
colons : are just separators
Edited on 29 January 2016 - 10:41 AM
56 posts
Posted 30 January 2016 - 02:42 PM
Then it's neither of my suggestions.
I can decompose the error message for you.
rednet:87: Expected number
rednet is the name of the file which errored, this usually tells you the program but in this case it's the rednet API.
87 is the line number of the error.
Expected number is a description of the error, whatever was above line 87 did some data type checking and found that what should have been a number was some other type (such as a string or table)
if it needs saying, the
colons : are just separators
was just playing around with it some more and it seems like when i try to load plugins that also have helps it errors when i try running the help command. I also know how error messages work & what they mean :P/>
56 posts
Posted 30 January 2016 - 02:54 PM
Then it's neither of my suggestions.
I can decompose the error message for you.
rednet:87: Expected number
rednet is the name of the file which errored, this usually tells you the program but in this case it's the rednet API.
87 is the line number of the error.
Expected number is a description of the error, whatever was above line 87 did some data type checking and found that what should have been a number was some other type (such as a string or table)
if it needs saying, the
colons : are just separators
was just playing around with it some more and it seems like when i try to load plugins that also have helps it errors when i try running the help command. I also know how error messages work & what they mean :P/>
after further testing i've found what i think is the problem, when i try printing the help in the help function (ln 61) it doesn't print out anything - not even a blank space so what i have done is where i have a test for if msg[1] == "exit" (ln 207) i have an elseif testing if msg[1] == "help"
7083 posts
Location
Tasmania (AU)
Posted 30 January 2016 - 03:28 PM
Which leads to a line with a missing bracket, apparently?
I took a look at the paste as it was a night or so ago, and didn't see anything which'd lead to the error. That and your latest upload make me wonder if I've actually seen a copy of the script which would've produced your original error.
Given your symptoms, I'm strongly suspecting that you've somehow messed up in terms of variable scope, or fed an incorrectly named variable into your original help function at some stage.
In any case,
this guide would be well worth a read.
56 posts
Posted 30 January 2016 - 05:10 PM
Which leads to a line with a missing bracket, apparently?
I took a look at the paste as it was a night or so ago, and didn't see anything which'd lead to the error. That and your latest upload make me wonder if I've actually seen a copy of the script which would've produced your original error.
Given your symptoms, I'm strongly suspecting that you've somehow messed up in terms of variable scope, or fed an incorrectly named variable into your original help function at some stage.
In any case,
this guide would be well worth a read.
been trying to use other functions and the same error message has been happening, i've also taken a read of the link and i knew it all already. but when i was just testing then i tried using upload then download then fileList and then move (from my minerTurtle plugin) and it errored at the move, but when i restarted and tried running fileList straight away, it errored.
Edited on 30 January 2016 - 04:12 PM
1023 posts
Posted 31 January 2016 - 01:10 AM
-snip
been trying to use other functions and the same error message has been happening, i've also taken a read of the link and i knew it all already. but when i was just testing then i tried using upload then download then fileList and then move (from my minerTurtle plugin) and it errored at the move, but when i restarted and tried running fileList straight away, it errored.
Little debugging trick you can use to find it. Unload the rednet api (set _G.rednet to nil). Copy rednet from the rom to anywhere not the rom, and make sure the name is still rednet. Go into the copied file, and anywhere in the beginning of the function that line 87 is in do error checking to see if the first argument is a number. If it is not then make the function error with some easily identifiable message, and with a level 3 (might be 4) return (don't really know what to call this). This will make it error on the line that the function is called, instead of inside the rednet function. Then just use os.loadAPI to load the rednet api and run your program. If it errors encounters the same problem it will error and tell you exactly which of your rednet.sends is causing the bug.
I would try and find the bug, but I am unable to reproduce the error. So you can try and do this and provide us with the information.
Little snippet of what you would insert into the rednet function:
if type(whatEverTheFirstVariableInTheFunctionIsCalled) ~= "number" then
error("This is the bad function call, number expected got" .. type(whatEverTheFirstVariableInTheFunctionIsCalled) ,3)
end
Edited on 31 January 2016 - 12:16 AM
56 posts
Posted 31 January 2016 - 10:14 AM
-snip
been trying to use other functions and the same error message has been happening, i've also taken a read of the link and i knew it all already. but when i was just testing then i tried using upload then download then fileList and then move (from my minerTurtle plugin) and it errored at the move, but when i restarted and tried running fileList straight away, it errored.
Little debugging trick you can use to find it. Unload the rednet api (set _G.rednet to nil). Copy rednet from the rom to anywhere not the rom, and make sure the name is still rednet. Go into the copied file, and anywhere in the beginning of the function that line 87 is in do error checking to see if the first argument is a number. If it is not then make the function error with some easily identifiable message, and with a level 3 (might be 4) return (don't really know what to call this). This will make it error on the line that the function is called, instead of inside the rednet function. Then just use os.loadAPI to load the rednet api and run your program. If it errors encounters the same problem it will error and tell you exactly which of your rednet.sends is causing the bug.
I would try and find the bug, but I am unable to reproduce the error. So you can try and do this and provide us with the information.
Little snippet of what you would insert into the rednet function:
if type(whatEverTheFirstVariableInTheFunctionIsCalled) ~= "number" then
error("This is the bad function call, number expected got" .. type(whatEverTheFirstVariableInTheFunctionIsCalled) ,3)
end
ok, i've just done a print in the
original rednet api on line 87 where i just print(sModem,nRecipient,nReplyChannel) (not tMessage because its a table) and the first few times it says: right 0 1 (right being the side that the modem is on, 0 being the id that im sending to and 1 being the id of the control computer) and then on the third one it says the nRecipient is nil which i don't know why it is happening because im pretty sure im always sending the rednet function the right id. It then errors on the next line with the rednet:88: Expected number (ln 88 because of the print that i have before it).
56 posts
Posted 31 January 2016 - 10:44 AM
-snip
been trying to use other functions and the same error message has been happening, i've also taken a read of the link and i knew it all already. but when i was just testing then i tried using upload then download then fileList and then move (from my minerTurtle plugin) and it errored at the move, but when i restarted and tried running fileList straight away, it errored.
Little debugging trick you can use to find it. Unload the rednet api (set _G.rednet to nil). Copy rednet from the rom to anywhere not the rom, and make sure the name is still rednet. Go into the copied file, and anywhere in the beginning of the function that line 87 is in do error checking to see if the first argument is a number. If it is not then make the function error with some easily identifiable message, and with a level 3 (might be 4) return (don't really know what to call this). This will make it error on the line that the function is called, instead of inside the rednet function. Then just use os.loadAPI to load the rednet api and run your program. If it errors encounters the same problem it will error and tell you exactly which of your rednet.sends is causing the bug.
I would try and find the bug, but I am unable to reproduce the error. So you can try and do this and provide us with the information.
Little snippet of what you would insert into the rednet function:
if type(whatEverTheFirstVariableInTheFunctionIsCalled) ~= "number" then
error("This is the bad function call, number expected got" .. type(whatEverTheFirstVariableInTheFunctionIsCalled) ,3)
end
ok, i've just done a print in the
original rednet api on line 87 where i just print(sModem,nRecipient,nReplyChannel) (not tMessage because its a table) and the first few times it says: right 0 1 (right being the side that the modem is on, 0 being the id that im sending to and 1 being the id of the control computer) and then on the third one it says the nRecipient is nil which i don't know why it is happening because im pretty sure im always sending the rednet function the right id. It then errors on the next line with the rednet:88: Expected number (ln 88 because of the print that i have before it).
I've found it!!!!!!!!!!!
in my minerTurtle plugin, i have a help function aswell that i accidently left in there - all fixed now. But thank you guys for the help! :D/>
7083 posts
Location
Tasmania (AU)
Posted 31 January 2016 - 11:09 AM
Since you've got such a good understanding of scope, I'm sure you can see how to make your script work even with such plugins present. ;)/>
56 posts
Posted 31 January 2016 - 11:43 AM
Since you've got such a good understanding of scope, I'm sure you can see how to make your script work even with such plugins present. ;)/>
do you mean like checking if it will work or not? like going through the plugins to see if they would work?
7083 posts
Location
Tasmania (AU)
Posted 31 January 2016 - 11:51 AM
What I'm getting at is that your script makes use of global variables exclusively. Any other scripts that place data into the global scope are prone to interfere.
If you localise all variables to your script, then other scripts can't touch them - whether or not they correctly localise their own variables.
56 posts
Posted 31 January 2016 - 12:03 PM
What I'm getting at is that your script makes use of global variables exclusively. Any other scripts that place data into the global scope are prone to interfere.
If you localise all variables to your script, then other scripts can't touch them - whether or not they correctly localise their own variables.
i have it intended that plugin's functions take priority over the default functions if that is what you mean, if you mean to just add local to all the variables i could probably do that though :P/>