Meter Utilities #246

Parent #72Owner #361Flags readSource hellcore/hellcore.db

Aliases: Meter Utilities

11 verbs · 11 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
graphical_barthis none thisrxd#24634
numeric_barthis none thisrxd#24612
bar_forthis none thisrxd#2469
health_forthis none thisrxd#2463
@testthis none nonerxd#24610
fix_argumentsthis none thisrxd#24627
thirst_forthis none thisrxd#2464
damage_forthis none thisrxd#2463
stress_forthis none thisrxd#2464
wanted_forthis none thisrxd#2463
hunger_forthis none thisrxd#2464

Properties

PropertyDefinerFlagsOwnerValue
help_msg#72rc#361<clear>
aliases#1rc#361{"Meter Utilities"}
description#1rc#361<clear>
object_size#1r#29{7685, 1298434090}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#361<clear>
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #72 Generic Utilities Package#1 root

Children: none

Call graph

calls n246_0 #246:graphical_bar n246_5 #246:fix_arguments n246_0->n246_5 n18_42 #18:rint n246_0->n18_42 n48_8 #48:suspend_if_needed n246_0->n48_8 n246_1 #246:numeric_bar n246_1->n246_5 n246_2 #246:bar_for n246_2->n246_0 n246_2->n246_1 n246_3 #246:health_for n246_3->n246_2 n246_4 #246:@test n246_4->n246_0 n246_4->n246_1 n107_43 #107:tell n246_4->n107_43 n20_1 #20:left n246_4->n20_1 n246_6 #246:thirst_for n246_6->n246_2 n246_7 #246:damage_for n246_7->n246_2 n246_8 #246:stress_for n246_8->n246_2 n246_9 #246:wanted_for n246_9->n246_2 n246_10 #246:hunger_for n246_10->n246_2

Source

graphical_bar

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none noneFlags rxdOwner #361Definer #246

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #246

Referenced by

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);