如何修复此错误:"attempt to index ? (a number value)"


local questions={
    EN={
        Q1={"",""},
        Q2={"",""},
        Q3={"",""},
        Q4={"",""},
        Q5={"",""},
        Q6={"",""},
        Q7={"",""},
        Q8={"",""},
        Q9={"",""},
        Q10={"",""}
    },
    BR={
        Q1={"",""},
        Q2={"",""},
        Q3={"",""},
        Q4={"",""},
        Q5={"",""},
        Q6={"",""},
        Q7={"",""},
        Q8={"",""},
        Q9={"",""},
        Q10={"",""}
    },
    TR={
        Q1={"",""},
        Q2={"",""},
        Q3={"",""},
        Q4={"",""},
        Q5={"",""},
        Q6={"",""},
        Q7={"",""},
        Q8={"",""},
        Q9={"",""},
        Q10={"",""}
    }
}
local current_question = questions.EN.Q..math.random(1,10)[1]

我想让current_question变量从questions表中返回一个随机问题,但它给了我一个错误;"尝试索引?(数字值)"

你需要

告诉解释器Q..math.random(1,10)是一个这样的字符串:

local current_question = questions.EN["Q"..math.random(1,10)][1]

相关内容

最新更新