ID:159981
 
I was wondering how to write a repop that happend every 10 minutes. (6000 ticks)

I know I would either use while, do while, or for, but I'm not to familiar with them. (And the DM Guide is too confusing)

Please help, thanks!
Here is what I would do. Not saying its correct, but it works. I don't use repop though.

world/New()
spawn Repop_Loop()
..()
proc/Repop_Loop()
while(1)
sleep(6000)
world.Repop()
In response to Dragonn
Thanks!
Hi1 wrote:
And the DM Guide is too confusing

Just out of curiosity, could you be a bit more specific on the matter, in case there are attempts to improve the guide, it might be helpful to know what to focus on.
In response to Dragonn
Dragonn wrote:
Here is what I would do. Not saying its correct, but it works. I don't use repop though.

> world/New()
> spawn Repop_Loop()
> ..()
> proc/Repop_Loop()
> while(1)
> sleep(6000)
> world.Repop()
>


That will not work. After the sleep proc runs out, it will spam the Repop. This works better:

world/New()
Repop_Loop()

proc/Repop_Loop()
world.Repop()
spawn(6000) Repop_Loop()


You may need to add 'Set background = 1' at the beginning of the main proc to help with lag/errors.
In response to Developous
Developous wrote:
That will not work. After the sleep proc runs out, it will spam the Repop.

Huh? No it won't.

This works better:

IMHO, an actual looping construct works better.

You may need to add 'Set background = 1' at the beginning of the main proc to help with lag/errors.

That should have no effect whatsoever with your implementation, because it doesn't have a proper loop at all, as far as the language is concerned; and all setting a proc to background does is cause it to (arbitrarily) sleep between loop iterations.