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

Issues with using variables with turtle.dropDown

Started by iiAnderson, 05 July 2013 - 01:31 PM
iiAnderson #1
Posted 05 July 2013 - 03:31 PM
I am looking at making a retrieval system using ComputerCraft, using both turtles and computers together to retrieve the items that are sent for and sending them to a certain pick up chest. I have made it so that you can enter the value for the block/item and an amount of the selected item/block but have encountered an issue with the turtle.dropDown() method. All of the information is sent from the computer to the turtle, and the turtle receives the info and processes it just fine but when the turtle is told to drop the items into the chest it generates a Turtle:18: Expected number error. Here is the script for the turtle; http://pastebin.com/0NMHd5Lf. All of the script is executed fine (http://gyazo.com/f9d...4caf887ad165ab6) and the computer definitely knows the value of i (As it prints it within the script), but it wont work when in turtle.dropDown. Can you just not use variables in this situation, is there some other way around it or is it just a bug within the turtle api?

Thanks for any help on the subject, I have a feeling that you just cant use variables within the method, but I thought I'd just check to make sure :)/>
Lyqyd #2
Posted 05 July 2013 - 07:59 PM
Split into new topic.
verdult #3
Posted 09 July 2013 - 04:15 AM
it sais turtle expected number on line 18, you only have 8 line's in this script. Is this the right script?
GopherAtl #4
Posted 09 July 2013 - 10:49 AM
The error is thrown by the turtle API, not the program itself. This means somewhere you call a turtle method that expects a number, and either pass it nil or some other data type instead. That can only be turtle.dropDown, so check that rec.b is actually a number, not a string? You can check by changing "print(i)" to "print(type(i).."="..i)". If its a string, you'll want to us tonumber(i) to make it into a number first. This should probably happen in the other program before its sending the message at all, so it can detect invalid input and report errors at its end.