ID:143752
 
Code:
obj
Explosive
icon_state="explosive"
verb/Explode()
var/r=input("range?") as num
for(var/turf/T in range(r, usr))
T.overlays.Add(icon('explode.dmi',"explode"))
sleep(10)
T.overlays.Remove(icon('explode.dmi',"explode"))
for(var/atom/A in range(r, usr))
A.TakeDamage(damage=rand(50,60), damagetype="explosive")


Problem description:
When I add the overlay to T and remove it after a second, it does it one turf at a time. How could I make all the turfs have the explosive icon, and removed at the same time?

I'm thinking I would use block()...would I need to use block()?

> obj
> Explosive
> icon_state="explosive"
> verb/Explode()
> var/r=input("range?") as num
> for(var/turf/T in range(r, usr))
> T.overlays.Add(icon('explode.dmi',"explode"))
> sleep(10)
> T.overlays.Remove(icon('explode.dmi',"explode"))
> for(var/atom/A in range(r, usr))
> A.TakeDamage(damage=rand(50,60), damagetype="explosive")
>


The way you have it, it loops through all turfs with a delay after each.

<code>for each turf add an overlay then wait 10 ticks then remove the overlay continue to next turf...</code>

What you want to do is, instead of using sleep() to put a delay between turfs, you should use spawn(), so it would be:

<code>for each turf add an overlay then after 10 ticks: remove the overlay continue to next turf...</code>

If you're using spawn(), it won't create a pause while looping through turfs, it'll just tell it to happen 10 ticks later.

obj/Explosive
icon_state="explosive"
verb/Explode()
var/r=input("range?") as num
for(var/turf/T in range(r, usr))
T.overlays.Add(icon('explode.dmi',"explode"))
spawn(10)
T.overlays.Remove(icon('explode.dmi',"explode"))

sleep(10) // if you want to wait 10 ticks before doing damage too

for(var/atom/A in range(r, usr))
A.TakeDamage(damage=rand(50,60), damagetype="explosive")