I cannot find where the missing end is, iI have double checked and triple checked the syntax and its driving me mad. I have tested compilation online and locally so my specific question here is why is the error being thrown?
Here is the error:
line 71: 'end' expected (to close 'function' at line 25) near '< eof >'
Here is the code:
tArgs = { ... }
--Argument validation
if #tArgs < 2 then
printUsage()
return
end
--globals
local MAX_INV_SLOT = 16
local depth = tonumber(tArgs[1])
local bredth = tonumber(tArgs[2])
--Usage output
local function printUsage()
print("Usage: <branch depth> <num branches>")
end
--wrap turtle.forward()
local function fwd()
while turtle.forward() == false do
turtle.dig()
end
end
-- check / get fuels
local function checkFuel()
while turtle.getFuelLevel() == 0 do
for k=0, 16, 1 do
if turtle.refuel(i) then
return
end
end
return
end
--mine 1 wide 3 tall segment
local function step()
fwd()
turtle.digUp()
turtle.digDown()
end
local function control()
for i=0, bredth,1 do
for j=0, depth,1 do
checkFuel()
step()
end
-- Turn Corner
if (i % 2) == 0 then
step()
turtle.turnRight()
step()
step()
step()
turtle.turnRight()
else
-- Left U turn
step()
turtle.turnLeft()
step()
step()
step()
turtle.turnLeft()
end
end
print("Should be done!")
end
control()
There is a missing end
in the checkFuel()
body; it closes the while
block.
-- check / get fuels
local function checkFuel()
while turtle.getFuelLevel() == 0 do
for k=0, 16, 1 do
if turtle.refuel(i) then
return
end
end
return
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With