Posted 04 October 2013 - 04:17 PM
I wrote a lumber program and I can't find the end that it's talking about.
bios:337: [string "lumber"]:275: 'end' expected (to close 'function' at line 38)
Code:
bios:337: [string "lumber"]:275: 'end' expected (to close 'function' at line 38)
Code:
x = 0
function chop()
while turtle.detect do
turtle.dig()
turtle.digUp()
turtle.up()
x = x + 1
end
for i = 1,x do
turtle.down()
end
x = 0
end
function collect()
turtle.suck()
turtle.forward()
for i = 1,4 do
turtle.suck()
turtle.turnRight()
end
turtle.back()
turtle.suck()
end
function replant()
turtle.select(15)
turtle.place()
end
function refuel()
if turtle.getFuelLevel < 30 then
turtle.select(15)
turtle.refuel(4)
end
end
function refill()
if turtle.getItemCount(16) < 16 then
for i = 1,14 do
turtle.select(i)
if turtle.compareTo(16) then
turtle.drop(4)
turtle.select(16)
turtle.suck()
break
end
end
end
if turtle.getItemCount(15) < 16 then
for i = 1,14 do
turtle.select(i)
if turtle.compareTo(15) then
turtle.drop(4)
turtle.select(15)
turtle.suck()
break
end
end
end
function clear()
for i = 1,4 do
turtle.dig()
turtle.forward()
end
turtle.turnRight()
for i = 1,4 do
turtle.dig()
turtle.forward()
end
for i = 1,3 do
turtle.turnRight()
for i = 1,8 do
turtle.dig()
turtle.forward()
end
end
turtle.turnRight()
for i = 1,4 do
turtle.dig()
turtle.forward()
end
for i = 1,4 do
for i = 1,4 do
turtle.dig()
turtle.forward()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
for i = 1,4 do
turtle.dig()
turtle.forward()
end
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
for i = 1,4 do
turtle.forward()
end
for i = 1,4 do
for i = 1,4 do
turtle.dig()
turtle.forward()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
for i = 1,4 do
turtle.dig()
turtle.forward()
end
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
for i = 1,4 do
turtle.forward()
end
turtle.turnRight()
for i = 1,4 do
turtle.forward()
end
turtle.turnRight()
turtle.turnRight()
end
function setup()
turtle.turnRight()
turtle.turnRight()
turtle.select(14)
turtle.place()
if turtle.getItemCount(13) < 6 then
print("Less than required monitors required, continuing on standard mode.")
sleep(2)
end
if turtle.getItemCount(13) == 6 then
turtle.up()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.turnRight()
turtle.select(13)
turtle.place()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.place()
turtle.up()
turtle.place()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.place()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.place()
turtle.down()
turtle.place()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
for i = 1,2 do
turtle.up()
end
turtle.forward()
for i = 1,3 do
turtle.down()
end
end
end
function key()
print("Press any key to continue")
end
function clearS()
term.clear()
term.setCursorPos(1,1)
end
function mClear()
m.clear()
m.setCursorPos(1,1)
end
function press(p)
key()
while true do
if os.pullEvent("key") then
clearS()
print(p)
break
end
end
end
function countWood()
for i = 1,14 do
turtle.select(i)
if turtle.compareTo(16) then
wood = turtle.getItemCount(i) + wood
end
end
end
function dropOff()
turtle.turnRight()
turtle.turnRight()
for i = 1,14 do
turtle.drop()
end
turtle.turnRight()
turtle.turnRight()
end
function showWood()
clearS()
print("So far I have collected " .. wood .. ".")
if input == y then
turtle.turnRight()
turtle.turnRight()
turtle.up()
m.clear()
m.write("So far I have collected " .. wood .. ".")
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.down()
end
end
m = peripheral.wrap("front")
print("Thank you for using Meeko's Lumber Program!")
p = "Put 16 Birch, Spruce, or Jungle saplings in the 15th slot."
press(p)
p = "Put at least 8 wood of the same type into the 16th slot."
press(p)
p = "Put a chest into the 14th slot and *Optional* 6 monitors into the 13th."
press(p)
clearS()
print("Does the area around the turtle need to be cleared? y/n")
y = true
n = false
input = read()
if input == y then
clear()
end
while true do
replant()
turtle.up()
while true do
if turtle.detect then
turtle.down()
chop()
break
end
end
countWood()
refill()
refuel()
dropOff()
showWood()
end