Is there a reliable way to identify if the player has just skipped a line of speech?
My method in 3.6.1 is as follows:
1. Wrap Character.Say() to track when a character is speaking and if speech was skipped:
Code: ags
In 3.6.2, you can use Speech.SpeakingCharacter instead of SetGlobalInt(IS_SPEAKING, ...).
2. In repeatedly_execute_always(), check if a character is speaking and the skip key is pressed:
Code: ags
This approach sometimes but not always captures whether speech has been skipped. I assume this is because there's a race condition between completing the rest of the MySay() function (which clears IS_SPEAKING) and running repeatedly_execute_always() (which checks IS_SPEAKING).
Is there a better, more reliable way of tracking if speech has been skipped?
My method in 3.6.1 is as follows:
1. Wrap Character.Say() to track when a character is speaking and if speech was skipped:
function MySay(this Character*, String message) {
SetGlobalInt(IS_SPEAKING, this.ID);
this.Say(message);
if (GetGlobalInt(IS_SKIPPING_SPEECH)) {
Display("speech was skipped");
SetGlobalInt(IS_SKIPPING_SPEECH, 0);
}
SetGlobalInt(IS_SPEAKING, -1);
}
In 3.6.2, you can use Speech.SpeakingCharacter instead of SetGlobalInt(IS_SPEAKING, ...).
2. In repeatedly_execute_always(), check if a character is speaking and the skip key is pressed:
function repeatedly_execute_always() {
if (GetGlobalInt(IS_SPEAKING) >= 0 && IsKeyPressed(Speech.SkipKey)) {
SetGlobalInt(IS_SKIPPING_SPEECH, 1);
}
}
This approach sometimes but not always captures whether speech has been skipped. I assume this is because there's a race condition between completing the rest of the MySay() function (which clears IS_SPEAKING) and running repeatedly_execute_always() (which checks IS_SPEAKING).
Is there a better, more reliable way of tracking if speech has been skipped?