lundi 26 décembre 2016

Is Lua math.random broken?

Today I was writing a simple game in lua. A part of this game should choose a random element from a table and print it. Example:

test = { "foo", "bar", "test"}
print(math.random(#test))

The thing is: I'm always getting 1 when writing like that. If I miss something, then why does it work in the REPL?

Screenshot of the code and CMD

Im using lua version 5.3.2.

BTW: Sorry for bad english.




Aucun commentaire:

Enregistrer un commentaire