Mouse Over Stack Viewer Enhancement

Decimal - General Discussion - Vassal (vassalengine.org)

I would also like this. While I can java number crunch using (float) to obtain a real number, the stack viewer refuses to add them using sum(propertyName). Works with Integers, just not real numbers.

Alternatively, can the Summary text above pieces area be made a beanshell expression area. With this ability, I could still use the existing sum(propertyName), but I would deliberately multiply that propertyName by 10 so the sum function still uses integers and then I divide the sum(propertyName) total by 10 within the stack viewer Summary text above pieces area to get what I want to be displayed.

1 Like

I think if you try some beanshell in the Summary Text field it might surprise you by actually working.

I have used the “have everything pre-multiplied by 10 and then use / 10 and % 10 at the end to generate the decimal” system in various contexts.

1 Like

I have tried and no joy. I used $sum(propertyName)$/10 and the display just adds a /10 after the propertyName sum.
mouseoverdivide

Ah, but try changing the entire Summary Text field to just a beanshell statement surrounded by { }

So e.g.

{ "NAVAIR: " + sum(propertyName)/10 + " #NAVs: " + " <br>etc etc etc" }

For example I have used the following successfully in a module’s Mouseover Stack Viewer.

{ "<b>"+ GetProperty(DeckName + "_numPieces") + " Cards</b>" }

Brian

p.s. I can’t remember if “Sum” needs to be capitalized in beanshell.

sum should be OK. However, I keep getting error messages, basically, from the audit ability in prefs, the main issue is with the term. Paste from errorlog : Error=: Command not found: sum( int ). Same result for Sum(propertyName).
I restarted with the base term $sum(propertyName)$ works as per usual. Add the {} at either end the error occurs. Delete the $'s, error still occurs. I did note that when in this mode the property Name of tennav was reported as being 10, when it should have been 20. Thus using beanshell only looks at 1 counter not the 2+ that can exist.
I feel that there is a basic incompatibility with the $sum(propertyName)$ used by/in the summary text above pieces and its use within a beanshell expression.
While you are indeed correct that one can use beanshell expression in this area of the mouse over stack viewer, we cannot use a non beanshell expression that has been pre-defined within the Vassal code.
Drats, I say.

Ah! Right – the little local $sum(property)$ thing in the mouseover code is colliding with the Sum() that we built into Beanshell. I’ve just submitted a PR that will allow sumProperties(property) as a “synonym” that should work in the Beanshell versions of things. You can try a build of the “SumProperties” branch if you want when it comes up at vassalengine.org/builds, if you want to check it out. We’ll hopefully get it in the next 3.6 line we put out.

1 Like

This one - https://vassalengine.org/builds/build/116000576?
More than willing to give it a try out.
Fully separate directory and module copy.

Installed 3.6.0 Snapshot 67f1f74 SumProperties. Following is result thus far:

