Adventure Game Studio

AGS Development => Engine Development => Topic started by: tor.brandt on Tue 08/11/2016 11:19:04

Title: Pause game function that overrides and stores blocking scripts
Post by: tor.brandt on Tue 08/11/2016 11:19:04
Today I was working on the UI for my game, specifically on the pause game function, and then it occured to me that it's actually not possible to make an on_key_press PauseGame() function that overrides a currently running blocking script.
This means that it's not possible to pause the game e.g. while a character is speaking.

I'm still very much a newbie regarding scripting and how blocking scripts work, so I have no idea how much work and rework would need to be done to implement such a function in AGS, and perhaps the function is not worth the amount of work, BUT;

I for one think it would be awesome if it'd be made possible in some future version of AGS to make an on_key_press PauseGame() function that overrides a currently running blocking script, and somehow stores the running script and the current "position" within that script, such that it can be resumed after UnPauseGame().
Title: Re: Pause game function that overrides and stores blocking scripts
Post by: Crimson Wizard on Tue 08/11/2016 14:39:36
It is hard to say how easy that would be to implement user-scripted pause. Suspending script functions in the middle (aka coroutines) is something that would require big script overhaul, which may be unrealistic with our lack of human resources.

Probably there are less costly options, like adding "above-game" built-in pause that would just lock any game update.
Title: Re: Pause game function that overrides and stores blocking scripts
Post by: tor.brandt on Tue 08/11/2016 16:40:04
Quote from: Crimson Wizard on Tue 08/11/2016 14:39:36
It is hard to say how easy that would be to implement user-scripted pause. Suspending script functions in the middle (aka coroutines) is something that would require big script overhaul, which may be unrealistic with our lack of human resources.

Probably there are less costly options, like adding "above-game" built-in pause that would just lock any game update.

I don't care how the function is realized, as long as it works :smiley:
A built-in "above-game" (or meta-something or whatever) pause function sounds great to me, and it seems to me that something like that would do the job just fine.
Such a function would be awesome in a future version!
Title: Re: Pause game function that overrides and stores blocking scripts
Post by: monkey0506 on Thu 10/11/2016 07:05:46
Quote from: tor.brandt on Tue 08/11/2016 11:19:04it occured to me that it's actually not possible to make an on_key_press PauseGame() function that overrides a currently running blocking script.
This means that it's not possible to pause the game e.g. while a character is speaking.

This is incorrect. You have unfortunately been misinformed.

Quote from: tor.brandt on Tue 08/11/2016 11:19:04PauseGame() function that overrides a currently running blocking script, and somehow stores the running script and the current "position" within that script, such that it can be resumed after UnPauseGame()

This is exactly how PauseGame/UnPauseGame currently works. See my reply in Beginners' Technical Questions (http://www.adventuregamestudio.co.uk/forums/index.php?topic=54132.msg636547557#msg636547557). You were simply calling "IsKeyPressed" too often, without storing a "held" state of the key (which AGS doesn't do for you). There is actually a module for that, called KeyPressAlways (http://www.adventuregamestudio.co.uk/forums/index.php?topic=34339.msg448122#msg448122).