I need a loop, but my knowledge is limited. I need to move an actor in one unit increments, and writing the same line 64 times seems too much.
Maybe someone knows how to do it, or can point me to a tutorial. The examples in the wiki don't help.
Thanks.
How can I run a script a set number of times then stop?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Re: How can I run a script a set number of times then stop?
For that you will want to use loops.
In this case for will help you:
This loop will run 64 times and then stop.
In this case for will help you:
Code: Select all
for(int i=0; i<64; i++){
//Do code here
}
Re: How can I run a script a set number of times then stop?
So, it's:
Script 1 (void)
for(int i=0; i<64; i++)
{
//Do code here
}
Script 1 (void)
for(int i=0; i<64; i++)
{
//Do code here
}
Re: How can I run a script a set number of times then stop?
Scripts must also have opening and closing brackets.
Also you might want a Delay in your loop so it doesn't execute all at once.
Like so:
Also you might want a Delay in your loop so it doesn't execute all at once.
Like so:
Code: Select all
Script 1 (void)
{
for(int i=0; i<64; i++)
{
//Actions here
Delay(1); //Delay by 1 tic if needed
}
}