'elseif'附近的语法错误,'end'附近的语法错误,依此类推

时间:2015-08-29 10:38:29

标签: lua

这是我第一次尝试lua,所以我完全不熟悉它。 下面的代码部分是其他人的工作,部分由我自己完成。 标题显示我遇到了问题。有人可以帮我解决这些错误,并检查一下我是否还有其他错误?非常感谢!

bloodRound=600
hardRound=700

function main()  
while count<6000 do
fightEvil();
end   

function fightEvil()
count=count+1;

if isColor(40,495,15178484,90) then touchClick(40,495)
end

if isColor(75,410,8094051,90) then touchClick(75,410)
end

if round<=bloodRound then touchClick(110,230)
elseif round<= hardRound then touchClick(110,420)
else
touchClick(110,570)
end

if isColor(250,550,15721389,90) then touchClick(250,550)

elseif isColor(250,550,14044457,90) then touchClick(250,550)

elseif isColor(250,420,14570908,90) then touchClick(250,420)

elseif isColor(250,420,10251594,90) then touchClick(600,950)

elseif isColor(250,550,2202276,90) then touchClick(250,550)

elseif isColor(250,420,16769965,90) then touchClick(250,420)

elseif isColor(250,250,15716004,90) then touchClick(250,250)

elseif isColor(250,250,15720365,90) then touchClick(250,250)

elseif isColor(250,250,15721397,90) then touchClick(250,250)

elseif isColor(250,250,1656122,90) then touchClick(250,250)

elseif isColor(250,250,14593160,90) then touchClick(250,250)
end
end 

1 个答案:

答案 0 :(得分:1)

如果您缩进代码,错误的位置将变得更清晰(见下文)。

bloodRound=600
hardRound=700

function main()  
    while count<6000 do
        fightEvil();
    end   
--> there should be an `end` on this line

function fightEvil()
    -- snip --
end

请注意end上缺少function main()

我建议使用一个不错的文本编辑器,专门用于编辑代码,因为它会执行自动缩进和语法高亮关键字等操作。我目前正在使用Sublime Text 2 Lua语法荧光笔。有many others可供选择。

有关Lua脚本的速成课程,请查看Learn Lua in Y Minutes:)

无论如何,这里(可能)是固定代码:

local bloodRound, hardRound = 600, 700

function main()  
    while count<6000 do
        fightEvil();
    end
end

function fightEvil()
    count=count+1;

    if isColor(40,495,15178484,90) then
        touchClick(40,495)
    end

    if isColor(75,410,8094051,90) then
        touchClick(75,410)
    end

    if round <= bloodRound then
        touchClick(110,230)
    elseif round <= hardRound then
        touchClick(110,420)
    else
        touchClick(110,570)
    end

    if isColor(250,550,15721389,90) then
        touchClick(250,550)

    elseif isColor(250,550,14044457,90) then
        touchClick(250,550)

    elseif isColor(250,420,14570908,90) then
        touchClick(250,420)

    elseif isColor(250,420,10251594,90) then
        touchClick(600,950)

    elseif isColor(250,550,2202276,90) then
        touchClick(250,550)

    elseif isColor(250,420,16769965,90) then
        touchClick(250,420)

    elseif isColor(250,250,15716004,90) then
        touchClick(250,250)

    elseif isColor(250,250,15720365,90) then
        touchClick(250,250)

    elseif isColor(250,250,15721397,90) then
        touchClick(250,250)

    elseif isColor(250,250,1656122,90) then
        touchClick(250,250)

    elseif isColor(250,250,14593160,90) then
        touchClick(250,250)

    end
end 
相关问题