Jump to content

Random files from a folder


Recommended Posts

Hi,

I was wondering if it was possible to find a random file from a folder.

As example, I have 50 .xml files in a folder, and they all have different names.

Is there a function to get the contents of a folder, like files at a certain index, so I could just load a file when I have a number? Like 1-50?

I hope you guys understand this... :P

Regards,

Rutger Speksnijder.

Link to comment

Aha, are these xml's being generate by the same resource? In that case, when making an xml file, make a main xml file called master.xml, which specifies all the filenames of the generated ones. Then get the children, then use my function:

  
function table.getr(t, min) 
     return t[math.random(min or 1, table.getn(t))] 
end 

and then get the attributes and or value. But i cant guarantee itll work

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...