2021-11-21 13:20:23,512 [20492-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {SumProperties(tennav)} Error: Expression evaluation error. See the errorlog for more details.
Expression Audit:
Source type=
Source name=
Source field=Summary text above pieces
Source Expression={SumProperties(tennav)}
tennav=20
Error=: Command not found: SumProperties( int )
2021-11-21 13:20:36,204 [20492-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {SumProperties(nav)} Error: Expression evaluation error. See the errorlog for more details.
Expression Audit:
Source type=
Source name=
Source field=Summary text above pieces
Source Expression={SumProperties(nav)}
nav=2
Error=: Command not found: SumProperties( int )

Could it be that it is not taking the 20 or 2 as an integer but text? That would be inconsistent though as the calculated property to obtain tennav is simply nav x 10. sumProperties does not work either.

Just tried the SumProduct as if it was just another name for the stack viewer $sum(property)$. SumProduct or sumProduct is just that. Something that works outside of any beanshell expression. sum(property) and sumProperty(property) will never work within a beanshell expression. What is needed is a beanshell expression that does the same job as either of these two terms. What that is I have no idea. I know java like the back of someone else’s hand. :slight_smile:

It looks like you need SumProperties(“nav”) with the quotation marks because in Beanshell these things take a string argument.

Hmmm, maybe not. See attached error log file extract. Tried a few permutations.
2021-11-22 15:16:43,320 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"ACFT: NAVAIR: " + sumProperties(“tennav”)==0?0:sumProperties(“tennav”)/10} Error: Expression evaluation error. Turn on the Audit Trail preference to generate more details in the errorlog.
2021-11-22 15:17:16,112 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"ACFT: NAVAIR: " + SumProperties(“tennav”)==0?0:SumProperties(“tennav”)/10} Error: Expression evaluation error. See the errorlog for more details.
Expression Audit:
Source type=
Source name=
Source field=Summary text above pieces
Source Expression={"ACFT: NAVAIR: " + SumProperties(“tennav”)==0?0:SumProperties(“tennav”)/10}
Error=: Command not found: SumProperties( java.lang.String )
2021-11-22 15:17:54,126 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {SumProperties(“tennav”)} Error: Expression evaluation error. See the errorlog for more details.
Expression Audit:
Source type=
Source name=
Source field=Summary text above pieces
Source Expression={SumProperties(“tennav”)}
Error=: Command not found: SumProperties( java.lang.String )
2021-11-22 15:18:08,630 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {sumProperties(“tennav”)} Error: Expression evaluation error. See the errorlog for more details.
Expression Audit:
Source type=
Source name=
Source field=Summary text above pieces
Source Expression={sumProperties(“tennav”)}
Error=: Command not found: sumProperties( java.lang.String )
2021-11-22 15:18:24,267 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {$sumProperties(“tennav”)$} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:22:32,568 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " sumProperties($tennav$)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:22:52,090 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " SumProperties($tennav$)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:25:49,480 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " SumStack(tennav)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:26:15,231 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " SumStack(“tennav”)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:26:28,025 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Sum(“tennav”)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:26:42,797 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Sum(tennav)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:28:04,803 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " sum(tennav)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:29:42,561 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Sum(1,2,3,4,5)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:29:57,640 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " sum(1,2,3,4,5)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:30:10,334 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " sum(1)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:30:26,773 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Sum(1)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:33:27,639 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Sum(GetProperty(tennav))} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:34:04,678 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Sum(GetProperty(“tennav”))} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:36:26,111 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " Count()} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:43:34,836 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " sumProperties(tennav)} Error: Expression evaluation error. See the errorlog for more details.
2021-11-22 15:43:47,833 [4192-AWT-EventQueue-0] WARN VASSAL.tools.ErrorDialog - Source: {"AIRNAV: " sumProperties(“tennav”)} Error: Expression evaluation error. See the errorlog for more details.

Problem solved and using the stack viewer sum function. Need to do this:
GetProperty(“sum(propertyname)”)

I guess that makes the sumProperty(property) addition redundant.

Here is what I have now for the mouse over stack viewer for above the pieces:
{"" + “Ships: ATK:” + GetProperty(“sum(surf)”) + " #: " + GetProperty(“sum(noships)”) + "
SUBs: ATK: " + GetProperty(“sum(subsurf)”) + " #: " + GetProperty(“sum(nosubs)”) + "
All Naval: AA: " + GetProperty(“sum(aa)”) + " ASW: " + (GetProperty(“sum(asw)”)*1.0 + GetProperty(“sum(tennav)”)/10.0 + (Math.floor(GetProperty(“sum(nocps)”)/5.0))) + "
ACFT: NAVAIR: " + GetProperty(“sum(tennav)”)/10.0 + " #NAVS: " + GetProperty(“sum(nonavacft)”) + " #Total: " + GetProperty(“sum(noacft)”) + "
CPs: Total: " + GetProperty(“sum(nocps)”) + " CPs/5: " + ((int)(Math.ceil(GetProperty(“sum(nocps)”)/5.0))) + " CPs/3 : " + ((int)(Math.ceil(GetProperty(“sum(nocps)”)/3.0))) + "
GND CF Total: " + GetProperty(“sum(groupcf)”) + " 3D10 Depletion: " + GetProperty(“sum(depletion3d10_Name)”)}
This works with beta 6, with one caveat that probably should be mentioned in the help area. Every propertyName used within the sum(propertyName) must have a value for every piece in the stack the mouse over viewer is active. The values can be 0, but there must be a value otherwise an error will occur. I thinnk it comes back to the basic, non beanshell, expression $sum(propertyName)$ which displays a sum of the property and adds an ? where there is no value for that property for a piece. When using a beanshell expression that ‘?’ mucks things up.

If Beanshell is working in this context, and the counters to be summed are in a stack, did you consider SumStack() ?

It amazes me that GetProperty(“sum(PropertyName)”) works, but from the above thread I understand it’s because there’s a second level of (non beanshell) evaluation being done on “sum()”. Is that right ?

Seems undesirable that sum() is tripped up by a non-numeric property value rather than just treating it as zero. I don’t think the beanshell functions do that.

SumStack does not work with multiple layers. When using $sum(propertyName)$ in the mouseover, if any piece in the mouseover stack does not have ‘propertyName’ defined then the mouseover top window adds a ? to the total displayed. So, when using a beanshell expression in the mouseover above display ie {beanshell}, the $sum(propertyName)$ does not work. You have to use the GetProperty() function for it to work. But if the “sum(propertyName)” returns a number and a ‘?’ then the beanshell expression fails with an error.