我找不到遗漏的地方在哪里,我已经仔细检查了语法并再次检查了三遍,这让我很生气。我已经在线和本地测试了编译,所以我的具体问题是为什么会抛出错误?
这是错误:
line 71: 'end' expected (to close 'function' at line 25) near '< eof >'
这是代码:
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()
最佳答案
缺少一个end
在 checkFuel()
body ;它关闭了 while
堵塞。
-- 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
关于Lua 'end' 预期(在 'function' 附近的行关闭 '<eof>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23167890/