Posted 14 May 2015 - 02:55 AM
Not sure why but it's giving me this error… I've read it over at least 20 times scratching my head.
ERROR: bios:366: [string "berry"]:181: 'end' expected (to close 'while' at line 162)
ERROR: bios:366: [string "berry"]:181: 'end' expected (to close 'while' at line 162)
Spoiler
local x = 0 --home x of the turtle
local z = 0 --home z of the turtle
local dir = "x-" --x+,z-,z+
local fx = 23
local fz = 4
local harvesting = false
function up()
turtle.up()
end
function down()
turtle.down()
end
function forward()
turtle.forward()
if dir=="x-" then
x=x-1
end
if dir=="x+" then
x=x+1
end
if dir=="z-" then
z=z-1
end
if dir=="z+" then
z=z+1
end
end
function tr()
turtle.turnRight()
if dir=="x-" then
dir="z-"
end
if dir=="x+" then
dir="z+"
end
if dir=="z-" then
dir=x"+"
end
if dir=="z+" then
dir="x-"
end
end
function tl()
turtle.turnLeft()
if dir=="x-" then
dir="z+"
end
if dir=="x+" then
dir="z-"
end
if dir=="z-" then
dir="x-"
end
if dir=="z+" then
dir="x+"
end
end
function back()
turtle.back()
if dir=="x-" then
x=x+1
end
if dir=="x+" then
x=x-1
end
if dir=="z-" then
z=z+1
end
if dir=="z+" then
z=z-1
end
end
function h()
local g = getGrowthDown()
if g==100 then
r=turtle.place()
if r==false then
turtle.digDown()
turtle.suckDown()
turtle.select(1)
turtle.place()
else
turtle.suckDown()
end
end
end
function start()
turtle.up()
sleep(1)
turtle.forward()
sleep(1)
harvesting=true
end
function goHome()
repeat
if dir=="x-" then
if x>0 then
forward()
end
end
if dir=="x+" then
if x>0 then
backward()
end
end
if dir=="z+" then
if z>0 then
forward()
end
end
if dir=="z-" then
if z>0 then
forward()
end
end
until x==0 and y==0
end
repeat
io.write("Should I start? [y/n]")
yn=io.read()
io.clear()
until yn=="y" or "n"
if yn=="y" then
harvesting=true
start()
end
if yn=="n" then
io.write("Exiting")
sleep(1)
io.reboot()
end
while harvesting==true do
h()
if z > fz then
goHome()
end
if x~=fx and x > 0 then
forward()
else
tr()
forward()
tr()
end
if x==0 then
tl()
forward()
tl()
end
until harvesting==false