我想使用Lua将随机生成的字符串放入字符串中。但是,我一直收到错误。
function main()
times = 0
while times < 10 do
ValueOne = {"1","2","3","4","5"}
ValueTwo = {"1","2","3","4","5"}
aval = math.random(1,#ValueOne)
bval = math.random(1,#ValueTwo)
a = ValueOne[aval]
b = ValueTwo[bval]
print ("Generated Values: " ..a.." "..b)
times = times + 1
end
end
main()
我收到此错误:
Exception in thread "main" com.naef.jnlua.LuaRuntimeException: ...Eclipse\Lua\workspace\My_Project\src\main.lua:13: attempt to concatenate global 'b' (a nil value)
at com.naef.jnlua.LuaState.lua_pcall(Native Method)
at com.naef.jnlua.LuaState.call(LuaState.java:555)
at org.eclipse.koneki.ldt.support.lua51.internal.interpreter.JNLua51Launcher.run(JNLua51Launcher.java:122)
at org.eclipse.koneki.ldt.support.lua51.internal.interpreter.JNLua51Launcher.main(JNLua51Launcher.java:137)
这意味着由于某种原因,变量'b'无法连接。我可能做错了什么。请帮忙。