ID:537730
 
(See the best response by Stephen001.)
Code:
mob
Login()
src.icon='Player.dmi'
src.loc=locate(1,1,1)

Move()
..()
if(src.dir==EAST)
icon.Flip(EAST)


Problem description:
I tried a bunch of variations of this, but this one seems the most logical. I want the icon to flip east if the player moves east, simple enough. However, I simply get an error saying "Test.dm:9:error: Flip: undefined proc", which it definitely isn't. Am I making some really obvious mistake? It's been a while since I last coded, so that might just be.

Best response
It's a bit of a trick one, actually.

The issue is more that atom/icon as a variable isn't typed as an icon, so the compiler doesn't know if can even use Flip() on it. The solution is to type-cast:

    Move()
..()
if(src.dir==EAST)
var/icon/I = src.icon
I.Flip(EAST)
src.icon = I


The final assignment may be un-necessary, but adds a certain clarity to what's going on, I feel.
You need to verify what you're flipping as an icon. Soo, what you would do here is this type of thing

var/icon/I = new(src.icon)
I.Flip(EAST)
src.icon = I
Oh crap lol, good timing Stephen.
Let us +1 each other's posts, as heck, great minds think alike.
Deal. Though yours is better, I forgot you didn't have to specify it as new()

Edit: Or not, I just tested it with just src.icon instead of new(src.icon) and it didn't work. Maybe it's just the way I did it.
Oh, I see! I was so close there, I actually tried assigning a variable and then pointing to it, but it completely slipped past me that I should be defining it as var/icon/I rather than var/I... I'm getting rusty.

Thanks, anyways! :P

EDIT:

I tried it out, and got this runtime error, which I'm unable to read myself. D:

runtime error: Cannot execute null.Flip().
proc name: Move (/mob/Move)
usr: Guest-2568378137 (/mob)
src: Guest-2568378137 (/mob)
call stack:
Guest-2568378137 (/mob): Move(the turf (2,1,1) (/turf), 4)
You need to do what I said to not get that error,

go new(src.icon) instead of just src.icon
Glad we could help!
Oops, didn't notice you edited your post. :x

EDIT: *sigh*, now it randomly switches directions every time it moves left or right. It might help a bit if I say why I need this: I've made a huge amount of icons done, but they're all facing west! That's obviously incredibly annoying, and I can't be assed to redo them all, so I figured Flip might save me.

But the first step the player takes, his icon flips east, then the next flips to west, then east etc. Whut tha. Sorry about this getting drawn out so much, I've never used icon procs before! :P
Dyou have msn? if so add me [email protected], I can help you easier from there probably.
Added ya.
Hm I'm not getting a request. Maybe MSN's funky. What's yours I'll add you?