ID:146336
 
Ok this may seem like no big deal, but what I did, what I thought would work, dosent. :/

obj/Doors
icon = 'Buildings.dmi'
name = ""

Door_Top_Closed
icon_state = "009"
density = 1
New()
pixel_y = 32

Door_Bottom_Closed
icon_state = "010"
density = 1
var/obj/Doors/Door_Top_Closed/DTC = new
var/open = 0
New()
src.overlays += DTC

Bumped()
src.icon_state = "012"
DTC.icon_state = "011"
src.density = 0
sleep(30)
src.icon_state = "010"
DTC.icon_state = "009"
src.density = 1


Bascilly I want it, so when the bottom is generated, the top is put on as a overlay, that works. I want the Overlay to change to the other states when the door opens or closes.

The bottom opens, and closes fine, the top wont change. So..Anyone got an idea?
I think, it's because DTC is an overlay. Why not just do:
        New()
new DTC(src.loc)


Between:
        New()
pixel_y = 32

Can be replaced with:
        pixel_y = 32
I don't think you can access overlays like that... there's two solutions:
1) Instead of using an 'open' or 'closed' icon state have one icon state with different directions, e.g. north would be a closed door and south an open one. Then when the player bumps the door make it change direction accordingly.
or
2) Use a seperate object for the top part, and edit the bottom's New() so that when it's created it spawns a new top door, stores it in a variable, and puts it on the map at locate(x,y+1,z) then when the bump is called on the bottom bit it affects the top bit.

It's up to personal preference which you opt for, it depends on whether you want doors that face different directions or not...
As Fartmonger said, you cannot do it like that. The overlays list is a special list that holds only image objects. When you add an object to it, it creates a new image object with the properties of that object and puts that image object into the list, so the original object is not the thing that is in it.

What you could do is remove the overlay, then add DTC back into it again after changing its icon state.
obj/Doors/Bottom_Door_Closed
Bump()
src.icon_state = "012"
DTC.icon_state = "011"
overlays = list()
overlays += DTC
src.density = 0
sleep(30)
src.icon_state = "010"
DTC.icon_state = "009"
overlays = list()
overlays += DTC
src.density = 1