ID:1759839
 
(See the best response by Kaiochao.)
Code:
card/proc/SwitchPos(var/card/D,var/mob/C,p as num)
if(p == 1)
D.dir = turn(C.dir,0)
D.bPos = 0
return

D.dir = turn(C.dir,90)
D.bPos = 1
return


Problem description:
So I was trying to figure this out as my new team mate showed me it as it will save code lines. Originally it started to work but after deleting the states (Which I read that they are not needed) and we tried figuring it out but nothing happens. Help :/
Best response
Looks like you're trying to make a card game where cards can be rotated 90 degrees (relative to the owner's direction) depending on their "bPos".

About your code:
* You defined SwitchPos() as a /card proc, but you're passing the card you're operating on as D instead of just using src.
* You also defined p as the opposite of what you want the card's bPos to end up as.
* You're using turn(dir, angle) properly, but unless your card icon actually has those directions, it's not going to do anything.

If you want to rotate an atom's icon dynamically, you set atom.transform using the matrix() proc and maybe turn(matrix, angle).

card
proc/SwitchPos(mob/Owner, Position)
bPos = Position
transform = matrix(dir2angle(Owner.dir) + (Position && 90), MATRIX_ROTATE)

proc/dir2angle(dir) switch(dir)
if(NORTH) return 0
if(SOUTH) return 180
if(EAST) return 90
if(WEST) return -90
if(NORTHEAST) return 45
if(NORTHWEST) return -45
if(NORTHEAST) return 135
if(SOUTHEAST) return -135
K. Figured it out :)

One last question, just for animations purposes, can I still use turn on the dir and changes it direction without affecting the image?
BUMP. So I did figure this out but I was wondering if I wanted to print the icon in an output? What tag would I use and how I would go about doing it.

EDIT: SHow the transformed icon.
To output an icon to an output control, you must use the \icon text macro:

mob/verb/showMyIcon()
world << output("\icon[src]")


For further information on the matter, head to the reference: icon text macro
Yah I already know that, but I want to show the newly transformed icon.