Jump to content

get all png files in folder?


Thing

Recommended Posts

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.

Link to comment
  • Other Languages Moderators
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.

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