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

Number Expected Error

Started by meeko011, 18 September 2013 - 02:49 PM
meeko011 #1
Posted 18 September 2013 - 04:49 PM
I made a program for a turtle to turn gravel into flint. It worked fine until the part where it drops all but one flint into a chest above it.

turtle.select(1)
gravel = turtle.getItemCount(1)
while true do
turtle.place()
turtle.dig()
gravel = turtle.getItemCount(1)
if tonumber(gravel) < 1 then
  turtle.select(16)
  while turtle.getItemCount() < 1 do
   turtle.dropUp(1)
  end
  turtle.select(1)
  os.reboot()
end
end

The exact error was: gravel :9: Expected number
theoriginalbit #2
Posted 18 September 2013 - 04:50 PM
As can be seen on the wiki turtle.getItemCount requires the slot number to get the count of
meeko011 #3
Posted 18 September 2013 - 10:00 PM
Thanks.
kreezxil #4
Posted 18 September 2013 - 10:11 PM
Also you don't need
tonumber(gravel)
as gravel is already a number simply use
if gravel < 1 then
.