Formatting Custom Statsformat_bool( value, format )format_bool( flg_p_ccall, 'check' )
..shows a boolean (true/false) value as a checkbox.
format_number( value, decimal places, commas, color )format_number( value, 1, false, false )
..shows a number (value) with 1 decimal place, no commas, not colored (green for positive, red for negative).
'value' will normally be something like:
(cnt_p_ccall / cnt_p_ccall_opp) * 100
..in which case this will be a % formatted to 1 decimal place.
This is more commonly done by entering this in the Format Expression field:
/%.2f
..which formats the value of the statistic to 2 decimal places.
formatformat( format_str , ... )
Now here's where it gets interesting. (if you like that kind of thing)
You can add as many numbers as you want to a formatted string, by adding {1}, {2}, etc. These will be replaced by the first, second, etc. value you add instead of the ...
This allows you to format strings with numbers in them, so you can construct stats with multiple values.
e.g. If a=37 and b=19, this Format Expression:
format( 'a={1}, b={2}', a, b )
..would give a stat output of:
a=37, b=19
or, more realistically..
format( 'You have played {1} hands and been in the blinds {2} times', cnt_hands, cnt_blind )
would look like:
You have played 100 hands and been in the blinds 25 times
Showing number of opportunitiesAnd better still, you can use this to construct stats showing a percentage and counts as a fraction in one stat, like this:
75% (3/4).
The format string for this is a little complicated. This is for cold calls again, and I've formatted to 0 decimal places.
format( '{1}% ({2}/{3})', format_number((cnt_p_ccall / cnt_p_ccall_opp) * 100 ,0,false,false), cnt_p_ccall, cnt_p_ccall_opp )
Which would give an output like:
33% (3/9)
If you want to try this - select the CCPF stat in 'holdem cash player statistics' section of the Configure Stats window, and click the 'Dup' button to make your own copy you can edit.
Rename the stat, e.g. CCPF2, then click the 'format' tab and replace the content with the above format string.
Better still, experiment with your own version so you understand how it works.
NOTE: This formatting still works and is still useful for reports but you can now format stats like this in the HUD without needing to do any formatting in the stat itself (as described here). Instead you can set the 'Show Times/Opportunities' property to True in the HUD Statistic Properties.Further formatting cleverness-- 1 --I stumbled across a useful little formatting trick related to use of checkbox (boolean) stats while experimenting with blind steal success.
I wanted some way to show when I'd attempted a steal as well as when it succeeded, and realised that I could use an IF statement in the 'format expression' field to determine whether the checkbox was even drawn.
format expression = if ( flg_steal_attempt, format_bool(flg_steal_success,'check'), '' )
This checks to see if a steal was attempted:
"if ( flg_steal_attempt"
..and if so it draws the checkbox to show whether the steal succeeded:
"format_bool(flg_steal_success,'check')"
..but if not it doesn't show anything (empty single quotes):
''
So if a steal was attempted and succeeded you get a checked checkbox, if a steal was attempted but failed you get an unchecked checkbox, if no steal was attempted you get an empty cell.
This makes the instances that are relevant stand out much more clearly.
-- 2 --You can do a similar thing with 'normal' numeric stats.
Some stats are quite rare and will sometimes have zero opportunities (as an example, cold calling preflop, and then betting the flop if checked to) - and looking down a long list of these it's easy to miss a case where the stats are 0/1 instead of 0/0 (even if you have formatted the stat "p% (x/y)" as described above). My solution to this is to add a colour condition to check for zero opportunities and colour the stat in pale grey so that those cases with non-zero opportunities stand out.
See this post for an example of this in use.
viewtopic.php?f=18&t=11480#p53759