8 posts
Posted 23 March 2014 - 01:00 AM
So I've been getting into computercraft again, and while making an automatic obsidian generator program I ran into some issues.
This is my code:
if turtle.getItemSpace(2) >= input then
for i=1,amount do
place()
button()
mine()
end
else
print("Not enough redstone!")
end
I'm always getting one of two errors: "Attempt to call table" or "Attempt to compare __le on table and string." For reference, I'm keeping redstone in slot 2 and trying to make sure there is enough of it for the obsidian request.
Edited on 23 March 2014 - 12:01 AM
1281 posts
Posted 23 March 2014 - 01:06 AM
Post the functions and the error line numbers as well.
8 posts
Posted 23 March 2014 - 01:10 AM
Entire code
here and both errors occur on line 42
Edited on 23 March 2014 - 12:13 AM
2151 posts
Location
Auckland, New Zealand
Posted 23 March 2014 - 01:13 AM
My bet would be that you've set one of these:
place()
button()
mine()
To something like '{}' somewhere else in your code.
But please post your entire code.
Edit: Sorry, the above post didn't show up when I was writing. CometWolf's post looks correct though.
Edited on 23 March 2014 - 12:19 AM
1281 posts
Posted 23 March 2014 - 01:13 AM
it's weird, there's nothing related to tables here
input = read()
amount = input/3
if turtle.getItemCount(2) <= input then
However, read() always returns a string, so using tonumber to convert it to a number is probably a good idea.
input = tonumber(read())
Edited on 23 March 2014 - 12:15 AM
8 posts
Posted 23 March 2014 - 01:14 AM
I suppose I should also note I'm using CC 1.56 EDIT: I have tried that fix, but I'm still getting an "Attempt to call table" error on line 42
Edited on 23 March 2014 - 12:16 AM
1281 posts
Posted 23 March 2014 - 01:20 AM
And your not running any other programs prior to this? Try rebooting the turtle and running your program directly if so.
2151 posts
Location
Auckland, New Zealand
Posted 23 March 2014 - 01:22 AM
I suppose I should also note I'm using CC 1.56 EDIT: I have tried that fix, but I'm still getting an "Attempt to call table" error on line 42
Right before line 42 do:
print(turtle.getItemCount)
If what it writes contains 'table' then I'm really don't know. If it says 'function' it shouldn't be giving that error.
8 posts
Posted 23 March 2014 - 01:22 AM
Rebooting it worked, thanks! :D/>
331 posts
Posted 23 March 2014 - 01:23 AM
-snip-
Edited on 23 March 2014 - 12:26 AM
2151 posts
Location
Auckland, New Zealand
Posted 23 March 2014 - 01:35 AM
Rebooting it worked, thanks! :D/>
You probably modified the function, make sure you avoid doing touching default APIs.