Create account / Log in

Beanshell in "Summary text above pieces"?

Talk about module design ideas and techniques.

Moderators: uckelman, Tim M

Beanshell in "Summary text above pieces"?

Postby cemoreno » October 12th, 2020, 5:52 am

In the Mouse-over Stack Viewer I have a "Summary text above pieces" that reads:

$sum(Steps)$

and shows the total number of Steps in the stack.

But I cannot figure out how to convert it into a beanshell expression so I can perform some operations (I would like to substract another property). For example:

{sum(Steps)}

doesn't work. I cannot find the answer in the documentation, or what is different about this field (if there is any difference).

Of course if I type:

$sum(Steps)$ - $sum(Detachments)$

I get "8 - 3" and the player must do the math. How could I have "5" instead?
cemoreno
 
Posts: 67
Joined: September 30th, 2010, 4:57 pm

Re: Beanshell in "Summary text above pieces"?

Postby Brent Easton » October 12th, 2020, 5:59 am

Beanshell expressions are not currently support into the Mouse-over stack viewer. The sum() function is an old hand-coded extension to the viewer and has no relationship to the Beanshell function of the same name.
User avatar
Brent Easton
 
Posts: 3229
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Beanshell in "Summary text above pieces"?

Postby cemoreno » October 12th, 2020, 6:54 am

Thanks once more Brent. Ok, I guess "8 Steps - 3 Detachments" will do.
cemoreno
 
Posts: 67
Joined: September 30th, 2010, 4:57 pm

Re: Beanshell in "Summary text above pieces"?

Postby Cattlesquat » October 12th, 2020, 2:50 pm

If "Steps" and "Detachments" are properties of the piece in question, you can add a "Calculated Property" trait to that kind of piece, call it something like "NetSteps", and set its expression to "Steps - Detachments". Then you can reference $NetSteps$ in your summary text and it will produce the result you want.
User avatar
Cattlesquat
 
Posts: 953
Joined: December 2nd, 2019, 4:57 pm
Location: Baltimore, Maryland, USA

Re: Beanshell in "Summary text above pieces"?

Postby cemoreno » October 12th, 2020, 3:28 pm

Thanks for the great suggestion! It helps a lot, as I was calculating (Steps - Detachments) in a few other places.
cemoreno
 
Posts: 67
Joined: September 30th, 2010, 4:57 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 3 guests