Is there a way to call a blocking function within repeatedly_execute_always? Because I'm trying to allow certain keypresses during speech, i.e., I use 91 and 93 (keycodes) to control the text speed. I want to be able to change this while the characters are talking, but in my "on_key_press_always" function (which I call in rep_ex_always), I have the following code:
if ((keycode == 91) || (keycode == 93)) {
GUIOn(TEXTSPEED);
Wait(5);
int value = GetSliderValue(TEXTSPEED, 0);
if ((1 < value <= 10) && (keycode == 91)) SetSliderValue(TEXTSPEED, 0, value - 1);
else if ((1 <= value < 10) && (keycode == 93)) SetSliderValue(TEXTSPEED, 0, value + 1);
game.text_speed = GetSliderValue(TEXTSPEED, 0);
timer = 100;
}
This produces an error when I press '-' or '=' because of the "Wait(5);" line. It says something about calling a blocking function in rep_ex_always. I do this to provide fluid movement of the slider handle (which controls the text speed) because if I leave the line out, you can't just hold the keys down to move the slider handle, you have to press the key and then wait for about 3 or 4 seconds to change it again. Is there a way of emulating a wait command in rep_ex_always? Or maybe a different way of doing the same thing? (I did try just using rep_ex, but it's not called during speech). Thanks for any help.
No, you can't put blocking functions within repeatedly execture always. Only one blocking function can run at once. Blocking means that it stops everything else from happening.
The best way to solve your problem is probably to have an integer which holds the text speed times 50 or something, so every loop while it's held down, it increases or decreases by 1. Then it sets the text speed to the integer / 50. This makes it so that every 50 loops the text speed is change by 1. (You might want to use some other number instead of 50, depending on how fast you want it to change.)