Hello all,
So, I am writing a game where I am planning to occasionally bring up a GUI when the player interacts with an object, etc. for something a bit comparable to a quick time event. The GUI asks the player to perform a task and then the game does *something* based on whether they succeed or fail. Here's a little snippet that I wrote to test this feature.
Code:
function hHotspot2_Interact()
{
bringUpCardMatch();
//wait for the GUI to close somehow
if(lastCheckPassed == true)
{
Display ("Pass!");
}
else
{
Display ("Fail!");
}
}
Where bringUpCardMatch() brings up the GUI, which pauses the game while visible, and then adjusts lastCheckPassed accordingly. However, the room script just keeps going (which is to be expected) and hits the if statement long before the GUI can adjust lastCheckPassed.
The obvious solution is this:
function hHotspot2_Interact()
{
bringUpCardMatch();
while(gCardCheck.Visible){}
if(lastCheckPassed == true)
{
Display ("Pass!");
}
else
{
Display ("Fail!");
}
}
However, AGS hates it when you put together what appears to be a hung loop, and crashes.
I could try delegating the responsibility to the GUI to do whatever it needs to do, but that could make things very complicated, considering that this would be used in a variety of situations. So, ideally, I should find some way to block the room script until this is done, without crashing the game.
So, I am writing a game where I am planning to occasionally bring up a GUI when the player interacts with an object, etc. for something a bit comparable to a quick time event. The GUI asks the player to perform a task and then the game does *something* based on whether they succeed or fail. Here's a little snippet that I wrote to test this feature.
Code:
function hHotspot2_Interact()
{
bringUpCardMatch();
//wait for the GUI to close somehow
if(lastCheckPassed == true)
{
Display ("Pass!");
}
else
{
Display ("Fail!");
}
}
Where bringUpCardMatch() brings up the GUI, which pauses the game while visible, and then adjusts lastCheckPassed accordingly. However, the room script just keeps going (which is to be expected) and hits the if statement long before the GUI can adjust lastCheckPassed.
The obvious solution is this:
function hHotspot2_Interact()
{
bringUpCardMatch();
while(gCardCheck.Visible){}
if(lastCheckPassed == true)
{
Display ("Pass!");
}
else
{
Display ("Fail!");
}
}
However, AGS hates it when you put together what appears to be a hung loop, and crashes.
I could try delegating the responsibility to the GUI to do whatever it needs to do, but that could make things very complicated, considering that this would be used in a variety of situations. So, ideally, I should find some way to block the room script until this is done, without crashing the game.