ID:1678390
 
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
I talked it over with D4RK3 54B3R and he agreed with me that it would be nice to be able to assign icon_state to a number (instead of just text).

Hypothetically, when assigning icon_state to a number, it corresponds to the state index of the icon. Let's say there's ten different states in the icon file, which may or may not have state names. Setting icon_state to something like 6 would set the state to the sixth state to display in this list.

Decimal points could be floored (6.54 -> 6). 0 would simply not display any state. Numbers below 0 could just be kicked back up to 0.

I'm not entirely certain what the backend code looks like in relation to icon_states, but I suppose if a number were assigned, it could simply mean just translating it to whatever the state name was.

Some pseudocode showing how it could be done in DM currently (this wasn't compiled or tested):
atom/proc/SetIconState(N)
if (isnum(N))
var/icon/i = icon(icon)
var/list/l = i.IconStates()
if (l.len)
N = max(min(N,l.len),1)
icon_state = "[l[N]]"
else
icon_state = ""