Hey everyone… as this script is too small to post in an example or project, thought I'd just post it in a blog.
Quote: From GMC Topic
Hey everyone!I wrote a script for picking a random file with attributes you specify on another forum (Reunited) for "Edge". Here it is:
And here is the example file (includes the GM6, the GMK, and 3 example jpg files to choose from):Download pick_random_file.zipI hope you like it :D,Jesper
{
///////////////////////////////////////////////////////////////////////////////////////////////
// pick_random_file(directory,filter,attr)
///////////////////////////////////////////////////////////////////////////////////////////////
// returns a random file from the directory, filter and attributes you choose
///////////////////////////////////////////////////////////////////////////////////////////////
// argument0: directory: directory to search in (example: "D:My Documents:examplefolder")
///////////////////////////////////////////////////////////////////////////////////////////////
// argument1: filter: only search for the sepcified file extension (example: "jpg")
///////////////////////////////////////////////////////////////////////////////////////////////
// argument2: attr: search for the following optional files with special attributes too:
//// fa_readonly (read-only files), fa_hidden (hidden files), fa_sysfile (system files),
//// fa_volumeid (volume-id files), fa_directory (directories), fa_archive (archived files)
//// (those are all constants, so if you type them right they will be colored red ;))
//// (example: fa_readonly+fa_sysfile+fa_archive)
///////////////////////////////////////////////////////////////////////////////////////////////
var dir,filt,attr,fnum,pickfile;
dir=argument0
filt=argument1
attr=argument2
fnum=0
file_find_first(dir+"*."+filt,attr)
while !(file_find_next()="")
{
fnum+=1
}
file_find_close()
pickfile=round(random(fnum))
openfile=file_find_first(dir+"*."+filt,attr)
repeat(pickfile)
{
openfile=file_find_next()
}
file_find_close()
return(openfile)
}
random files are pointless
Theoretically, it could be used for lots of things. Plus, Edge needed it, so it at least has one purpose [:D].
ChIkEn, you are again showing your lack of understanding of some subjects. Here's an example of a use for a random file picker:
You are making a 3D game. You have made interchangeable scenery (one object can use many different scenery objects). Now you want to place some scenery. Instead of specifying a scenery item, you need only place the object, and it will pick a file.Or put the filenames in an array and pick a random one =/
So you would load a file for every tree object? Yeah right.
so if you have a game with 50 20kb external maps you can pick a random one to load instead of load them all and then pick one to save time….
Chiken got owned.
I don't see the point of the script, anything you needs it for could be done Kaz's way.
And it can be done this way. What's your point…