It's a little complicated to explain, so I wrote out some code for it. Hopefully it's obvious what's going on.
//this function puts all the icons in a list
function findBrickIcons(%mask)
{
for(%file = findFirstFile(%mask); %file !$= ""; %file = findNextFile(%mask))
{
%name = fileName(%file);
%name = strReplace(%name," ","@_@"); //we cannot have spaces in any of the names
%count = getWordCount($iconList);
$iconList = setWord($iconList,%count,%name SPC %count);
}
}
//we need to do this twice, once for PNG files and once for JPG
findBrickIcons("base/client/ui/brickIcons/*.png");
findBrickIcons("base/client/ui/brickIcons/*.jpg");
//now you can create the event:
registerOutputEvent(fxDtsBrick, yourEventName, "list" SPC $iconList, 1);
//let's do something
function fxDtsBrick::yourEventName(%this,%iconID,%client)
{
//the event returns a number
//let's loop through the list to find the right name
for(%i = 1; %i < getWordCount($iconList); %i += 2)
{
%word = getWord($iconList,%i);
if(%word == %iconID)
{
%name = getWord($iconList,%i - 1);
break;
}
}
%name = strReplace(%name,"@_@"," "); //add the spaces back in
%file = "base/client/ui/brickIcons/" @ %name;
//congrats, you have your file!
//do stuff here
}