ID:178491
 
Dracimor wrote:
How would I make a proc replay itself over and over from the start of the world?
Like every 100 seconds it will say..
world << "Pop"
And will keep repeating itself every 100 seconds until the world shuts down or until it is told to stop through another proc.

You want to spawn off a proc that has a while loop that executes as long as you want it to. Make a global variable that tells whether it should continue executing. Then if you want to stop it, just set that variable to false. Try something like this:

var/popping

world/New()
. = ..()
popping = TRUE
spawn(1000)
Pop()

proc/Pop()
while (popping)
world << "Pop"
sleep(1000)

mob/verb/stop-pop()
popping = FALSE
In response to Air Mapster
In response to Dracimor
Dracimor wrote:
Ok is there anyway I can toggle the popping on through a proc instead of when the world starts?

Just toggle the popping var on and off.
mob/verb/togglepop()
popping = !popping
world << "Popping is now [popping==TRUE?"on":"off"]."

I used two tricks here which can be good to know of. The !variable is a fast way to toggle between true and false (not true = false you know). The other line is a quick way to make an embedded if statement. A little harder to understand, but if the expression before the ? is true, the statement before the colon is executed, otherwise the one after.


/Andreas
In response to Gazoot
In response to Dracimor
Dracimor wrote:
But I dont know exactly where to put a check and what the check would be. if(popping == TRUE)? And if so then where?

If using Mapsters example, spawn the Pop proc at the end of itself, and change the "while(popping)" line to "if(popping)".
proc/Pop()
if(popping)
world << "Pop"
spawn(1000)
Pop()

See the difference?


/Andreas