Author Topic: Event parameter that shows a list of brick images?  (Read 636 times)

So i'm making something, and it's going to have an event that has a parameter that shows a list of all the picture names in here:



Yeah, so, I just want it to have a list of all the names of the items in here, and have it return the name in the function argument. How can I do this?

no, don't you die on me

i'm serious

It's a little complicated to explain, so I wrote out some code for it. Hopefully it's obvious what's going on.

Code: [Select]
//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
}

Greek2me, what about the length limit on networked strings?

Does it HAVE to be the images? Can it also be the brick datablocks?

Because, then you can just do
Code: [Select]
RegisterOutputEvent("fxDTSBrick","doSomething","datablock fxDTSBrickData");
And it will list all bricks (the uinames appear in the list), without requiring the client to download a giant list as it figures out the datablock list itself

Greek2me, what about the length limit on networked strings?

Oh yeah. I think you'll have to do what Zeb said.