generic power plant #134

Parent #338Owner #361Flags read, fertileSource hellcore/hellcore.db

Aliases: generic power plant

13 verbs · 74 properties · 1 children

Verbs

VerbSpecFlagsDefinerLines
_plugthis none thisrxd#1346
_unplugthis none thisrxd#1346
heartbeatthis none thisrxd#13430
_turn_onthis none thisrxd#13411
_turn_offthis none thisrxd#1346
look_selfthis none thisrxd#13430
initializethis none thisrxd#1342
recyclethis none thisrxd#1342
has_powerthis none thisrxd#1341
tree_tagthis none thisrxd#1341
startthis none nonerxd#13412
fuel_usethis none thisrxd#1341
entombthis none thisrxd#1343

Properties

PropertyDefinerFlagsOwnerValue
plugged_in#134rc#361{#403203, #565897}
on#134rc#3611
help_msg#134rc#361
list of 105{"Powerplants ", "", "Powerplants are objects that generate power for an area. There might be lots of things in an area that use power, from television sets to battery chargers. When the powerplant is online all of this is possible, but when it goes offline all of those things lose power and cease to operate. ", "", "Powerplants are descended from the generic power plant (#1655). The powerplant does two things, codewise. First, it provides a mechanism for switching lots of devices on and off all at the same time. This can be a dramatic effect in the game, since things the players need to complete their adventures might depend on powered objects. Second, it sends current to devices plugged into it every so often, which can be used to charge things. ", "", "To find out what powerplant your area is using, you can look at it's .powerplant property: ", "", " powerplant = this:area().powerplant;", "", "When things are 'plugged in' to the powerplant it just means that they are registered with it, in the sense that it knows it's providing power to that object (via its .plugged_in property). Programatically you can connect things up to the powerplant via the powerplant's :_plug() verb. It's very simple, just pass it the object you want to plug in to it: ", "", " powerplant:_plug(thing)", "", "If you're using the generic powered thing (#2521), there is a command-line wrapper verb that does this for you: ", "", "#2521:plug this (in/inside/into) none", " 1: if (!is_a(this.location, #489))", " 2: player:tell(\"You don't see any place to plug \", this:dname(), \" in.\");", " 3: return;", " 4: elseif (!is_a(pp = this:area().powerplant, $powerplant))", " 5: player:tell(\"There don't seem to be any working outlets here.\");", " 6: return;", " 7: elseif (is_a(this.powered_by, $powerplant))", " 8: player:tell(this:dnamec(), \" is already plugged in.\");", " 9: return;", "10: endif", "11: pp:_plug(this);", "12: this.powered_by = pp;", "13: this.location:announce($su:ps(this.oplugin_msg));", "14: player:tell($su:ps(this.plugin_msg));", "", "First we check to make sure we're indoors, then we find the powerplant for out area, make a quick check to see if we're already plugged in, and then call the powerplant's :_plug() verb. There is a corresponding verb called :_unplug() which does the opposite. ", "", "When you have some things plugged into a powerplant, all sorts of fun things can happen. Most importantly, if the powerplant gets blown up by terrorists or something, all of the powered devices hooked up to it turn themselves off. This is done via those objects' :_lose_power() verbs, if they exist. For instance, going back to the generic powered thing: ", "", "#2521:_lose_power this none this", " 1: if (this.lose_power_msg)", " 2: this.location:announce_all($su:ps(this.lose_power_msg));", " 3: endif", " 4: this:turn_off();", "", "Similarly, when the powerplant is turned on, it will call the :_gain_power() verb on all of the objects that are plugged into it, presuming they have that verb. It does exactly what you would expect. ", "", "Here's a quick rundown of the imporant verbs and properties on $powerplant: ", "", "Verbs on $powerplant: ", "", "_plug(OBJ thing) -- Connect 'thing' to the powerplant ", "", "_unplug(OBJ thing) -- Disconnect 'thing' from the powerplant ", "", "heartbeat() -- You should never have to call this, but should know that it calls :_charge on all the objects that are connected to it when it runs ", "", "_turn_on() -- Turns the powerplant on, calling :_gain_power() on all objects connected to it ", "", "_turn_off -- Turns off the powerplant, calling :_lose_power() on all objects connected to it ", "", "", "Properties on $powerplant: ", "", "plugged_in -- List of objects that are connected to the powerplant ", "", "on -- boolean for determing the state of the powerplant ", "", "", "Verbs on generic powered thing (#2521): ", "", "turn_on() -- turns on the appliance ", "", "turn_off() -- turns off the appliance ", "", "_lose_power() -- causes the appliance to lose power (usually turning it off) ", "", "_gain_power() -- restores power to the appliance ", "", "plug this in -- command-line verb for connecting the appliance to a wall socket or other power source ", "", "unplug this -- command-line verb for unplugging the appliance ", "", "", "Properties on generic powered thing (#2521): ", "", "on -- for determining whether the thing is turned on ", "", "turn_on_msg -- What you see when you turn the thing on ", "", "turn_off_msg -- What you see when you turn this thing off ", "", "gain_power_msg -- What you see when the thing starts to get power ", "", "lose_power_msg -- What you see when the thing loses power ", "", "plugin_msg -- What you see then you plug the thing in ", "", "oplugin_msg -- What others see when you plug the thing in ", "", "no_power_msg -- What you see when you try to turn the thing on and it has no power ", "", "powered_by -- What the thing's source of power is (#-1 if nothing) ", "", "unplug_msg -- What you see when you unplug the thing ", "", "ounplug_msg -- What others see when you unplug the thing ", ""}
power_on_msg#134rc#361"%DT kicks on, filling the area with a low hum."
power_off_msg#134rc#361"%DT shuts down, leaving the area much quieter."
heart#134rc#361-1
last_heartbeat#134rc#3610
generic_generator#134rc#361#108265
start_nofuel_msg#134rc#361"%DN hits the start switch on %dt. It clicks impotently and makes a faint chemical smell."
start_msg#134rc#361"%DN hits the start switch on %dt, which coughs then rumbles to life."
burn_fuel_msg#134rc#361"%DT hums softly."
fuel_type#134rc#361#-1
dont_hibernate#134rc#3611
capacity#338rc#361100
infinite_fluid#338rc#361<clear>
fillable#338rc#361<clear>
hold_to_drink#338rc#361<clear>
drink_msg#338rc#361<clear>
recycle_on_empty#338rc#361<clear>
fill_from_msg#338rc#361<clear>
spawn_liquid#338rc#361<clear>
wash_msg#338rc#361<clear>
show_contents#338rc#3610
unchuggable#338rc#361<clear>
chug_start_msg#338rc#361<clear>
ochug_start_msg#338rc#361<clear>
chug_continue_msg#338rc#361<clear>
ochug_continue_msg#338rc#361<clear>
chug_stop_msg#338rc#361<clear>
ochug_stop_msg#338rc#361<clear>
choke_start_msg#338rc#361<clear>
ochoke_start_msg#338rc#361<clear>
ochug_finish_msg#338rc#361<clear>
chug_finish_msg#338rc#361<clear>
junk_after_chug#338rc#361<clear>
break_msg#255rc#361<clear>
repair_difficulty#255rc#361<clear>
junk_on_break#255rc#361<clear>
rename_on_break#255rc#361<clear>
smashable#255rc#361<clear>
repairable#255rc#361<clear>
armor#255rc#361<clear>
held_break_msg#255rc#361<clear>
oheld_break_msg#255rc#361<clear>
handed#5rc#361<clear>
wield_msg#5rc#361<clear>
unwield_msg#5rc#361<clear>
size#5rc#361<clear>
look_place_msg#5rc#361"%IT is installed here."
value#5rc#361<clear>
get_msg#5rc#361<clear>
drop_msg#5rc#361<clear>
get_fail_msg#5rc#361<clear>
junk_ok#5rc#361<clear>
floats#5rc#361<clear>
long_name_msg#5rc#361<clear>
article#5rc#361<clear>
setup_list#5rc#361<clear>
health#5rc#361<clear>
health_max#5rc#361<clear>
min_skill#5rc#361<clear>
skill#5rc#361<clear>
recipe_for#5rc#361<clear>
carried_msg#5rc#361<clear>
aliases#1rc#361{"generic power plant"}
description#1rc#361"A huge iron-walled cylinder which seems to throb lightly with restrained energy. Radiation symbols festoon the beige paint coating."
object_size#1r#29{14796, 1298433816}
hidden_verbs#1rc#361
list of 11{"hold", "stow", "@setup", "_turn_on", "_turn_off", "toast", "drink", "wash", "empty", "dump", "chug"}
phelp_msg#1rc#361<clear>
weight#1rc#361-1
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #338 generic liquid container#255 generic smashable thing#5 generic thing#1 root

