Jump to content




Issues with turtle.getItemCount/Space


  • You cannot reply to this topic
10 replies to this topic

#1 pieisnotpi

  • Members
  • 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 by pieisnotpi, 23 March 2014 - 01:01 AM.


#2 CometWolf

  • Members
  • 1,283 posts

Posted 23 March 2014 - 01:06 AM

Post the functions and the error line numbers as well.

#3 pieisnotpi

  • Members
  • 8 posts

Posted 23 March 2014 - 01:10 AM

Entire code here and both errors occur on line 42

Edited by pieisnotpi, 23 March 2014 - 01:13 AM.


#4 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, 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 by oeed, 23 March 2014 - 01:19 AM.


#5 CometWolf

  • Members
  • 1,283 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 by CometWolf, 23 March 2014 - 01:15 AM.


#6 pieisnotpi

  • Members
  • 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 by pieisnotpi, 23 March 2014 - 01:16 AM.


#7 CometWolf

  • Members
  • 1,283 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.

#8 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 23 March 2014 - 01:22 AM

View Postpieisnotpi, on 23 March 2014 - 01:14 AM, said:

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.

#9 pieisnotpi

  • Members
  • 8 posts

Posted 23 March 2014 - 01:22 AM

Rebooting it worked, thanks! :D

#10 jay5476

  • Members
  • 289 posts

Posted 23 March 2014 - 01:23 AM

-snip-

Edited by jay5476, 23 March 2014 - 01:26 AM.


#11 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 23 March 2014 - 01:35 AM

View Postpieisnotpi, on 23 March 2014 - 01:22 AM, said:

Rebooting it worked, thanks! :D
You probably modified the function, make sure you avoid doing touching default APIs.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users