ID:960995
 
(See the best response by Stephen001.)
Problem description: Let's say i want to cache around 150 - 200 icons, which would be the best way to accomplish this?
Then how would i easily access the cached elements? (In a fast way)

So i've read this post from Lummox: http://www.byond.com/forum/?post=265909#comment1230731

Cached icon operations

That's what i mean. All my icons use icon operations, re-doing them all the time wouldn't be the best way in my opinion.
Well, you would use world.Export() to access the cache.

As for storing them, I believe it really depends on the purpose. If it's for a preloader, I would simply upload the rsc file to a 3rd party file sharing site and have the game set to load it. Sorry if this wasn't the answer you were looking for, i'm not sure that I understood the question completely and what exactly you were asking.


!~Zane~!
Edited first post.
Format:
fcopy_rsc(File)

Args:
File: file to copy into the resource cache
------------------------------------------------
http://www.byond.com/docs/ref/info.html#/proc/fcopy_rsc

You might want to look into setting the lifespan of the cache
http://www.byond.com/docs/ref/info.html#/world/var/ cache_lifespan

As you noted that these are icons, might be nice doubling checking that (if you aren't uploading them all) http://www.byond.com/docs/ref/info.html#/proc/isicon

ID:273061

ID:158533 - although the snippet may be old (and broken) it'll explain somethings for you.

ID:165581 - second post may be helpful.

ID:166619 - second post may be helpful.

ID:168989

ID:148849 - might be what you are looking for.
Best response
It depends a little on how you want to use the icons, and refer to them.

http://www.byond.com/developer/Flick/F_Damage

F_Damage for instance, has no idea how many different icons it might need to cache, or how much they are going to be used. But it does know, it will need to be able to refer to icons by the colour they were transformed into.

So, the cache it builds is (more or less) an associated list of "colour" = iconObject, and so it can simply check if cache["colour"] != null, and use that icon if so. Otherwise, it creates a new icon, and stores it in the associative list.

This basically means you take the 20 ms overheard or what have you for creating your icon or manipulating it, and then have 0.01 ms fetches for the icon after that.

Another advantage is the CRC32 checksum for the icon is the same and the reference is the same, so once a user has received the icon, the client will re-use it. In F_Damage, we don't know what icons we'll need ahead of time, so we just let the normal internal fcopy_rsc() mechanism send the icon over to the client once, and let it internally re-use the icon.

If you know all the icons you want in advance though (or a sub-set of them), you can generate them on world start-up or player login (depending on what they are for), throw them into the associated cache for later re-use, and browse_rsc() those icons across on login, to get them in the cache straight-up.