ID:262767
 
Code:
area
area8
Entered()
new/obj/trap1(usr.loc)
sleep(50)
del(src)


Problem description: i created a area that the player, when enter, a trap will appear, and after 5 seconds it will disappear, but, i tested and after 5 seconds it dont disappear.Whats wrong?

..()
A couple of problems:

- You are using usr in a proc. This is generally unsafe because usr is the object that told something to enter it, which could generally be anything. By default, the first argument for Entered() is the movable atom which tried to enter.

- You are deleting the area, which doesn't delete the trap. You need to set the new trap you are creating to a variable to keep track of it, then delete it.

So in the end, it comes up to something like this:

area/area8
Entered(atom/movable/A) // A is the attempted "enterer"
var/obj/trap1/T = new (A.loc)
spawn(50) // wait 5 seconds, but let everything else do stuff
del(T) // delete the trap, not the area


~~> Unknown Person
In response to Mysame
Don't give bad advice. I think I have told you this many times. Don't give advice, especially if you are just starting out. If you don't know, the forums are a great place to find answers, if you give advice that includes problems that potentially hurt the author, you can actually hurt many people who are going to use the forums as a method to help themselves. For example, if I tell someone to use usr in Enter(), then someone else searches for a problem with Enter() they will find my post, and that will cause 2 people to have problems.
In response to Unknown Person
> area/area8
> Entered(atom/movable/A) // A is the attempted "enterer"
> var/obj/trap1/T = new (A.loc)
> spawn(50) // wait 5 seconds, but let everything else do stuff
> del(T) // delete the trap, not the area
>

~~> Unknown Person

Thanks, this is very helpful!