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

[Lua] ~ [Error] ~ 'then' expected

Started by Boldy97, 06 August 2012 - 02:00 PM
Boldy97 #1
Posted 06 August 2012 - 04:00 PM
Allrighted, after my initial fail with a giant quarry I decided to make easy strip mining program.



The first slot of the turtle has chests and the second torches. Everything works fine untill I add an extra if/then situation at line 31-35, used to place torches every 8 blocks travelled.

It now says: " 'then' expected " at line 19

Thanks in advance,
Boldy97

This is what it's creating. the circles represents chests it places, the arrows the direction of travel.
The line on the right is done seperate, the rest is repeatable.
(This will probably make no sense at all)



PS: no more 'do' commands :P/>/> yeey!

function strip()
d=0
a=25
mijn()
turtle.back()
turtle.back()
turtle.select(1)
turtle.place()
b=3
drop()
turtle.up()
turtle.forward()
turtle.forward()
turtle.down()
turtle.turnLeft()
c=turtle.getItemCount(1)
mijn2()
end
function mijn()
if a>0
then
turtle.dig()
turtle.up()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.down()
turtle.dig()
turtle.forward()
a=a-1
d=d+1
if d=4 then
turtle.select(2)
turtle.placeUp()
d=0
end
mijn()
end
end
function mijn2()
if c>0 then
a=2
mijn()
turtle.turnLeft()
a=25
mijn()
turtle.turnLeft()
a=2
mijn()
turtle.back()
turtle.select(1)
turtle.place()
c=c-1
b=2
drop()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.forward()
a=2
mijn()
turtle.turnRight()
a=25
mijn()
turtle.turnRight()
a=2
mijn()
turtle.back()
turtle.select(1)
turtle.place()
c=c-1
b=2
drop()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.forward()
mijn2()
end
end
function drop()
if b<17 then
  turtle.select(;)/>/>
  turtle.drop()
  b=b+1
  drop()
  end
  end





inventor2514 #2
Posted 06 August 2012 - 05:15 PM
if d=4 then
should be
if d==4 then
Boldy97 #3
Posted 06 August 2012 - 05:58 PM
if d=4 then
should be
if d==4 then

Thanks! I would've never found that… SIlly Lua :P/>/>
Kolpa #4
Posted 06 August 2012 - 07:24 PM
if d=4 then
should be
if d==4 then

Thanks! I would've never found that… SIlly Lua :P/>/>
well its like that in a ton of languages (java/javascript,c,c++,lua,python,php)