ID:161874
 
Could someone help me make an object proc that checks if the user's direction is WEST or NORTH, and then if it is make the object an underlay (if it is currently an overlay), and vice versa for if it is SOUTH or EAST?

In easier terms: My mob is supposed to hold a sword in his right hand, and the sword is an overlay. When he faces south or east, the sword appears in his right hand. When he faces west, it appears in his left hand, and when he faces north, it appears on his back.

I don't care how much coding it requires, as long as I can actually understand it. So please try to keep it short and simple, but don't make it so simple that it makes me feel like a fool for not doing that in the first place!

Also, I don't want to have to edit the icon state to make it only show what is not covered up by the mob's icon from each point of view, as this game is going to have quite a few swords and it would be really time consuming to edit them all, since I have nearly every icon already made.
I tried that with one of the swords, and it took me nearly 10 minutes to get it to work just right!

I'd greatly appreciate it if someone could help me out.

Thanks in advance!
I'm guessing you want something like this:
mob
proc
dircheck()
if(src.dir==north)
src.overlays += 'sword.dmi'
In response to Demon_F0rce
No, that's wrong.

As for the original question... you're really quite boned. This is the best I could come up with:

mob
var/list/maybeoverlays
var/maybeoverlay = -1
New()
..()
updateOverlays()

Move()
.=..()
updateOverlays()

proc/updateOverlays()
if(dir == NORTH || dir == WEST)
if(maybeoverlay != 0)
overlays -= maybeoverlays
underlays += maybeoverlays
else
if(maybeoverlay != 1)
underlays -= maybeoverlays
overlays += maybeoverlays


Anything you'll want to be under you when you're facing north or west (If you're moving in eight directions with only four direction states... I really don't want to deal with that right now) but over you when facing any other direction, just add it to the maybeoverlays list. Of course, I hate dealing with the overlays and underlays list, so you might get some wonky effects from all this adding and subtracting, perhaps if you've already got things in underlays / overlays.
In response to Garthor
I probably wouldn't even do this with code.


I'd make two different Iconstates,

One would be the overlay, and the graphics for the directions I don't want would be blank.

The other would be an underlay, and would be the same except in other directions, leaving the ones that the overlay had as blank.

Then I'd just add both.