ID:163565
 
Lists make me mad xD. Okay well heres the problem!


Im adding overlays like this...
for(var/obj/S in get_step(src,src.dir))
usr.icon_state="holding"
usr.overlays+=S


and im trying to remove the obj like this, but it doesnt seem to work.

mob/proc/blech()
src.removeoverlays()
for(var/obj/O in src.overlays)
if(!istype(O,/obj/overlays/clothes/)
usr.overlays.Remove(O)



Well somthing like that atleast, any help? :).
You can't really get objects back from overlays. That's why it doesn't work. Read the reference in regards to the overlays list.
In response to Ter13
You can use my overlay procs at [link] to add/remove overlays by icon and icon state instead.
In response to Foomer
well i need to set the icons pixel Y to make the obj change position so it looks as if its over head. But can i change an icons pixel_y?
In response to Bladeshifter
The procs I mentioned let you set an overlay's icon, icon state, pixel x, pixel y and layer when you add it. Just make sure that the values are the same when the overlay is removed as they were when it was added.

(See the example at the bottom of the post.)
In response to Foomer
real nice, thats just what i need. thanks.
In response to Bladeshifter
This doesnt work if its 2 seperate procs? :( Remove overlay wont take effect? has to be called the same proc? :/. Is it possible to send the overlay to a var for keepign then when i want it removed call your proc to remove the var somehow? :/.
In response to Bladeshifter
Yes, actually, you can just create a list, add to the list and the overlays, and then remove it by referencing it from the list again.

mob
var
obj/item/holding
...
...
...
src.holding = item
src.overlays += src.holding
...
...
...
src.overlays -= src.holding
src.holding.loc = get_step(src,src.dir)
src.holding = null


See?
In response to Ter13
niiiice thnx.
In response to Bladeshifter
works perfect... FOR SOUTH dir xD. if im facing a dif dir for some reason it messes up when i try to drop it. maybe the obj is reseting its dir when i pick it up and then its not thinking its the same obj in overlays because its not same dir or somthing?
In response to Bladeshifter
Hah! No. Is the function that causes the item to be dropped a /mob function, or is it the obj's function?

You need to reference the player's direction, otherwise, it will always be SOUTH, as the obj's direction isn't inherited from the player. It's purely a visual effect. The direction of the overlay has nothing to do with the object itself.