Children: #265 reactor

Call graph

calls n134_2 #134:heartbeat n1_42 #1:occupants n134_2->n1_42 n20_34 #20:pronoun_sub n134_2->n20_34 n134_11 #134:fuel_use n134_2->n134_11 n134_4 #134:_turn_off n134_2->n134_4 n20_59 #20:name_and_number n134_2->n20_59 n134_1 #134:_unplug n134_2->n134_1 n134_4->n20_34 n150_2 #150:unregister n134_4->n150_2 n134_3 #134:_turn_on n134_3->n134_2 n134_3->n20_34 n45_2 #45:has_verb n134_3->n45_2 n150_0 #150:register n134_3->n150_0 n134_5 #134:look_self n338_1 #338:look_self n134_5->n338_1 n107_43 #107:tell n134_5->n107_43 n20_15 #20:capitalize n134_5->n20_15 n20_6 #20:english_list n134_5->n20_6 n47_3 #47:map_verb n134_5->n47_3 n1_31 #1:dname n134_5->n1_31 n134_6 #134:initialize n134_6->n150_0 n1_0 #1:initialize n134_6->n1_0 n134_7 #134:recycle n134_7->n150_2 n338_22 #338:recycle n134_7->n338_22 n134_9 #134:tree_tag n134_9->n20_59 n20_1 #20:left n134_9->n20_1 n134_10 #134:start n134_10->n1_42 n134_10->n20_34 n134_10->n134_3 n134_10->n107_43 n1_66 #1:announce_action_text n134_10->n1_66 n134_12 #134:entomb n134_12->n150_2 n338_34 #338:entomb n134_12->n338_34

