You can use "Tables in tables." In tables, the value can be another table as well!
Let me show you!
local stuff = {{"Hi, can I have one scoop of vanilla?", "I would like one scoop of vanilla ice cream", "Can you get me a scoop of vanilla?"},{"Hi, can I have one scoop of chocolate?", "I would like one scoop of chocolateice cream", "Can you get me a scoop of chocolate?"}}
local chosenTable = stuff[math.random(1, #stuff)]
for i, v in ipairs(chosenTable) do
print(i, v)
end
This will pick a random table from the list, then print all of its contents (including the indices).
You can also use variables for each table as well.
local osv = {"Hi, can I have one scoop of vanilla?", "I would like one scoop of vanilla ice cream", "Can you get me a scoop of vanilla?"}
local osc = {"Hi, can I have one scoop of chocolate?", "I would like one scoop of chocolateice cream", "Can you get me a scoop of chocolate?"}
local listOfExpressions = {osv, osc}
local chosenList = listOfExpressions[math.random(1, #listOfExpressions)]
for i, v in ipairs(chosenList) do
print(i, v)
end
This also works the same!
UPDATE!
If you wanted to have only one entry from the many lists, you just have to index it like so:
local osv = {"Hi, can I have one scoop of vanilla?", "I would like one scoop of vanilla ice cream", "Can you get me a scoop of vanilla?"}
local osc = {"Hi, can I have one scoop of chocolate?", "I would like one scoop of chocolateice cream", "Can you get me a scoop of chocolate?"}
local listOfExpressions = {osv, osc}
local chosenList = listOfExpressions[math.random(1, #listOfExpressions)]
local chosenExpression = chosenList[math.random(#chosenList)]
print(chosenExpression)
Any questions? Please leave a comment below. Thanks! :)
1 comment
Why not just make it one list? If it really matters, you can just pick a random table then pick a random value out of that.