generic switch #151
Aliases: generic switch
7 verbs · 39 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
switch_to | this none this | rxd | #151 | 8 |
switch turn change set throw | this any any | rxd | #151 | 15 |
on_reset | this none this | rxd | #151 | 1 |
look_self | this none this | rxd | #151 | 2 |
tell_setting | this none this | rxd | #151 | 1 |
_finish | this none this | rxd | #151 | 15 |
_start | this none this | rxd | #151 | 1 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
states | #151 | rc | #361 | {"on", "off"} |
reset_state | #151 | rc | #361 | "off" |
reveal_states | #151 | rc | #361 | 1 |
switch_msg | #151 | rc | #361 | "%DN turns %dt to %state." |
look_setting_msg | #151 | rc | #361 | "%DT is set to %state." |
help_msg | #151 | rc | #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 | #151 | rw | #361 | "on" |
listeners | #151 | rc | #361 | {} |
bad_state_msg | #151 | rc | #361 | "%DT can't be set to '%state'." |
handed | #5 | rc | #361 | <clear> |
wield_msg | #5 | rc | #361 | <clear> |
unwield_msg | #5 | rc | #361 | <clear> |
size | #5 | rc | #361 | <clear> |
look_place_msg | #5 | rc | #361 | "There is %it here." |
value | #5 | rc | #361 | <clear> |
get_msg | #5 | rc | #361 | <clear> |
drop_msg | #5 | rc | #361 | <clear> |
get_fail_msg | #5 | rc | #361 | <clear> |
junk_ok | #5 | rc | #361 | <clear> |
floats | #5 | rc | #361 | <clear> |
long_name_msg | #5 | rc | #361 | <clear> |
article | #5 | rc | #361 | <clear> |
setup_list | #5 | rc | #361 | <clear> |
health | #5 | rc | #361 | <clear> |
health_max | #5 | rc | #361 | <clear> |
min_skill | #5 | rc | #361 | <clear> |
skill | #5 | rc | #361 | <clear> |
recipe_for | #5 | rc | #361 | <clear> |
carried_msg | #5 | rc | #361 | <clear> |
aliases | #1 | rc | #361 | {"generic switch"} |
description | #1 | rc | #361 | "A simple electronic switch." |
object_size | #1 | r | #29 | {6236, 1298433835} |
hidden_verbs | #1 | rc | #361 | <clear> |
phelp_msg | #1 | rc | #361 | {"Seems to be a switch. Try using the 'turn <this> to <some setting>' command on it."} |
weight | #1 | rc | #361 | -1 |
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): #5 generic thing → #1 root
Children: none
Call graph
Source
switch_to
Referenced by
- #151:on_reset line 1:
this:switch_to - #151:_finish line 14:
this:switch_to
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
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
Referenced by
none
Source
1this:switch_to(this.reset_state);
look_self
Referenced by
none
Source
1pass(@args); 2this:tell_setting();
tell_setting
Referenced by
- #151:look_self line 2:
this:tell_setting
Source
1player:tell($su:ps(strsub(this.look_setting_msg, "%state", this.state), player, this));
_finish
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
Referenced by
none
Source
1return {1.0, 1};