Jump to content




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

turtle lua api

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

#1 Boldy97

  • New Members
  • 9 posts

Posted 06 August 2012 - 03: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)
Posted Image


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







#2 inventor2514

  • Members
  • 63 posts

Posted 06 August 2012 - 04:15 PM

if d=4 then
should be
if d==4 then


#3 Boldy97

  • New Members
  • 9 posts

Posted 06 August 2012 - 04:58 PM

View Postinventor2514, on 06 August 2012 - 04:15 PM, said:

if d=4 then
should be
if d==4 then

Thanks! I would've never found that... SIlly Lua :P/>

#4 Kolpa

  • New Members
  • 260 posts
  • LocationGermany

Posted 06 August 2012 - 06:24 PM

View PostBoldy97, on 06 August 2012 - 04:58 PM, said:

View Postinventor2514, on 06 August 2012 - 04:15 PM, said:

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)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users