ID:157451
 
I was wondering if there was a way I could use if statements in objects to change an icon state. I can't get this to work.

obj/var/alreadyset = 0

obj
KA
icon = 'FIRE.dmi'
BL_x1_y1
if(src.dir == NORTH)
if(alreadyset == 0)
icon_state = ""
alreadyset = 1
sleep(50)
alreadyset = 0
else
icon_state = ""





Nickr-sorry... Thanks!
http://www.byond.com/members/ DreamMakers?command=view_post&post=43124

You shouldn't even need code to do this, though, since you can create directional icon states in Dream Maker by hitting the movie button.
Nickr-Your link and comment has nothing to do with the issue at hand.

Yes, it does. You can't just put code anywhere under an object like you did in your example and expect it to execute (it needs to be under a proc or verb), just as the article explains. In fact, it even gives an example using the move proc, which is exactly what you would need to use.

Second, if you go into the icon editor and hit the movie button, change the number of directions to either four or eight, and set the number of frames to one, you can draw an icon for each direction. If you then set an atom's icon state to it, its icon will change automatically as its direction changes (which is usually good enough, if it doesn't meet your needs then you need to read at least parts of the article).

Nickr-sorry... Thanks!

No problem, good luck.