Posted 14 October 2012 - 10:56 PM
Sit the turtle down on a layer in front of a hole with a clearly defined edge, and this turtle should fill it.
But it won't run.
ERROR is:
bios:206: [string "fillarea"]:42:'then' expected
I looked at all of my IF statements, and they all seem to have a THEN with them, so I do not see the problem, Perhaps your keen eyes or mind will see it?
But it won't run.
ERROR is:
bios:206: [string "fillarea"]:42:'then' expected
I looked at all of my IF statements, and they all seem to have a THEN with them, so I do not see the problem, Perhaps your keen eyes or mind will see it?
--[[ Program name : fillarea
Put this program in front of an unfilled hole in the ground
(with a defined edge on the layer the turtle is sitting on),
it should fill it with dirt then return to starting position.
--]]
--[[ Be sure the turtles has the following items
in the correct slots...
slot 13 has 64 coal/charcoal
other slots (at least 1) has filler (dirt/etc)
--]]
function refuel()
fuellvl = turtle.getFuelLevel()
if fuellvl<100 then
amtchar = turtle.getItemCount(13)
if amtchar > 1 then
turtle.select(13)
turtle.refuel(2)
turtle.select(1)
else
if amtchar > 0 then
turtle.select(13)
turtle.refuel(1)
turtle.select(1)
end
end
end
end
function fillerCheck()
fillerFlag = 0
for X = 1,16 do
turtle.select(X)
if fillSlot == 13 then
fillSlot = 14
end
if turtle.getItemCount(X) > 0 then
fillerFlag = 1
end
end
if fillerFlag = 0 then
print "Out of Filler"
end
end
function moveLeft()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
colModifier = colModifier - 1
end
function moveRight()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
colModifier = colModifier + 1
end
function moveForward()
turtle.forward()
rowModifier = rowModifier + 1
end
function moveBack()
turtle.back()
rowModifier = rowModifier - 1
end
function moveSide()
if lookingLeft = 1 then
moveLeft()
else
moveRight()
end
end
function moveRecenter()
while colModifier < 0 do
moveRight()
end
while colModifier > 0 do
moveLeft()
end
end
function moveRecenterRow()
while rowModifier < 0 do
moveForward()
end
while rowModifier > 0 do
moveBack()
end
end
function fillHole()
--[[ move down as far as it can --]]
while not turtle.detectDown() do
refuel()
turtle.down()
downMoves = downMoves + 1
end
--[[ move up and fill --]]
while downMoves > 0 do
refuel()
turtle.up()
fillerCheck()
if fillerFlag = 1 then
while not turtle.placeDown() do
fillSlot = fillSlot + 1
if fillSlot == 13 then
fillSlot = 14
end
turtle.select(fillSlot)
end
turtle.placeDown()
end
downMoves = downMoves - 1
end
recentFillCol = 1
recentFillRow = 1
end
--[[ set numeric var's --]]
fuellvl = 0
amtchar = 0
fillerFlag = 0
downMoves = 0
X = 0
fillSlot = 1
rowModifier = 0
colModifier = 0
searchOver = 0
lookingLeft = 1
recentFillCol = 0
recentFillRow = 0
--[[ move forward one --]]
refuel()
turtle.forward()
rowModifier = rowModifier + 1
while searchOver = 0 and fillerFlag <> 0 do
if not turtle.detectDown() then
fillHole()
moveSide()
else
--[[ no hole directly under --]]
if recentFillCol = 1 then
--[[ there is no hole under AND the spot on the side WAS filled as well --]]
moveSide()
else
--[[ there is no hole under AND the spot on the side was NOT filled as well --]]
if lookingLeft = 1 then
moveRecenter()
lookingLeft = 2
recentFillCol = 1 --[[ NOT SURE IF THIS IS NECESSARY --]]
else
moveRecenter()
if recentFillRow = 1 then
moveForward()
lookingLeft = 1
recentFillRow = 0
else
--[[ you are done with the filling of the hole --]]
searchOver = 1
end
end
end
recentFill = 0
end
end
moveRecenter()
moveRecenterRow()