ID:706959
 
(See the best response by Johan411.)
Well, I made the doors, both open and closed, an object. The reason being I want it to overlay the turf below.

//Objects.dm//

obj
icon = 'objects.dmi'
door_open
icon_state = "o_door"
density = 0
layer = MOB_LAYER + 1 //To fix isometric bugs
Click() //Close door
set src in view(1)
new /obj/door_closed(src) //Handles door
usr << "You latched the creeky door behind you." //informs user

door_closed
icon_state = "c_door"
density = 1
layer = MOB_LAYER + 1 //Same as above
Click() //Open door
set src in view(1)
new /obj/door_open(src) //Handles door
usr << "You slowly opened the creeky door." //informs user


Note: I don't get any errors, it just displays the message, but doesn't change the textures or properties of the doors.

Thanks.

This may be a silly question, but reading your code I can't actually see a point where the old door gets deleted; does clicking the door just stack new doors?
You'd want src.loc as the arguments in new. As it stands you're spawning new doors inside the original door's contents.
Best response
I hope this example helps you. The problem with the code you posted is that the closed state is still going to be show since you didn't make the previous door delete, Which would result in just creating a new door every time you click it.

obj
icon = 'objects.dmi'
door
icon_state = "c_door"
density = 1
layer = MOB_LAYER + 1 //Same as above
Click() //Open door
if(usr in view(src,1))
switch(icon_state)
if("c_door")
usr << "You slowly opened the creeky door."
icon_state="o_door"
density=0
if("o_door")
usr << "You latched the creeky door behind you."
icon_state="c_door"
density=1
In response to Johan411 (#3)
Johan411 wrote:
I hope this example helps you. The problem with the code you posted is that the closed state is still going to be show since you didn't make the previous door delete, Which would result in just creating a new door every time you click it.

> obj
> icon = 'objects.dmi'
> door
> icon_state = "c_door"
> density = 1
> layer = MOB_LAYER + 1 //Same as above
> Click() //Open door
> if(usr in view(src,1))
> switch(icon_state)
> if("c_door")
> usr << "You slowly opened the creeky door."
> icon_state="o_door"
> density=0
> if("o_door")
> usr << "You latched the creeky door behind you."
> icon_state="c_door"
> density=1
>
>
>
>

Thanks, I got it working. Thanks everyone for your help.