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

[lua] [string "wood"]:5:unexpected symbol [autotreefarm]

Started by Ustabil2, 01 October 2012 - 09:36 PM
Ustabil2 #1
Posted 01 October 2012 - 11:36 PM
i'm having a problem finding the errors :S and yes its a treefarm named wood… (edit fixed it :)/>/> and now it needs a redstone current to start :(/>/> sweet )


function hasItPower()
if redstone.getInput("back", true) then
  checkSaplingSupply()
else
  sleep(5)
end
end

function checkSaplingSupply()
turtle.select(2)
if turtle.getItemCount(2) > 0 then
  logg()
elseif turtle.getItemCount(2) > 0 then
  turtle.select(1)
  sleep(2)
  checkSaplingSupply()
end
end

function logg()
for i=1,6 do
  work()
end
  attFem()
  sleep(20)
end

function work()
framFem()
turtle.turnRight()
if turtle.detect() then
  turtle.select(1)
  cut()
elseif not turtle.detect() then
  turtle.turnLeft()
end
end

function framFem()
for i=1,5 do
  turtle.forward()
end
end

function attFem()
for i=1,30 do
  turtle.back()
end
end

function cut()
turtle.select(1)
turtle.dig()
turtle.forward()
turtle.digDown()
turtle.select(2)
turtle.placeDown()
while turtle.detectUp() do
  goHigh()
end
goDown()
end

function goHigh()
turtle.select(1)
turtle.digUp()
turtle.up()
end

function goDown()
while not turtle.detectDown() do
  turtle.down()
end
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.select(1)
turtle.drop()
turtle.turnRight()
end

while true do
hasItPower()
end
Edited on 02 October 2012 - 07:13 AM
Cranium #2
Posted 01 October 2012 - 11:40 PM

else not turtle.getItemCount(2) > 0 then
--should be
elseif not turtle.getItemCount(2) > 0 then
I haven't looked at any of your other code, but that's the error you're currently getting. Line 5 of program "wood"(weird name, i say), error: unexpected symbol(not turtle.getItemCount(2) >0).
MysticT #3
Posted 01 October 2012 - 11:46 PM
And it would be better to only use else, since the conditions are exclusive (if the first condition is false, the second will always be true).
Ustabil2 #4
Posted 02 October 2012 - 07:56 AM
thanks :)/>/> it's my first treefarm program for a turtle. then again it's my first program ever :(/>/>

it cuts a row of 6 trees then returns.. (until somthing happend whit the goDown function :S ) it was ment to do drop the items in (1) then go tu next tree.. now if tree is there it cuts it, goes down to the stide of the tree as normal. then drops the item goes down again to the floor and goes around in a circle digs the dirt block for the tree then keeps on going i circles :S
Edited on 02 October 2012 - 05:57 AM
Ustabil2 #5
Posted 02 October 2012 - 09:02 AM
thanks :)/>/> it's my first treefarm program for a turtle. then again it's my first program ever :(/>/>

it cuts a row of 6 trees then returns.. (until somthing happend whit the goDown function :S ) it was ment to do drop the items in (1) then go tu next tree.. now if tree is there it cuts it, goes down to the stide of the tree as normal. then drops the item goes down again to the floor and goes around in a circle digs the dirt block for the tree then keeps on going i circles :S

fixed it… remowed getSapling()