Bit-wise operators ??

With 3.2, there is the Calculated Property that can take expressions Math.sqrt (variable). Is there an equivalent expression for bit-wise operators? For example, Bit.rightShift(n, number). I could use these tools to create masks and use status strings to store piece info efficiently.


All of the Java bitwise operators appear to work: … s/op3.html

This is good, thanks.

How would I assign a data variable, say StatusData, with a ‘1’ at bit number 3? [i]StatusData /i |= [i]infoBit /i, where infoBit = 1 << 2.

Can this only be done in a Calculated Property? How about in Dynamic Property → set value directly?

I have not tried in my module yet as I do not know the proper syntax or implementation you have used.

Any instructions would be much appreciated.

Thanks again,


Pretty much any place in the editor that you can enter a string to be evaluated, including the Dynamic Property->Set Value field, supports Beanshell expressions, enclosed in curly braces: { }
Beanshell syntax is basically Java syntax, with a very few exceptions regarding property definitions as Beanshell is loosely typed. So I suspect you could do simply:
(in the field for ‘Set Value Directly’)

{ 1 << 2 }

Or, masking:

{ StatusData | ( 1 << 2 ) }

More info here:

I am curious, by the way, for what reason you’re so interested in this. I don’t expect it will much optimize storage or speed, for instance.


Hello Seth,

I have a CV unit that stacks squadron units under it. The CV keeps data on the number and type of squadrons ‘carried’. This data is used to support CV menu commands regarding the squadrons: unit capacity vs current storage, launch availability, bay occupied, et cetera.

This bookkeeping would require many [DP] and corresponding [Trigger] conditional checks. Using a single StatusData [DP] coupled with a common mask operation reduces the numerous properties required (and especially my typing mistakes with repeated named properties (I am not using the CTRL-ALT- methods).

Granted, players could do these operations manually, but it is complicated and prone to error. The module handles these issues and frees players from necessary bookkeeping.

At first it was not too complicated. But then I added more ‘helpers’ and it soon became programing cumbersome. The masking and bit control simplified this mess.

Fair enough! Anything that reduces the number of traits is a smart move in my book.