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

[Lua] [Error] turtle:18:expected number

Started by lordxarus, 06 February 2013 - 07:52 AM
lordxarus #1
Posted 06 February 2013 - 08:52 AM
I am making a program that farms trees. I am adding a part to that checks if there are any more saplings. I am fairly new to lua but I have tried to fix the error myself and can't.

Code:

local bExit = false
local function checkItems()
   turtle.select(1)
   turtle.compareTo(15)
	  if turtle.compareTo() == false then
	  bExit = true
	  else
    end
end
local function plantTree()
   turtle.select(1)
   turtle.place()
   turtle.select(2)
   turtle.place()
end
local function cutTree()
   turtle.dig()
   turtle.forward()
   turtle.suck()
   turtle.digUp()
   turtle.suck()
   turtle.up()
   turtle.digUp()
   turtle.suck()
   turtle.up()
   turtle.digUp()
   turtle.suck()
   turtle.up()
   turtle.digUp()
   turtle.suck()
   turtle.up()
   turtle.digUp()
   turtle.suck()
   turtle.up()
   turtle.digUp()
   turtle.suck()
   turtle.up()
   turtle.digUp()
   turtle.suck()
end
local function returnToStart()
  turtle.down()
  turtle.down()
  turtle.down()
  turtle.down()
  turtle.down()
  turtle.down()
  turtle.down()
  turtle.back()
end
while not bExit do
checkItems()
plantTree()
cutTree()
returnToStart()
end
Lyqyd #2
Posted 06 February 2013 - 08:58 AM
Split into new topic.

Is this the exact code you're using? I doubt very much if it is. This line is likely the problem (though it isn't line 18, hence my doubt about this being the exact code):

if turtle.compareTo() == false then

You are not providing the numeric argument, hence the error.
lordxarus #3
Posted 06 February 2013 - 09:07 AM
OH wow thanks. So this the exact code I am using Notepad++ to edit and it was copied from that so I am sure the line encoding got a little messed up. Anyway thanks again great mod guys.