So apologies if this has been asked before,
I am looking to build a sentence with random strings that will be stored in a table.
For example:
text = {}
names = {"a", "b", "c"}
name = names[rnd(2)] <-- doesn't work :(
foo = {
str = "Hi my name is" .. name
}
Everything I have found is in the Non P8 version of Lua.
P#54142 2018-07-13 12:56 ( Edited 2018-07-18 08:53)


rnd() doesn't return an integer. also table indices start at 1:
name = names[1+flr(rnd(2))] |
if you need this a lot you could use:
function rndt(t) return t[1+flr(rnd(#t))] end name=rndt(names) |
P#54144 2018-07-13 14:02 ( Edited 2018-07-13 18:02)
[Please log in to post a comment]