I have two sorts of pieces in my module, combat units, and leaders. I have a lot of info coming up in the mouse over stack viewer for each unit and that works great. However I do not want that to show for the leaders.
I think I want a beanshell expression to look for a dynamic property on the leaders, like leader=true and then do a ternary operator to show just the name of the unit (the leader case) or the string that has all the info on it.
I tried it, but it shows me the expression as a string and does not evaluate or show any content.
(note, consecutive and before <br> have no additional effect, so they are removed).
In BeanShell expression, the $...$ form of properties are plain-text substituted before evaluation by BeanShell. You probably want to use the properties more directly
I have one more question on this. My customer wants a nested condition. If condition one is true then he wants a second to pick between two choices. Is there a way to nest ternary expressions.
There are three condditions:
a dynamic value x has no value. Nothing is displayed in roll over.
a dynamic value x has value A. String A appears in the roll over.
a dynamic value x has value B. String B appears in the roll over.
Now, about nested conditions, yes, that is indeed possible. Now, your conditions above could be re-written (in pseudo-code)
IF x == A THEN
Display A
ELSE IF x == B THEN
Display B
ELSE
Display nothing
which would translate to
{ x == A ? A : (x == B ? B : "")}
The parenthesis are - in this simple case - not really needed, but can help in more complex cases.
Hope that helps. Again, try with the standalone interactive BeanShell interpreter. You can get it from GitHub - download the file bsh-2.1.1.jar, and run it as
java -cp bsh-2.1.1.jar bsh.Interpreter
If you need more specific help, it would be good if you could make your module available somewhere for me to look at. If you do not want to post a link here, you can PM me by clicking my avatar.
You are correct about the $…$. I tried that earlier but had some other syntax error so it did not appear to work and it does.
I will try the solution above.
On the I have to disagree.
“First, a without preceding white space has no effect.”
This is in the " marks so it returns as HTML and in HTML an does not need space before or after, it creates the space. Here is the code with the removed.
Your post above is a bit messed up, because the text is interpreted by the web-browser.
When you want to write something like you better put that into back-ticks, i.e., ` `, or it will be rendered by the browser. Similar with the code, except you should probably use triple back-ticks
```
code goes here
```
Also, you screenshots are not visible.
With respect to the effect of : In something like
<html> <b>Foo</b></html> <!-- Notice no space between ">" and "&"
the (meaning none-breaking-space) may or may not have an effect, depending on how the HTML rendering code works. In your case, it is rather old Java code doing the rendering, and it isn’t really up to spec. It may simple eat leading and trailing space at the start and end of a string. Perhaps you can use a <table> to format your text display (don’t know if that works in the mouse-over context though).
Thank you will work on it and can send a link. It is a not for distribution so that would be fine. I will do others in the series that ARE general release.
I Tried that pattern and got no results so I think there might have been a syntax error so I will approach it again. Thank you for the help.