这个lua代码有何问题?

我正在编码中,这里出现了一个错误:

翻译后内容在此显示

它说附近应该有一个end,我已经找了一段时间,但不知道该如何解决。但是,我已经缩小了错误范围:

function attendMission()
    if Ammo >= 400 or Rocket >= 35 and Money >= 30000 then
        return Money = Money - 30000
        Msg("参加任务\n")
        Msg("现在你有"..Money.." 美元\n")
    else
        Msg("你没有足够资源参加这项任务\n")
    end
end
点赞
用户4348048
用户4348048

我刚发现问题所在。显然,将一些单词挪回去即可:

Ammo = 450
Rocket = 20
Money = 35041
--我能参加这个任务吗?
function attendMission()
if Ammo >= 400 or Rocket >= 35 and Money >= 30000 then
    Msg("参加任务\n你现在有"..Money.."美元\n")
    Money = Money - 30000
else
    Msg("你没有足够的资源参加这个任务\n")
end
end
print(attendMission())
--弹药数量
function whatIsAmmo()
if Ammo > 0 then
    print("你有"..Ammo.."个弹药")
else
    Msg("你没有弹药")
end
end
print(whatIsAmmo())
--火箭数量
function whatIsRocket()
if Rocket > 0 then
    Msg("你有"..Rocket.."枚火箭")
else
    Msg("你没有火箭")
end
end
print(whatIsRocket())
--金钱数量
function whatIsMoney()
if Money > 100000 then
    Msg("你有"..Money.."美元,哇,你好富有!")
elseif Money > 0 then
    Msg("你有"..Money.."美元")
else
    Msg("你没有钱")
end
end
print(whatIsMoney())

像这样完美地解决了问题。感谢你们的帮助!特别是你的评论乔什,教给了我一些新东西;)

2014-12-11 04:53:06