Choosing a Random File lua

773 Views Asked by At

Well, like it says in the title I need to figure out how to choose a random file from a folder with no idea on where to start or what to look for. Anyone willing to help me out?

1

There are 1 best solutions below

0
Paul Kulchenko On

Get the list of files in the folder using lfs module, store them in a table, and get a random element from that table using t[math.random(#t)] expression.