在PC上,我的遊戲編譯罰款和正常運行,但只要我建立它的Android我得到這個奇怪的錯誤代碼:的Lua(科羅娜SDK)Android的問題 - 時間間隔爲空
bad argument #1 to 'random' (interval is empty)
線這個代碼錯誤代碼來自是:
local word = wordsList[math.random(#wordsList)]
整個代碼Segement:
local lineCount = 1
local wordsList = {}
local wordAccepted = true
local file = io.open(system.pathForFile("words.txt", system.ResourceDirectory), "r") --Open the words file from the resource folder
for line in file:lines() do
if #line > 1 and #line <= 10 then
for i = 1,#line do
if string.byte(line,i)<65 or string.byte(line,i)>90 and string.byte(line,i)<97 or string.byte(line,i)>122 then
wordAccepted = false
end
end
if wordAccepted == true then
print ("accepted "..line)
wordsList[lineCount]=string.upper(line)
lineCount = lineCount + 1
else
print("rejected "..line)
end
end
end
io.close(file)
file = nil
local word = wordsList[math.random(#wordsList)]
什麼是'wordsList'?它有多大? –
我嘗試了大小爲3和78的wordsList。兩者都有相同的問題 – GMSkittles
提供'wordsList'的一個小例子。 –