Jump to content

get all png files in folder?


Thing

Recommended Posts

Posted

You can read the resource's meta.xml and get all the files from there.

function getResourceAllFiles( resourceName ) 
    local files = { }; 
    local metaRoot = xmlLoadFile( ":" .. resourceName .. "/meta.xml" ); 
    for i, node in ipairs( xmlNodeGetChildren( metaRoot ) ) do 
        if( xmlNodeGetName( node ) == "file" then -- check if the node is  
            table.insert( files, xmlNodeGetAttribute( node, "src" ) ); 
        end 
    end 
    return files; 
end 

Haven't tested but it's a simple function which will return all 's from specified resource (this includes .mp3, .png and all other files included in resource as ). Once you get the list of files just loop through it and add it to gridlist.

Posted

Show us how you used it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
doesnt work

I guess you use it client side, xmlLoadFile client side can load only the files that has downloaded in mods\deathmatch\resources, while meta.xml not one of them. You need to use it server side and trigger it to client side.

CiTLh.png
Posted

You can try using modules to make a function to scan directories.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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...