Multiple actor functions on same frame in ZScript?

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!)
User avatar
DamTheGreat
Posts: 77
Joined: Mon Oct 26, 2020 6:40 pm
Discord: ☠DamTheGreat☠#7201
Graphics Processor: nVidia with Vulkan support
Location: Luxembourg

Multiple actor functions on same frame in ZScript?

Post by DamTheGreat »

I want two actions to happen on the same frame, but I don't know how to implement that. I tried with a "&&" operator, but that doesn't work. I know it's pretty basic stuff, but I'm not that good at ZScript. Here's my code:

Code: Select all

brut AABBCCDDEEFF 4 A_Chase && A_Startsound ("brmove",CHAN_5,CHANF_LOOPING,1.0,attn_norm,0.0,0.0);
EDIT: Nevermind, figured it out. Here's what the code should look like:

Code: Select all

See:
		brut AABBCCDDEEFF 4
		{
		A_Chase(null,"missile"); 
		A_Startsound ("brmove",CHAN_5,CHANF_LOOPING,1.0,attn_norm,0.0,0.0);
		}
		Loop;
User avatar
Sir Robin
Posts: 392
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: Multiple actor functions on same frame in ZScript?

Post by Sir Robin »

Good job figuring it out.
And though you didn't ask about it, I'll post this here anyway, in case you need it in the future, or someone finds this thread doing a search:

If you are using any function that changes the state (eg. A_Jump()) you have use the return keyword to make that change get passed back to the actor.

example:

Code: Select all

See:
      brut AABBCCDDEEFF 4
      {
      A_Chase(null,"missile");
      A_Startsound ("brmove",CHAN_5,CHANF_LOOPING,1.0,attn_norm,0.0,0.0);
      return A_Jump(1, "SomewhereElse");
      }
      Loop;

Return to “Scripting”