我正在制作一个随机词生成器,但遇到了一个小问题。我正在尝试从包含 closedLetters(c、d、f 等)的表中打印值,但它不起作用。它返回零。帮忙?
local closedLetters={b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, z}
local openLetters={a, e, i, o, u, y}
print(closedLetters[2])
(那段代码只是一个例子,我设置的其实更像这样)
local closedLetters={b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, z}
local openLetters={a, e, i, o, u, y}
print(closedLetters[math.random(#closedLetters)]..openLetters[math.random(#openLetters)])
最佳答案
你在那个表中只有一堆键。具有 nil 值的键,因此您的返回值。 将它们改为文字: closedLetters= {'a', 'b', .....}
关于random - 表值返回零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17516614/