Just a short alias that creates a hp bar (196 bytes)
Use $hp(30,99)
30 being the hp left and 99 being the total hp
;Owls HpBar :]
alias hp return $regsubex($regsubex($str($chr(160),$int($calc($2 / 4 - $len($1) * 2))),/(.+)..(\1)/,\1 $+ [ $1 ] $+ \2),/(.{ $+ $int($calc($1 /4 -1)) $+ })/,$+(00,$chr(44),03\100,$chr(44),04))
I use this one:
alias hpbar {
if ($1 == 100) { return 09,09.........0110009,09....... | halt }
tokenize 32 $iif($len($1) == 1,0 $+ $1,$1)
var %green = $ceil($calc($1 / 100 * 20))
var %red = $calc(20 - %green)
var %x = 1
var %re = 09,09
while (%x <= 20) {
if (%x == $calc(%green + 1)) { var %re = %re $+ 04,04 }
if (%x == 10) { var %re = %re $+ 01 $+ $left($1,1) }
if (%x == 11) { var %re = %re $+ 01 $+ $right($1,1) }
if (%x == 11) { vaR %re = %re $+ $+ $iif($+(04,$chr(44),04) isin %re,04 $+ $chr(44) $+ 04,09 $+ $chr(44) $+ 09) }
if (%x != 10) && (%x != 11) var %re = %re $+ .
inc %x
}
return $regsubex(%re,(01)0(01\d04),\14.4\2) $+
}
dynamic length of the bar, like mine
bar { var %e = $2, %r = $calc($3 / %e), %x = $round($calc($1 / %r),0) | return 9,9 $+ $str(X,%x) $+ $iif($calc(%e - %x) > 0,$+(,4,$chr(44),4,$str(X,$calc(%e - %x)))) }
ex $bar(30,100,99) does the same thing as yours, but the length of the hp bar is 100 characters.