ID:177152
 
i know its stupid but i have never really used icon states in my games! so could someone tell me the code to change icon states
Well, since icon_state is a variable, you can easily change it just about anywhere. All you need to do is add a line in someplace,

icon_state = "green"

Of course, you can substitue the name for whatever you want, it could be "blue" "pink" "fighting" "dead" or whatever. A good way to add this in a verb, so a user can change their own icon_state, is like this..
mob/verb
change_icon_state(msg as text)
usr.icon_state = msg
usr << "You changed your icon_state to [msg]."


By putting usr.icon_state, we are using a "reference" (at least thats what I call them. Some people say 'pointer'), which basically points to a certain object, mob, or whatever, and tells the code to modify that mob's variables. Hopefully this makes a bit of sense to you?

[atom to change variable].icon_state = "[new state]"


~Polatrite~