Purpose:

A colorful(less than 50% - red, less than 75% - yellow else green) bar, you can use in status windows, for example, to show your hp, sp, etc...

Code:

#CLASS {Bar}

#VAR bar {%if(%3 > 100, "Illegal length (0 < length < 101)", %if(%3 < 1, "Illegal length (0 < length < 101)", %if(@b_perc(%1, %2) < 50, %ansi(high, red), %if(@b_perc(%1, %2) < 75, %ansi(high, yellow), %ansi(high, green)))%repeat("#", %if(@b_length(%1, %2, %3) > %3, %3, @b_length(%1, %2, %3)))%ansi(def)%repeat(".", %if(@b_remaining(%1, %2, %3) > %3, %3, @b_remaining(%1, %2, %3)))))}

#VAR b_perc {%eval(%1 * 100 / %2)}

#VAR b_remaining {%eval(((%3 * 100) - (%3 * @b_perc(%1, %2))) / 100)}

#VAR b_length {%eval(%3 - @b_remaining(%1, %2, %3))}

#CLASS 0

Usage:

@bar(current, max, length)

Where:

current - the current value of the stat you want to show

max - the maximum value of the stat you want to show

length - the length of the bar(from 1 to 100)

Example:

Let's say you have your hp in @hp, max hp in @hpmax.

#echo {Hp: "["@bar(@hp, @hpmax, 10)"]"}

If you currently have 27 out of 34 hit points, will result in:

Hp: [########..]