Source

_plug

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1what = args[1];
2this.plugged_in = setadd(this.plugged_in, what);
3if (this.on)
4has_callable_verb(what, "_gain_power") && what:_gain_power(this);
5endif
6return 1;

_unplug

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

Source

1what = args[1];
2this.plugged_in = setremove(this.plugged_in, what);
3if (this.on)
4has_callable_verb(what, "_lose_power") && what:_lose_power(this);
5endif
6return 1;

heartbeat

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

Source

1if (!this.on)
2return;
3endif
4if (valid(this.fuel_type))
5fuel = this:occupants(this.fuel_type);
6if (fuel)
7(m = this.burn_fuel_msg) && this.location:announce_all($su:ps(m, this, this));
8fuel[1]:reduce_by(this:fuel_use());
9else
10this:_turn_off();
11return;
12endif
13endif
14for x in (this.plugged_in)
15if (!is_a(x, #1))
16this.plugged_in = setremove(this.plugged_in, x);
17elseif (`area(x).powerplant ! ANY => #-1' == this)
18has_callable_verb(x, "_charge") && x:_charge(this);
19elseif (x.location == this.location)
20has_callable_verb(x, "_charge") && x:_charge(this);
21elseif (gamevalid(`x.location.powerplant ! ANY => #-1'))
22"";
23else
24$nets.prognet:announce(#-1, (("unplugging " + $su:nn(x)) + " from ") + $su:nn(this), 1);
25this:_unplug(x);
26if (has_property(x, "powered_by"))
27x.powered_by = #-1;
28endif
29endif
30endfor

_turn_on

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

Source

1this.on = 1;
2this.power_on_msg && this.location:announce_all($su:ps(this.power_on_msg));
3for x in (this.plugged_in)
4$ou:has_verb(x, "_gain_power") && x:_gain_power(this);
5endfor
6"do one heartbeat -- we may not even be able to stay on.";
7this:heartbeat();
8if (!this.on)
9return;
10endif
11$heart:register(this);

_turn_off

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

Source

1this.on = 0;
2this.power_off_msg && this.location:announce_all($su:ps(this.power_off_msg));
3for x in (this.plugged_in)
4has_callable_verb(x, "_lose_power") && x:_lose_power(this);
5endfor
6$heart:unregister(this);

look_self

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1"Copied from portable generator (#110968):look_self by Chiyo (#143894) Thu Feb  5 02:07:42 2009 CST";
2pass(@args);
3if (valid(this.fuel_type))
4if ((length(this.contents) >= 1) && is_a(this.contents[1], #140609))
5level = 0;
6meter = "";
7metercount = 0;
8while (metercount < this.capacity)
9while (level <= this.contents[1].accumulation)
10meter = tostr(meter) + "|";
11metercount = metercount + 1;
12level = level + 1;
13endwhile
14meter = tostr(meter) + " ";
15metercount = metercount + 1;
16endwhile
17player:tell("A meter on the side shows the fuel level:", $ansi.yellow, " [", $ansi.bold_on, meter, $ansi.reset, $ansi.yellow, "]", $ansi.reset);
18else
19player:tell("A meter on the side shows the fuel level:", $ansi.yellow, " [               ]", $ansi.reset);
20endif
21endif
22if (length(this.plugged_in) >= 1)
23here = {};
24for x in (this.plugged_in)
25if (x.location == this.location)
26here = setadd(here, x);
27endif
28endfor
29player:tell($su:capitalize($su:english_list($lu:map_verb(here, "iname"))), (length(here) > 1) ? " are" | " is", " plugged into ", this:dname(), ".");
30endif

initialize

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1$heart:register(this);
2return pass(@args);

recycle

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1$heart:unregister(this);
2return pass(@args);

has_power

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1return this.on;

tree_tag

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1return tostr($ansi.cyan, $su:left($su:nn(this.location), -20), $ansi.reset);

start

Spec this none noneFlags rxdOwner #361Definer #134

Referenced by

none

Source

1if (this.on)
2player:tell("It's already on.");
3return;
4endif
5if (valid(this.spawn_liquid))
6if (!(fuel = this:occupants(this.spawn_liquid)))
7player:aat($su:ps(this.start_nofuel_msg, player, this));
8return;
9endif
10endif
11player:aat($su:ps(this.start_msg, player, this));
12this:_turn_on();

fuel_use

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

Source

1return 1;

entomb

Spec this none thisFlags rxdOwner #361Definer #134

Referenced by

none

Source

1"Copied from generic power plant (#1655):recycle by chill (#241405) Wed Jun  2 21:43:18 2010 CDT";
2$heart:unregister(this);
3return pass(@args);