Alternating Line Textures

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
Moebius
Posts: 57
Joined: Thu Jan 28, 2021 1:45 am

Alternating Line Textures

Post by Moebius »

I created a console and assigned the first of three textures to it. The three textures are from D3 Textures Set and are nearly identical except for some small lights. Using Zscript I can get it to change from TXT1 to TXT2 to TXT3, but then it stops. How do I make it loop back and repeat the script?

script 4 (void) {
SetLineTexture (222, SIDE_FRONT, TEXTURE_BOTTOM, "CPNL3K0");
delay (17);
SetLineTexture (222, SIDE_FRONT, TEXTURE_BOTTOM, "CPNL3K1");
delay (17);
SetLineTexture (222, SIDE_FRONT, TEXTURE_BOTTOM, "CPNL3K2");
delay (17);
What do I need here to make it go back to the beginning of the script and repeat????
}
User avatar
Virathas
Posts: 254
Joined: Thu Aug 10, 2017 9:38 am

Re: Alternating Line Textures

Post by Virathas »

You could just add a "while" loop for it

Code: Select all

script 4 (void) 
{
while(1) // This will be a permanent loop, there are no conditions for it to stop, ever
{
SetLineTexture (222, SIDE_FRONT, TEXTURE_BOTTOM, "CPNL3K0");
delay (17);
SetLineTexture (222, SIDE_FRONT, TEXTURE_BOTTOM, "CPNL3K1");
delay (17);
SetLineTexture (222, SIDE_FRONT, TEXTURE_BOTTOM, "CPNL3K2");
delay (17);
}

}
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Alternating Line Textures

Post by Gez »

This looks like [wiki]ACS[/wiki], not [wiki]ZScript[/wiki]. You can put a [wiki]restart[/wiki] to have the script go back to its beginning, or put the whole set of instructions inside a [wiki]while[/wiki] (1) loop.

However, you could also remove the script entirely and instead use [wiki]ANIMDEFS[/wiki] to handle the animation cycle automatically.
Moebius
Posts: 57
Joined: Thu Jan 28, 2021 1:45 am

Re: Alternating Line Textures

Post by Moebius »

Thanks, Virathas and Gez. The while(1) works like I want it to. I'll have to explore ANIMDEF's for future maps.
Post Reply

Return to “Scripting”