generic switch #151

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

Aliases: generic switch

7 verbs · 39 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
switch_tothis none thisrxd#1518
switch turn change set throwthis any anyrxd#15115
on_resetthis none thisrxd#1511
look_selfthis none thisrxd#1512
tell_settingthis none thisrxd#1511
_finishthis none thisrxd#15115
_startthis none thisrxd#1511

Properties

PropertyDefinerFlagsOwnerValue
states#151rc#361{"on", "off"}
reset_state#151rc#361"off"
reveal_states#151rc#3611
switch_msg#151rc#361"%DN turns %dt to %state."
look_setting_msg#151rc#361"%DT is set to %state."
help_msg#151rc#361
list of 38{"The $switch is simply an immobile object which players can set to one of a selection of states (for instance, \"on\" and \"off\"). This does nothing on its own; however, you can read the switch's state from some other object and make changes elsewhere based on it, or have the switch notify other objects when its state changes.", "", "Properties:", "", "states = LIST", " A list of strings, naming all the states to which the switch can be set.", "", "reset_state = STR", " One of the above states -- the state to which the switch is set on an area reset.", "", "reveal_states = INT (boolean)", " If true, show the player all possible states if she tries to set the switch to an invalid state.", "", "listeners = LIST", " A list of objects with a :hear_switch(this, state) intended to hear state changes from this switch.", "", "state = STR (read-only)", " You can check this property to see what state the switch is in.", "", "", "Commands:", "", "switch/turn/set <this> to <any>", "turn <this> <any>", " The one and only player command for switches -- turn the switch to a different state.", "", "", "Verbs:", "", ":switch_to(STR state)", " Called when the player switches the switch to a new state. Also notifies any .listeners of the state change by calling listener:hear_switch(this, state).", "", ":on_reset()", " Resets the switch to its .reset_state.", "", ":tell_setting()", " When the player looks at the switch, this describes its state to her.", ""}
state#151rw#361"on"
listeners#151rc#361{}
bad_state_msg#151rc#361"%DT can't be set to '%state'."
handed#5rc#361<clear>
wield_msg#5rc#361<clear>
unwield_msg#5rc#361<clear>
size#5rc#361<clear>
look_place_msg#5rc#361"There is %it 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 switch"}
description#1rc#361"A simple electronic switch."
object_size#1r#29{6236, 1298433835}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361{"Seems to be a switch. Try using the 'turn <this> to <some setting>' command on it."}
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): #5 generic thing#1 root

Children: none

Call graph

calls n151_1 #151:switch n107_155 #107:hands n151_1->n107_155 n107_43 #107:tell n151_1->n107_43 n20_34 #20:pronoun_sub n151_1->n20_34 n20_6 #20:english_list n151_1->n20_6 n92_2 #92:queue_action n151_1->n92_2 n151_2 #151:on_reset n151_0 #151:switch_to n151_2->n151_0 n151_3 #151:look_self n1_9 #1:look_self n151_3->n1_9 n151_4 #151:tell_setting n151_3->n151_4 n151_4->n107_43 n151_4->n20_34 n151_5 #151:_finish n151_5->n20_34 n151_5->n20_6 n151_5->n151_0 n1_39 #1:dnamec n151_5->n1_39

Source

switch_to

Spec this none thisFlags rxdOwner #361Definer #151

Referenced by

Source

1state = args[1];
2who = (length(args) > 1) ? args[2] | #-1;
3if (state != this.state)
4this.state = state;
5endif
6for x in (this.listeners)
7x:hear_switch(this, state, who);
8endfor

switch turn change set throw

Spec this any anyFlags rxdOwner #361Definer #151

Referenced by

none

Source

1if (player:hands() < 1)
2player:tell("You don't have any functioning hands!  How frustrating.");
3return;
4endif
5nstate = iobjstr || prepstr;
6if (!(nstate in this.states))
7m = this.bad_state_msg;
8m = strsub(m, "%state", nstate);
9player:tell($su:ps(m, this, this));
10if (this.reveal_states)
11player:tell("It can be set to ", $su:english_list(this.states, "nothing", " or "), ".");
12endif
13return;
14endif
15player:queue_action(this, {nstate}, 1, "switch " + this.name);

on_reset

Spec this none thisFlags rxdOwner #361Definer #151

Referenced by

none

Source

1this:switch_to(this.reset_state);

look_self

Spec this none thisFlags rxdOwner #361Definer #151

Referenced by

none

Source

1pass(@args);
2this:tell_setting();

tell_setting

Spec this none thisFlags rxdOwner #361Definer #151

Referenced by

Source

1player:tell($su:ps(strsub(this.look_setting_msg, "%state", this.state), player, this));

_finish

Spec this none thisFlags rxdOwner #361Definer #151

Referenced by

none

Source

1who = args[1];
2nstate = args[2][1];
3if (!(nstate in this.states))
4m = this.bad_state_msg;
5m = strsub(m, "%state", nstate);
6who:tell($su:ps(m, this, this));
7if (this.reveal_states)
8who:tell("It can be set to ", $su:english_list(this.states, "nothing", " or "), ".");
9endif
10elseif (nstate == this.state)
11who:tell(this:dnamec(), " is already set to ", nstate, ".");
12else
13who:aat($su:ps(strsub(this.switch_msg, "%state", nstate), who, this));
14this:switch_to(nstate, who);
15endif

_start

Spec this none thisFlags rxdOwner #361Definer #151

Referenced by

none

Source

1return {1.0, 1};