If statement lua脚本中的if-else块

If statement lua脚本中的if-else块,if-statement,lua,If Statement,Lua,我试图在Lua脚本中创建if-else语句。但我真的无法让它发挥作用:(这就是我所拥有的 首先,我有一个随机发生器,可以在一些计划中进行选择 local phones_priceplan = { { priceplan = 'Fast'}, { priceplan = 'Mini'}, { priceplan = 'kort'}, } local rnd_priceplan = math.random(1, #phones_priceplan) local p

我试图在Lua脚本中创建if-else语句。但我真的无法让它发挥作用:(这就是我所拥有的

首先,我有一个随机发生器,可以在一些计划中进行选择

local phones_priceplan = {
    { priceplan = 'Fast'},
    { priceplan = 'Mini'},
    { priceplan = 'kort'},
}
local rnd_priceplan     =   math.random(1, #phones_priceplan)
local priceplan         =   phones_priceplan[rnd_priceplan]['priceplan']
然后,如果价格计划等于“快速”,我想运行另一个随机发生器

if priceplan == "Fastpris"
    local fastpris_plan = {
        {   price = '145',  gb = '0.5', },
        {   price = '195',  gb = '2',   },
        {   price = '245',  gb = '6',   },

    }
    local rnd_phone_surf_plan       =   math.random(1, #fastpris_plan)
    local surf_price            =   fastpris_plan[rnd_phone_surf_plan]['surf_price']
end

但是if语句似乎如此崩溃。关于什么可能是错误的,有什么想法吗?

在Lua中,
if
语句的语法如下:

if cond then
    statement
elseif cond then
    statement
else
    if cond then
        statement
    else
        statement
    end
end

你错过了
then
条款。

我去了洗手间,但是。我可能忘记了then条款。。。然后赶紧回去把我的问题去掉:)但是是的,先生,它马上就起作用了。非常感谢。您应该会收到以下错误消息:
'then'预期接近“local”
,这一点非常清楚。