ID:1262007
 
(See the best response by Neimo.)
Is it possible to grab an icon and loop through all of it's icon states, as well as output the names of all it's state? If so, how would one go about this?
Best response
There is an icon_states() proc that takes an argument, an icon, and you can use a for() loop to output each state.
Thank you, I glanced over that but didn't think it was what I was looking for. Now looking over it again I saw what I was doing wrong the first time I glanced and tested it. I never stored them as a list. Thank you.
In response to D-Cire
No problem, glad to help.
On this note, how come when saving a list of icons/icon states; upon trying to call them back when loading them they are registered as existing, but have no icon?
In response to D-Cire
Show me how you're doing it?
var/list/cached_icons = list()


world/New()
..()
Load_Icon_Cache()
IconCacheOrig(NORTH,'item.dmi',Human)

world/Del()
Save_Icon_Cache()
..()

proc
Load_Icon_Cache()
if(fexists("WorldResources/IconCache.sav"))
var/savefile/load = new("WorldResources/IconCache.sav")
load["IconCache"] >> global.cached_icons
Save_Icon_Cache()
var/savefile/save = new("WorldResources/IconCache.sav")
save["IconCache"] << global.cached_icons

proc
IconCacheOrig(var/DIR = SOUTH,var/ICO = null,var/STATE = null)
var/a = "cache_[DIR]_[ICO]_[STATE]"

if(cached_icons.Find(a))
world << "RETURNED CACHED [a]"
return cached_icons[a]

else
var/icon/I = icon(ICO,STATE)
if(DIR == NORTH)
I.Turn(-90)

cached_icons += a
cached_icons[a] = I
world << "NEW CACHED [a]"
return cached_icons[a]


mob
Move()
src.icon = IconCache(DIR = dir,ICO = initial(src.icon),STATE = src.icon_state)
..()


It works perfectly fine without the loading system, upon saving, and loading, since the list loads the already cached icon, it doesn't recreate it. However, it says it's made already inside the cache. It doesn't place the icon on the src though.

Without loading and saving the system works fine, however if I plan to have a massive amount of cached icons it would be easier to save them all then have to generate/have them all made via playing each host time. Yet when I use the save/load system it displays no icon, yet states the icon is already in the cache and doesn't generate a new icon(Which it would if it wasn't located in the cache already)

It might be the way i'm saving it, because that's the only thing i see that might be wrong.


EDIT: I also forgot to state I tried this with and without using global.cached_icons