# Generating a total sum of a number of counters in a stack

Greetings, I want to make a counter that, when placed on top of a stack of on map units, will display the total of a number of marker traits and the number of ships and aircraft. For ex. There could be any number of ships (with surface combat, anti air and shore bombardment factors) (level naval, marker noship=1), a number of convoy points (3 or 5 CPs per 1 ship value always rounded up) (level cpasw, noship=no of CPs /32 rounded up [(Math.ceil)(float)(textvalue/3), some CV aircraft (level naval with naval air factors), submarines (with surface combat) (level subcx), CX ships with as per above ships but level subcx and land based aircraft with naval air factors (level air). I can make a counter to do this, but only for one level - naval, cpasw, subcx and air - using the SumStack function. There has to be a way to combine these into 1, repeat 1, counter. I think it can be done, but I need a pointer or two. The counter may need to reference where it is currently at (LocationName) and load the values of the various marker values for each level of counters in the stack. For this particular module, I will also need to differentiate between axis/allied units, and halve values if a ship is damaged (there is already a textvalue routine for damaged ships). The counter, ideally, will classed with the marker level - meaning it sits on top of everything else (except of course other marker level counters). I have learned that one can use (at least) certain java codes in the expression area, thus the (Math.ceil)(float) although I have actually used (Math.round)(float) in another area of the module). Even with (float) active, I still cannot use *1.5, but *3/2 works and round works. Thoughts please. No outright java programming stuff, I’ve no realistic idea how to to do so. I’m a dinosaur, machine code programs for a 8080/8086, done that. Fortran IV, basic, vis basic yep. I want java, I’ll ask my kids. But they will not be able to help if they know nothing of Vassal and what limitations there are with using java (or indeed how to use java within vassal as the developers guide is very non specific). Appreciate a lot to absorb, but constructive comment, suggestions and the like will be greatly appreciated.

Following on from the above. I can use the mouse over stack viewer functionality using SCS Attack: \$sum(surf)\$ Num: \$sum(noships)\$ AA: \$sum(aa)\$ NAVs A2S: \$sum(nav)\$ Num: \$sum(numacft)\$ SUBs: Attack: \$sum(subsurf)\$ Num: \$sum(numsub)\$ CPs: Num: \$sum(nocps)\$. But, this does have html ability so it’s just one long line and basic black text that is not that visible/readable. If I could make it red and bold with

I can make do.

But what I want is one counter that will provide the same information when dropped on top of a stack comprising several layers, said counter being a top layer counter.

Oh, and (Math.ceil()) does not work. Workaround is (Math.round((float)SumStack(“TextLabel”)/3+0.2)).

Finally dawned on me re the use of the 2 color selectors in the mouse over viewer properties. Black text on a white background works, as do other color combos. No bold text, but not a big deal.