ID:266309
 
Could somone give me an example of how to make it so when somone enters a turf, a proc is called, and is recalled until that person leaves that turf, here's what I have.

turf
Lava
Entered(mob/M as mob)
M.LavaCheck()
if(M.Health >= 0)
Deathcheck()
Exited(mob/M as mob)
M << "WHOOOO! THAT'S HOT STUFF!"

mob
proc
LavaCheck()
sleep(10)
usr.HP -= 10
usr << "Better get a move on hot foot!"

WHen somone enters the lava, it only takes 10 health away, even when they're standing on it for 2 minutes. So I just want to know how to make it recall the lavacheck until they exit it. I know this seems like a dumb thing to use it for, but I was just curious how to make it work. Thank you.

=The Bearded One=
You could have something like this:

turf/Lava
Entered()
spawn(10)
usr.LavaCheck()
..()

mob
proc/LavaCheck()
var/turf/T = src.loc
if(istype(T,/turf/Lava))
src.health -= 10
spawn(10)
src.LavaCheck()
else
return

This would start the LavaCheck when they enter some lava. The LavaCheck spawns and checks if they are on lava every second until it sees that they aren't anymore.
In response to Cinnom
Cinnom wrote:
This would start the LavaCheck when they enter some lava. The LavaCheck spawns and checks if they are on lava every second until it sees that they aren't anymore.

With these procs, if a player steps from one lava turf to another, it will spawn additional copies of LavaCheck and do extra damage (20 per second for 2 lava steps, 30 for 3, and so on).

I've modified it a little to avoid this problem.

turf/Lava
Entered()
spawn(10)
usr.LavaCheck(<font color=#ffffa0>src</font>)
..()

mob
proc/LavaCheck(<font color=#ffffa0>turf/T</font>)
<font color=#ffffa0>// </font>var/turf/T = src.loc <font color=#ffffa0>// This line is removed</font>
if(<font color=#ffffa0>loc == T</font>)
src.health -= 10
spawn(10)
src.LavaCheck(<font color=#ffffa0>T</font>)
else
return