I would like to know if it is possible to repeat a whole part of the script or set its blocking style.
Make that part of codes a function and call it whenever needed.
Otherwise, you may need to elaborate more on what you actually need.
Is it possible to make a function like this:
myfunction (eRepeat);
???
If not, this won't help me.
Why not just call the function in repeatedly_execute[_always]() ?
Making a Function
Put this somewhere inbetween functions.
#sectionstart MyFunction
function MyFunction(){ //If you want it to return a value put something in between the brackets
/* Your code here. This could be anything, like adding inventory or playing a sound, or a set of variables being checked */
}
#sectionend MyFunction
Then in your Script Header
import function MyFunction();
And then whenever you want to use that block of code, just type
MyFunction();
Does that help? You can use functions to collect blocks of code you use a lot to make life easier.
That's how to make a function. But I want to be able to make the code repeat and set the blocking style.
I have a sound1.wav
I can play it with PlaySound(1);
But how do I make it repeat?
And how do I make the script wait until the sound is finished? (Blocking style)
Search for PlayAmbientSound in the AGS Manual, you can use that.
What exactly is in this bit of code you want to repeat and make blocking?
I'll do that. Thank you!
Whatever I want. It can be a character walking around all the time (repeat) without blocking the script (blocking style).
For that particular example you could do something with the room's repeatedly execute (to make it repeating) and Character.Walk (set it's blocking mode to eNoBlock). And probably Character.Moving aswell.
As for blocking sounds, you can force the sound into a specific channel using PlaySoundEx and wait until that channel is free again:
PlaySoundEx(1, 3); // play sound1 in channel 3
while (IsChannelPlaying(3) == 1) Wait(1); // block until channel 3 is free
IT WORKS! YES! Finally! :D
Thank you all!
Topics merged, since they deal with similar issues.
There's no single way to 'block' parts of the script, without them actaully being Blocking. However, using things like Character.Moving, or IsChannelPlaying, you can usually work around it.