ID:145203
 
Just changed to Obj instead Turf.
Souloron wrote:
Problem description:
I am trying to make a door, when I bump into it, it open the door (change src.icon) but it doesnt change his density...


> atom
> proc
> Bumped(O)
>
> atom/movable
> proc
> Bump(atom/A)
> if(istype(A)) A.Bumped(src)
> ..()
>

>   Doors
> Door1
> icon='Doors.dmi'
> icon_state="1door-closed"
> density=1
> var/open = 0
> layer = 5
> Bumped()
> src.icon_state = "1door-open"
> src.density = 0
> sleep(30)
> src.icon_state = "1door-closed"
> src.density = 1
>


It would probably be better to do my above change to the door.

Because Bump is not called unless it is dense, the Open thing is not required. When you go into Bumped, it will make it non-dense, and make it apparently dissapear. After 3 seconds, it will return. Bumped will not be called again during those 3 seconds because when things are not dense, you cannot Bump into them.

Also, the original problem with your code is that Enter() is for BEFORE you actually enter the space the thing is taking up. Also, you would have to return 1 for the code to let you pass. If that was supposed to not let you pass, then you should have added return 1 at the end of the function all together. It would only make it to return 0 if both of those if statements returned true, otherwise it woulf return false, going to return 1. If you meant the other way, then just switch them, but I think the code above is more efficient and should work, tell me if there are any problems.