Posted 03 July 2016 - 10:00 PM
Hello everyone, I've been working on my turtle program for a bit and didn't test it in a while.
Now I'm getting the following error:
bios:14: [string "startup"]:114: 'end' expected (to close 'while' at line 47)
The error seems kind of obvious but having checked it out in notepad++ I cant for the life of me find out where I'm missing an end.
Can anyone else spot the (probably obvious) error in my code?
I know my code isn't perfect and I'd appreciate other random tips on the side if someone has some.
Thanks in advance!
Zalmfilet
Edit: Line 47 starts at –main work routine btw, I cut a few lines. Also sorry for dropping this question here, I've read the "read this before posting" but couldn't figure out my mistake.
Now I'm getting the following error:
bios:14: [string "startup"]:114: 'end' expected (to close 'while' at line 47)
The error seems kind of obvious but having checked it out in notepad++ I cant for the life of me find out where I'm missing an end.
Can anyone else spot the (probably obvious) error in my code?
--Initiate modem and set label
rednet.open("right")
rednet.host("turtleNet", "Farming" .. os.getComputerID())
rednet.broadcast("Farming started", "turtleAlert")
shell.run("label set Farmer")
turtle.select(1)
--Check for seeds
while true do
local data = turtle.getItemDetail()
if data ~= nil then
if data.name == "minecraft:wheat_seeds" and data.count == 64 then
break
elseif data.name == "minecraft:wheat_seeds" and data.count ~= 64 then
print("ERR: Insufficient seeds")
rednet.broadcast("ERR: insufficient seeds", "turtleAlert")
os.sleep(30)
else
print("ERR: Wrong item in slot #1")
rednet.broadcast("ERR: wrong item in slot #1", "turtleAlert")
os.sleep(30)
end
else
print("ERR: no item in slot 1")
rednet.broadcast("ERR: no item in slot #1", "turtleAlert")
os.sleep(30)
end
end
--Begin farm routine
while true do
--Positioning, checks for STOP block (wood planks)
while true do
local success, data = turtle.inspect()
if data.name == "minecraft:planks" then
turtle.turnLeft()
turtle.turnLeft()
break
else
turtle.turnLeft()
end
end
--Main work routine
while true do
--Left side
turtle.turnLeft()
local success, data = turtle.inspect()
if success then
if data.metadata == 7 then
turtle.dig()
turtle.place()
turtle.turnRight()
elseif data.metadata ~= 7 then
turtle.turnRight()
end
else
turtle.dig()
turtle.place()
turtle.turnRight()
end
turtle.turnRight()
--Right side
local success, data = turtle.inspect()
if success then
if data.metadata == 7 then
turtle.dig()
turtle.place()
turtle.turnLeft()
elseif data.metadata ~= 7 then
turtle.turnLeft()
end
else
turtle.dig()
turtle.place()
turtle.turnLeft()
end
--Check for STOP block
local success, data = turtle.inspect()
if data.name == "minecraft:planks" then
local success, data turtle.inspectUp()
--Check for chest (home)
if success and data.name == "minecraft:chest" then
--Drop items into upper chest
i = 1
while i <17 do
turtle.select(i)
turtle.dropUp()
i = i + 1
end
turtle.select(1)
--Check fuel level, withdraw fuel from lower chest and refuel if needed
if turtle.getFuelLevel() < 200 then
if turtle.suckDown() == true then
turtle.refuel()
else
print("ERR:No fuel left in chest")
rednet.broadcast("ERR: No fuel in chest", "turtleAlert")
os.sleep(30)
end
end
--Withdraw seeds from upper chest
turtle.suckUp()
end
end
rednet.broadcast("Task done, sleeping(600)", "turtleAlert")
os.sleep(10)
break
else
turtle.forward()
--end
end
end
I know my code isn't perfect and I'd appreciate other random tips on the side if someone has some.
Thanks in advance!
Zalmfilet
Edit: Line 47 starts at –main work routine btw, I cut a few lines. Also sorry for dropping this question here, I've read the "read this before posting" but couldn't figure out my mistake.
Edited on 04 July 2016 - 12:19 AM