I need help with FlagDef 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!)
captainmann
Posts: 3
Joined: Thu Jul 04, 2024 9:45 pm

I need help with FlagDef in ZScript

Post by captainmann »

Hello, I am trying to make a class that has a custom flag, but when I put a Flagdef in the program, it brings me this error:

Code: Select all

Script error, "zscript/enemies/newenemy.zs" line 4: 
Unexpected ':' 
Expecting ';' or ','
This is line 3 and 4:

Code: Select all

private int newEnemyFlags; 
flagDef CanDodgeRoll: newEnemyFlags, 0;
I haven't been able to find too much documentation of Flagdef, and I'm new to ZScript, so I don't understand any mistakes I am making. Any help would be appreciated. Thanks.
Blue Shadow
Posts: 5039
Joined: Sun Nov 14, 2010 12:59 am

Re: I need help with FlagDef in ZScript

Post by Blue Shadow »

The earliest GZDoom version to support the custom flags feature is 3.7.0, so put this at the top of your ZSCRIPT file:

Code: Select all

version "3.7"
With that line, your mod can only be run with GZDoom 3.7.0 and higher, where the feature is supported.
captainmann
Posts: 3
Joined: Thu Jul 04, 2024 9:45 pm

Re: I need help with FlagDef in ZScript

Post by captainmann »

Blue Shadow wrote: Fri Jul 05, 2024 2:20 am The earliest GZDoom version to support the custom flags feature is 3.7.0, so put this at the top of your ZSCRIPT file:

Code: Select all

version "3.7"
With that line, your mod can only be run with GZDoom 3.7.0 and higher, where the feature is supported.
Now the error has changed to something different. It's changed to

Code: Select all

zscript/enemies/newenemy.zs, line 46: Unknown flag 'CanDodgeRoll'
Here is line 46

Code: Select all

+CanDodgeRoll

This is on some a class inheriting from the class where the CanDodgeRoll flag is defined
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: I need help with FlagDef in ZScript

Post by Jarewill »

You will also have to specify from which class the flag originates from, such as: +MyMonster.CanDodgeRoll
captainmann
Posts: 3
Joined: Thu Jul 04, 2024 9:45 pm

Re: I need help with FlagDef in ZScript

Post by captainmann »

Jarewill wrote: Tue Jul 09, 2024 10:27 am You will also have to specify from which class the flag originates from, such as: +MyMonster.CanDodgeRoll
Thanks for your help! This fixed my problem

Return to “Scripting”