Meter Utilities #246
Aliases: Meter Utilities
11 verbs · 11 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
graphical_bar | this none this | rxd | #246 | 34 |
numeric_bar | this none this | rxd | #246 | 12 |
bar_for | this none this | rxd | #246 | 9 |
health_for | this none this | rxd | #246 | 3 |
@test | this none none | rxd | #246 | 10 |
fix_arguments | this none this | rxd | #246 | 27 |
thirst_for | this none this | rxd | #246 | 4 |
damage_for | this none this | rxd | #246 | 3 |
stress_for | this none this | rxd | #246 | 4 |
wanted_for | this none this | rxd | #246 | 3 |
hunger_for | this none this | rxd | #246 | 4 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
help_msg | #72 | rc | #361 | <clear> |
aliases | #1 | rc | #361 | {"Meter Utilities"} |
description | #1 | rc | #361 | <clear> |
object_size | #1 | r | #29 | {7685, 1298434090} |
hidden_verbs | #1 | rc | #361 | <clear> |
phelp_msg | #1 | rc | #361 | <clear> |
weight | #1 | rc | #361 | <clear> |
owner_verbs | #1 | rc | #361 | <clear> |
plural_name | #1 | rc | #361 | <clear> |
client_image | #1 | rc | #361 | <clear> |
listening | #1 | rc | #361 | <clear> |
Ancestry
Ancestors (nearest first): #72 Generic Utilities Package → #1 root
Children: none
Call graph
Source
graphical_bar
Referenced by
- #246:bar_for line 4:
this:graphical_bar - #246:bar_for line 6:
this:graphical_bar - #246:@test line 6:
this:graphical_bar - #246:@test line 8:
this:graphical_bar
Source
1":graphical_bar(INT current, INT max, INT length, [INT delta[, STR current_color[, STR delta_color]]])"; 2{current, max, length, ?delta = 0, ?current_color = $ansi.green, ?delta_color = $ansi.red} = args; 3"Fix the arguments for bad values."; 4{current, max, length, delta} = this:fix_arguments(current, max, length, delta); 5current = max(0, min(current, max)); 6if (delta > 0) 7current = max(0, current - delta); 8endif 9delta = abs(delta); 10current_length = toint($math_utils:rint(tofloat(length) * (tofloat(current) / tofloat(max)))); 11delta_length = toint($math_utils:rint(tofloat(length) * (tofloat(delta) / tofloat(max)))); 12blank_length = length - (current_length + delta_length); 13s = tostr($ansi.bold_on, $ansi.white, "["); 14$cu:sin(0); 15if (current_length) 16s = s + current_color; 17for x in [1..current_length] 18s = s + "|"; 19endfor 20endif 21if (delta_length) 22s = s + delta_color; 23for x in [1..delta_length] 24s = s + "*"; 25endfor 26endif 27if (blank_length) 28s = s + $ansi.reset; 29for x in [1..blank_length] 30s = s + " "; 31endfor 32endif 33s = tostr(s, $ansi.white, $ansi.bold_on, "]", $ansi.reset); 34return s;
numeric_bar
Referenced by
- #246:bar_for line 4:
this:numeric_bar - #246:bar_for line 8:
this:numeric_bar - #246:@test line 6:
this:numeric_bar - #246:@test line 8:
this:numeric_bar
Source
1":numeric_bar(INT current, INT max, INT length, [INT delta[, STR current_color[, STR delta_color]]])"; 2{current, max, length, ?delta = 0, ?current_color = $ansi.green, ?delta_color = $ansi.red} = args; 3"Fix the arguments for bad values."; 4{current, max, length, delta} = this:fix_arguments(current, max, length, delta); 5s = tostr($ansi.bold_on, $ansi.white, "[ "); 6if (delta > 0) 7s = tostr(s, delta_color, "+", delta, " ", $ansi.reset); 8elseif (delta < 0) 9s = tostr(s, delta_color, delta, " ", $ansi.reset); 10endif 11s = tostr(s, $ansi.bold_on, $ansi.white, current, "/", max, " ", "]", $ansi.reset); 12return s;
bar_for
Referenced by
- #246:health_for line 3:
this:bar_for - #246:thirst_for line 4:
this:bar_for - #246:damage_for line 3:
this:bar_for - #246:stress_for line 4:
this:bar_for - #246:wanted_for line 3:
this:bar_for - #246:hunger_for line 4:
this:bar_for
Source
1":bar_for(OBJ who, INT current, INT max, INT length, [INT delta[, STR current_color[, STR delta_color]]])"; 2who = args[1]; 3if (who:check_pref("meterboth")) 4return (this:graphical_bar(@args[2..$]) + " ") + this:numeric_bar(@args[2..$]); 5elseif (who:check_pref("meters")) 6return this:graphical_bar(@args[2..$]); 7else 8return this:numeric_bar(@args[2..$]); 9endif
health_for
Referenced by
- #107:show_status line 2:
$meter_utils:health_for
Source
1":health_for(OBJ who, INT current_health, INT max_health, INT max_length) => graphical or numeric health meter"; 2{who, current_health, max_health, max_length} = args; 3return this:bar_for(who, current_health, max_health, max_length, 0, $ansi.green, $ansi.green);
@test
Referenced by
none
Source
1for damage_step in [1..1] 2for health_step in [-2..8] 3damage = 10 * damage_step; 4current = 5 * health_step; 5l = {current, 30, 30, damage, $ansi.green, $ansi.green}; 6player:tell(tostr($su:left(tostr("[+", damage, ":", current, "]"), 12), " ", this:graphical_bar(@l), " | ", this:numeric_bar(@l))); 7l = {current, 30, 30, -damage, $ansi.green, $ansi.red}; 8player:tell(tostr($su:left(tostr("[-", damage, ":", current, "]"), 12), " ", this:graphical_bar(@l), " | ", this:numeric_bar(@l))); 9endfor 10endfor
fix_arguments
Referenced by
- #246:graphical_bar line 4:
this:fix_arguments - #246:numeric_bar line 4:
this:fix_arguments
Source
1{current, max, length, delta} = args; 2if (current < 0) 3if (delta != 0) 4delta = current + delta; 5if ((current + delta) < 0) 6delta = 0; 7endif 8endif 9current = 0; 10elseif (current > max) 11if (delta != 0) 12delta = delta - (current - max); 13endif 14current = max; 15endif 16"Healing."; 17if (delta > 0) 18adjusted_current = current - delta; 19if (adjusted_current < 0) 20delta = current; 21endif 22elseif (delta < 0) 23if ((current + (-delta)) > max) 24delta = -(max - current); 25endif 26endif 27return {current, max, length, delta};
thirst_for
Referenced by
- #107:show_status line 4:
$meter_utils:thirst_for
Source
1":thirst_for(OBJ who, INT current_thirst, INT max_thirst, INT max_length) => graphical or numeric thirst meter"; 2{who, current_thirst, max_thirst, max_length} = args; 3color = (current_thirst < 100) ? $ansi.blue | $ansi.yellow; 4return this:bar_for(who, current_thirst, max_thirst, max_length, 0, color, color);
damage_for
Referenced by
- #6:take_damage line 12:
$meter_utils:damage_for
Source
1":damage_for(OBJ who, INT old_health, INT new_health, INT max_health) => graphical or numeric health damage meter"; 2{who, old_health, new_health, max_health} = args; 3return this:bar_for(who, new_health, max_health, 30, new_health - old_health, $ansi.green, (old_health < new_health) ? $ansi.green | $ansi.red);
stress_for
Referenced by
- #107:show_status line 6:
$meter_utils:stress_for
Source
1":stress_for(OBJ who, INT current_stress, INT max_stress, INT max_length) => graphical or numeric stress meter"; 2{who, current_stress, max_stress, max_length, ?delta = 0} = args; 3color = (current_stress < 100) ? $ansi.cyan | $ansi.red; 4return this:bar_for(who, current_stress, max_stress, max_length, delta, color, color);
wanted_for
Referenced by
- #6:tell_wanted line 13:
$meter_utils:wanted_for
Source
1":wanted_for(OBJ who, INT current_stars, INT max_stars, INT max_length) => graphical or numeric wanted meter"; 2{who, current_stars, max_stars, max_length} = args; 3return this:bar_for(who, current_stars, max_stars, max_length, 0, $ansi.red, $ansi.red);
hunger_for
Referenced by
- #107:show_status line 5:
$meter_utils:hunger_for
Source
1":hunger_for(OBJ who, INT current_hunger, INT max_hunger, INT max_length) => graphical or numeric hunger meter"; 2{who, current_hunger, max_hunger, max_length} = args; 3color = (current_hunger < 50) ? $ansi.yellow | $ansi.red; 4return this:bar_for(who, current_hunger, max_hunger, max_length, 0, color, color);