I suppose this is a project so I'm posting here, though it's a library, not a map. Flags are lists of properties you can check-mark, like the "flags" entry of a units in the data editor. The operators are missing from the editor, and are necessary to use bit flag presets, so I created a library of basic functions:
Variable - Modify Flags (set, clear, shift)
General - For Each Flag
General - For Each Flag by Index
General - For Each Flag Matching Conditions
General - For Each Flag Matching Conditions by Index
Conversions - Convert Preset to Integer
Index - Index of Single Flag
Logic - Flags Match Filters (any, all)
Logic - Flags And/Or
Logic - Flags Exclusive Or
Logic - Flags Not
All these but "index of bit flag" internally use a concept called macros, so there's no overhead compared to scripting it directly1. I also included an example bit flag preset variable, and functions useful to work around the editor bug with assigning flag values. If you're using one specific preset a lot, you can set the "number of flags" in the For Each Flag functions to default to some function or global where you store the number of flags for your preset.
Note: The import/export library functions of the editor are broken (hint and grammar text erase when you use import), so follow the method detailed in this post: Library Import/Export Bug
If you have any questions or problems, just ask.
Update:
I've updated the functions using new discoveries of how Blizzard does their macros. I combined several of the functions. Set, clear, shift left, and shift right are now all in the "modify flags" function, for example. I've also categorized the functions with similar functions. All the 'for each' loops are now in the General category with other loops.
1 With macros, the function calls are replaced by the actual operations when compiled, and the functions vanish entirely - they aren't even defined. You can see this by compiling your map in the script test window. If we had a log<sub>2</sub>x function in galaxy (or any logarithm at all), could make "index of single flag" a macro too.
Download
I suppose this is a project so I'm posting here, though it's a library, not a map. Flags are lists of properties you can check-mark, like the "flags" entry of a units in the data editor. The operators are missing from the editor, and are necessary to use bit flag presets, so I created a library of basic functions:
All these but "index of bit flag" internally use a concept called macros, so there's no overhead compared to scripting it directly1. I also included an example bit flag preset variable, and functions useful to work around the editor bug with assigning flag values. If you're using one specific preset a lot, you can set the "number of flags" in the For Each Flag functions to default to some function or global where you store the number of flags for your preset.
Note: The import/export library functions of the editor are broken (hint and grammar text erase when you use import), so follow the method detailed in this post: Library Import/Export Bug
If you have any questions or problems, just ask.
Update:
I've updated the functions using new discoveries of how Blizzard does their macros. I combined several of the functions. Set, clear, shift left, and shift right are now all in the "modify flags" function, for example. I've also categorized the functions with similar functions. All the 'for each' loops are now in the General category with other loops.
1 With macros, the function calls are replaced by the actual operations when compiled, and the functions vanish entirely - they aren't even defined. You can see this by compiling your map in the script test window. If we had a log<sub>2</sub>x function in galaxy (or any logarithm at all), could make "index of single flag" a macro too.