Numeric field contains a non-number Increment

So I want my module to keep track of VP for eliminated units.

So every unit has a marker: “unitVP” because not all of them are worth the same.

I defined two Module GlobalProperties, Side_A_VP and Side_B_VP, both numeric and starting at 0.

Whenever a unit is “Killed CTRL-K” it triggers a SetGlobalProperty trait, of the type “increment Numeric Value” and amount:

(A reduced unit is worth half its value, so I check the Reduced layer)

It worked flawlessly for a while, but now it throws an error the first time a unit of each side is eliminated.

Nevertheless, the correct value is added and reported. The next eliminated units doesn’t throw this error.

I’ve tried using a DynamicProperty instead of a marker, so I can specify it is a numeric value. The results are exactly the same.

I am at a lost, have no idea where to look or how to solve this. Any help is appreciated!

Once it throws a “Bad Data” error, then it no longer executes that particular trait in the future, which is why it is not throwing the error after the first time – but it is still not “working”.

I notice you are using “unitVP” and “UnitVP” as if they are interchangeable, but of course they are case sensitive. Check and make sure you are consistently using the same exact spelling (either ALWAYS unitVP or ALWAYS UnitVP) in all cases. Because if you use the wrong one you’re referencing an undefined property, which will be the same as a blank/empty one, which will count as “non-numeric” and will throw the error.

Yep in the module I didn’t make that typo.

Your answer gave me the clue I needed. This post was just an example.

Actually, I have two GP, CoalitionVP and FrenchVP. Coalition units have the marker “CoalitionUnitVP”, french units “FrenchUnitVP”.

When a unit is eliminated, both GPs are increased, but the unit only has one property. The other one isn’t defined and throws the error, while the VP are indeed correctly calculated.

So my options at this point are:
a) add a marker “FrenchUnitVP”=0 for every coalition unit, and do similarly for french units…
or
b) find a way to check if FrenchUnitVP is defined before trying to add it to the GP.

Can (b) be done with BeanShells expressions?

Thanks a lot!

My “quickie” way to check if something is defined is to say, e.g. { FrenchUnitVP != “” }

Obviously that won’t work in cases where you plan to have defined things equal an empty string, but since undefined things always equal an empty string then you can keep them from trying to be processed as numbers this way.

You remind me that I had the same problem awhile ago, but I had forgotten. I ended up setting a bunch of properties to 0 (your “a” option) in a prototype so I was always adding a number, no matter what. Another option is to add another property frenchUnit = true, coalitionUnit = true and increment only if the check passed. I’m not sure if vassal defines the value of an undefined property, so assuming it is null is not necessarily valid. It probably is, but you would have to test, and it might not be forward compatible.

Thanks a bunch guys!

Actually I had tried something very similar to Cattlesquat’s suggestion.

The leader sends a Command that in turn activates a Trigger trait in units matching condition “FrenchUnitVP >0” (I also tried “FrenchUnitVP !=null” ). I didn’t think of comparing an empty string. Anyway this did nothing.

So I changed the “increment value” to a BeanShell expression:

{(If(FrenchUnitVP>0, FrenchUnitVP,0)}

This works.

Thanks again!