ID:158343
 
If anyone has played a Castlevania game, you know what I'm talking about; more specifically the newer ones, such as Aria of Sorrow. Whenever you level up, the game freezes for a second or two to inform you that you have leveled up, and then it resumes the normal speed.

I was tinkering with it to see if I could perform the same operation by changing the world.tick_lag to something higher and then having a timer change it back. This, however, did not work. I forgot that even if you change the world.tick_lag, it still queues your input and then follows it up until the queue is empty.

The only other way I figured I could do this would be to program everything that runs in a loop to constantly check to see if the world is "frozen" and wait until it isn't any more. This would be the most obvious solution in my mind, but I just wanted to double check with your guys real quick and get your thoughts.

Thanks in advance.

I would make a proc that checks if the world is frozen simply because if you decide to change what checks if the world is frozen you wont have to change everything.
var/world_frozen=0
proc/world_is_frozen()
if(world_frozen)
return 1
return 0

Depending on what your stopping will change what you do, to stop movement you could do this.
atom/movable/Move()
if(world_is_frozen()&&(src.loc!=null))
return
..()

In an AI system returning wouldn't be the best choice...
So you would make it wait until it unfreezes
mob/Monster/Scan()
while(world_is_frozen())
sleep(10)

And you have to make every verb check if the world is frozen unless you ether remove them or have a non verb menu. How you do that can vary so no example for that one.

And here is how you an freeze the world for a bit.
proc/Freeze()
if(world_is_frozen())
return
world_frozen=1
sleep(100)
world_frozen=0

In response to Chowder
I already know how to program it; I already stated that. The question was: Is it possible to freeze the world without having to add a check point into every loop that requires to be stopped? All I need is a yes or no answer with an explanation before I proceed to begin some very tedious programming.
In response to ArcaneDragonX
Generally the only way to freeze the world is to stop or pause movement, loops, topic calls, and verbs. Usually nothing triggers events other then those except for login which probably doesn't apply to you as it seems its a one player game that your making. Your goal is to stop any of those from running besides the timer that unfreezes the game. If your using topic in place of verbs it will not only make your game look nicer it will remove the need to put a check in every verb.
In response to ArcaneDragonX
ArcaneDragonX wrote:
Is it possible to freeze the world without having to add a check point into every loop that requires to be stopped?

Short answer: No.
Long answer: No, but using world.sleep_offline you can pause the entire game when all players have logged off to save resources.