ID:2900638
 
Code:
var/list/posterypes = list()
var/list/icon_states = list(icon_states('icons/obj/machinery/holoposter.dmi'))
for(var/key = 1 to length(icon_states))
postertypes.Add(list(
"poster_name" = icon_states[key];
"poster_icon" = ))


Problem description:
So, what I am trying to achieve here is a list that contains the names of all icon states with their associated icon. How would I go about doing that?
The byond ref says that the icon_states() proc only returns a string with the names.
var/list/icon_states = icon_states('icons/obj/machinery/holoposter.dmi')
var/list/postertypes = list()

for(var/key in icon_states)
postertypes += list(list(
"poster_name" = key,
"poster_icon" = icon('icons/obj/machinery/holoposter.dmi', key),
))

Per the ref, icon_states just returns a list of strings that are the names of the states. You can then use the icon() proc, passing the file and key, to get an icon.

Please know that icon_states() is expensive due to being a file operation, so this should be cached. Additionally, this pattern as a whole is odd, why don't you just make datums to contain this information?
In response to Kapu1178
It's code for SS13, it's got to do with how data for TGUI is sent, but I'm very new to it. TGUI data is sent as a list of strings, lists and numbers, instead of datums and atoms, that's why the pattern might look weird.
In response to NotChasuX5
That explains a bit.
In response to Kapu1178
If you have more questions/suggestions how I could do it better, go ahead.
Are you trying to create a command that will collect the dmi files and icon-states?

It's not clear to me

It has this shape

When making 2 lists

The position can be the mirror of the other

It's not the right way to do it

But it works

world/var/list/nameicons=new

world/var/list/statesic=new

World/New()//default states for icons.dmi
_ nameicons=list('hairs.dmi','skins.dmi')
_ statesic=list("BlackHair","HumanBody")
_ ..()

MOB/verb/hair_to_default()
_usr.overlays-=hairs.dmi
_for(var/obj/i in usr.overlays)
_ _if(name=="hairs.dmi")
_ _ _usr.overlays-=i
_var/obj/i=New
_i.icon=nameicons[1]
_i.icon_state="statesic[1]
_i.name="hairs.dm"
_usr.overlays+=i