我正在编码,我在这里收到错误:
Ammo = 450
Rocket = 20
Money = 35041
--Can I attend this mission?
function attendMission()
if Ammo >= 400 or Rocket >= 35 and Money >= 30000 then
return Money = Money - 30000
Msg("Attending Mission\n")
Msg("You now have "..Money.." dollars\n")
else
Msg("You do not have the resources to attend this mission\n")
end
end
print(attendMission())
--Ammo Amount
function whatIsAmmo()
if Ammo > 0 then
print("You have "..Ammo.." Ammo")
else
Msg("You have no Ammo")
end
end
print(whatIsAmmo())
--Rocket Amount
function whatIsRocket()
if Rocket > 0 then
Msg("You have "..Rocket.." rockets")
else
Msg("You have no rockets")
end
end
print(whatIsRocket())
--Money Amount
function whatIsMoney()
if Money > 100000 then
Msg("You have "..Money.." dollars, wow your rich!")
elseif Money > 0 then
Msg("You have "..Money.." dollars")
else
Msg("You have no money")
end
end
print(whatIsMoney())
它表示预计会在=附近结束。我一直在寻找,但我不知道如何解决它。我已经缩小了错误在本节中的内容:
function attendMission()
if Ammo >= 400 or Rocket >= 35 and Money >= 30000 then
return Money = Money - 30000
Msg("Attending Mission\n")
Msg("You now have "..Money.." dollars\n")
else
Msg("You do not have the resources to attend this mission\n")
end
end
答案 0 :(得分:1)
我刚刚发现了问题所在。显然回过头来创造:
Ammo = 450
Rocket = 20
Money = 35041
--Can I attend this mission?
function attendMission()
if Ammo >= 400 or Rocket >= 35 and Money >= 30000 then
Msg("Attending Mission\nYou now have "..Money.." dollars\n")
Money = Money - 30000
else
Msg("You do not have the resources to attend this mission\n")
end
end
print(attendMission())
--Ammo Amount
function whatIsAmmo()
if Ammo > 0 then
print("You have "..Ammo.." Ammo")
else
Msg("You have no Ammo")
end
end
print(whatIsAmmo())
--Rocket Amount
function whatIsRocket()
if Rocket > 0 then
Msg("You have "..Rocket.." rockets")
else
Msg("You have no rockets")
end
end
print(whatIsRocket())
--Money Amount
function whatIsMoney()
if Money > 100000 then
Msg("You have "..Money.." dollars, wow your rich!")
elseif Money > 0 then
Msg("You have "..Money.." dollars")
else
Msg("You have no money")
end
end
print(whatIsMoney())
这样就完美了。但是,谢谢你们帮助我!尤其是你的评论Josh,他教会了我一些新东西;)