Verb:plugIn
Instance of: adventurejs.Verb
Defined in: adventure/dictionary/verbs/plugIn.js, line 6
Tutorials: Subscriptions VerbAnatomy VerbProcess ModifyVerbs ModifyVerbs
Description
> plug computer into socket
You plug the ancient computer into the dusty socket. Nothing happens.
But wait! Was that a flicker of light? It was! A small red light blinks on.
And then another, and another as the ancient computer begins to wake.
You hear a deep thrumming sound that rises in pitch until it becomes a
painful screeching whine. And then silence. Until. The computer speaks!
"THIS WORLD IS MINE!" Uh oh.
PlugIn applies to the physical act of attaching one
asset to another, such as plugging in a computer.
PlugIn is distinct from the verb plug. If
asset.dov.plugIn.with_nothing
is true, players can input "plug in computer" without specifying a
particular asset to plug the computer into, and it will just be
implied that the computer is plugged into a wall outlet.
Conversely, in order to specify an asset such as an outlet to plug
the computer into, enter asset IDs into the computer's
asset.dov.plugIn.with_assets
.
This distinction exists so that authors can choose how fiddly
they want to get.
Note that plugIn is distinct from
Plug, which pertains to plugging things like
drains.
Demo
// PlugDemo.js
// ----------
/*global adventurejs PlugDemo*/
var PlugDemo = new adventurejs.Game("PlugDemo", "PlugDemoDisplay").set({
// title, version, and author are shown in the title bar
title: "Plug Demo",
version: "0.0.1",
author: "Ivan Cockrum",
description: "This is my great game! Thanks for playing!",
});
PlugDemo.settings.set({
// if this is true, lists of exits will
// show the names of rooms they lead to
show_room_names_in_exit_descriptions: true,
// if this is true, lists of exits will
// only include room names known to player
show_room_names_in_exit_descriptions_only_when_room_is_known: false,
// if this is true, lists of exits will only
// show room names for exits player has used
show_room_names_in_exit_descriptions_only_after_exit_has_been_used: false,
// if this is true, verbose room descriptions will be
// shown on first visit regardless of verbosity settings
print_verbose_room_descriptions_on_first_visit: true,
// if this is true, adventurejs will print
// debug messages to the game display
debug_keywords: { general: true },
// set this to set a default response to
// player input that is not understood
if_parser_has_no_response_print_this: "I have no response to your input. ",
// set this to provide a default
// response to blank input
if_input_is_empty_print_this: "I didn't see any input. ",
// alternately, game can be set to print
// the current room description with
// if_input_is_empty_print_room_description: true
});
PlugDemo.createAsset({
class: "Room",
name: "Plug Demo Foyer",
definite_article: "the",
descriptions: {
look: `Welcome to the Plug Demo, where you can try plugging and unplugging things with the verbs plug, plugIn and unplug. AdventureJS understands "plug" to have four distinct verb uses. Which one is applied in any given circumstance is determined by the verb subscriptions of the assets involved. Visit the other rooms in this demo to find some demonstrations. `,
brief: `Try verbs.
Plug,
plugIn,
unplug. `,
},
exits: {
north: "Plug Something Into Something",
south: "Plug Something Into Nothing",
east: "Plug Something With Nothing",
west: "Plug Something With Something",
},
}); // Plug Demo
PlugDemo.createAsset({
class: "Player",
name: "Mario",
place: { in: "Plug Demo Foyer" },
is: { active: true },
pronouns: "second",
});
// PlugSomethingIntoSomething.js
// ----------
/*global adventurejs A PlugDemo*/
PlugDemo.createAsset({
class: "Room",
name: "Plug Something Into Something",
descriptions: {
look: `This room contains a demonstration of plugging one asset into another. Try plugging the computer and the printer into the outlet. This is handled through the verb subscription for plugIn on the computer, printer and outlet. See the example code in PlugSomethingIntoSomething.js for particulars. `,
brief: "You can plug one thing into another here. ",
},
exits: { south: "Plug Demo Foyer" },
}); // Plug Something Into Something
PlugDemo.createAsset({
class: "Desk",
name: "workstation",
place: { in: "Plug Something Into Something" },
descriptions: {
look: "This computer workstation has ample room for appliances. A two-socket brass outlet is set flush into the workstation's surface. ",
},
aspects: { attached: { list_contents_in_room: true } },
});
PlugDemo.createAsset({
class: "Computer",
name: "computer",
synonyms: ["monitor", "keyboard", "mouse"],
place: { on: "workstation" },
descriptions: {
look: function () {
let msg =
"It's a honking big old desktop computer. It is currently {computer [is] plugged in [or] unplugged}. ";
let file = PlugDemo.$("file");
if (file.is.created && file.$is("on", "computer")) {
msg += `The desktop shows a single file. `;
}
return msg;
},
},
aspects: { on: { with_assets: ["file"] } },
dov: {
plugIn: {
with_assets: ["brass outlet"],
on_success: function () {
if (PlugDemo.$("file").is.created) {
// Here we're using a simple hack to move a file
// when the computer is plugged/unplugged.
PlugDemo.$("file").setPlace("on", "computer");
}
return "BOUMMMMMMmmmmmmmm. The computer starts up with a deep bassy power chord. ";
},
on_first_success: function () {
PlugDemo.scorecard.completeEvent("plug in any computer part");
return this.dov.plugIn.on_success();
},
},
unplug: {
on_success: function () {
PlugDemo.$("file").setPlace();
return "BEEEooop. The computer display shrinks to a point, then goes black. ";
},
on_first_success: function () {
PlugDemo.scorecard.completeEvent("unplug any computer part");
return this.dov.unplug.on_success();
},
},
},
});
PlugDemo.createAsset({
class: "Printer",
name: "printer",
synonyms: ["fan"],
place: { on: "workstation" },
descriptions: {
look: "It's a massive heavy old laser printer. It is currently {printer [is] plugged in [or] unplugged}. ",
// You can set a variety of different descriptions
// for specific verbs / situations.
// See /doc/NextSteps_Descriptions.html for more info.
listen: () =>
PlugDemo.$("printer").$is("pluggedIn")
? "The printer's fan wheezes like an asthmatic in an iron lung. "
: "The printer is ominously silent. ",
},
aspects: { on: { with_assets: ["counterfeit bill", "dollar bill"] } },
dov: {
plugIn: {
with_assets: ["brass outlet"],
on_success:
"The printer's internal fan spins up with a series of clicks, clanks and whooshes. ",
// We've set all three computer parts to complete
// the same score event, "plug in any computer part".
// We can do that because score events only get
// counted one time.
on_first_success: function () {
PlugDemo.scorecard.completeEvent("plug in any computer part");
return this.dov.plugIn.on_success;
},
},
unplug: {
on_success: "The printer shuts down with a wheeze. ",
on_first_success: function () {
PlugDemo.scorecard.completeEvent("unplug any computer part");
return this.dov.unplug.on_success;
},
},
},
});
PlugDemo.createAsset({
class: "Scanner",
name: "scanner",
place: { on: "workstation" },
descriptions: {
look: "It's a chonky old scanner. It is currently {scanner [is] plugged in [or] unplugged}. ",
},
aspects: { on: { with_assets: ["dollar bill"] } },
dov: {
plugIn: {
with_assets: ["brass outlet"],
on_success: function () {
let msg = PlugDemo.$("scanner").is.broken
? `The scanner chunks like it's trying to power up, but then fritzes out and goes silent. `
: `The scan head ratchets back and forth trying to find a registration point. `;
return msg;
},
on_first_success: function () {
PlugDemo.scorecard.completeEvent("plug in any computer part");
return this.dov.plugIn.on_success();
},
},
unplug: {
on_success: "The scanner shuts down with a loud chunk. ",
on_first_success: function () {
PlugDemo.scorecard.completeEvent("unplug any computer part");
return this.dov.unplug.on_success;
},
},
},
});
PlugDemo.createAsset({
class: "Outlet",
name: "brass outlet",
synonyms: ["socket", "sockets"],
place: { attached: "workstation" },
description: () => {
let computer_is_plugged = PlugDemo.$("computer").isConnectedToAsset(
"plugIn",
"brass_outlet",
"to_iov"
);
let printer_is_plugged = PlugDemo.$("printer").isConnectedToAsset(
"plugIn",
"brass_outlet",
"to_iov"
);
let both_are_plugged = computer_is_plugged && printer_is_plugged;
let msg = `It's a two-socket outlet made of polished brass and set flush into the surface of the workstation. `;
if (both_are_plugged) msg += `The computer and the printer are both `;
else if (computer_is_plugged) msg += `The computer is `;
else if (printer_is_plugged) msg += "The printer is ";
msg += `plugged into it. `;
return msg;
},
is: { known: true },
dov: { unplug: true },
iov: {
plugIn: {
with_assets: ["computer", "printer"],
with_params: { max_connections: 2 },
},
},
});
PlugDemo.createAsset({
class: "Thing",
name: "file",
synonyms: [],
adjectives: [],
place: {},
descriptions: { look: "A single file sits on the computer's desktop. " },
dov: { print: true },
});
/* *
* Here's a bonus code example that demonstrates a method for
* creating custom verbs. We set up "scan" and "print" to work
* with the scanner and printer. The logic in this example is much
* less robust than the built-in verbs but shows some things
* authors can do with custom verbs. Another way to handle
* specialized verbs might be to consider a verb like "use"
* which could account for the context of the supplied objects
* and route to an appropriate block of code.
*/
PlugDemo.createVerb({
name: "scan",
do: function () {
/**
* Most verbs use doTry, doSuccess, etc. The main reason for
* those verb phases is to create hooks for authors. If you're
* writing your own verb from scratch for your own purposes,
* you needn't write all those. All your verb needs is a "do"
* function.
*/
let input = PlugDemo.getInput();
let direct_object = input.getAsset(1);
let scanner = PlugDemo.$("scanner");
let character = PlugDemo.getInput().getSubject();
if (scanner.is.broken) {
PlugDemo.print(`Sadly, the scanner has scanned its last scan. `);
return null;
}
if (!direct_object) {
if (PlugDemo.$("dollar bill").$is("on", "scanner")) {
direct_object = PlugDemo.$("dollar bill");
} else {
PlugDemo.print(`There's nothing scannable on the scanner. `);
return null;
}
}
if (direct_object && direct_object.id !== "dollar_bill") {
PlugDemo.print(`{We} can't scan ${direct_object.articlename}. `);
return null;
}
if (!direct_object.$is("on", "scanner")) {
PlugDemo.print(`The dollar bill is not on the scanner. `);
return null;
}
if (!scanner.$is("pluggedIn")) {
PlugDemo.print(`The scanner is not plugged in. `);
return null;
}
if (!PlugDemo.$("computer").$is("pluggedIn")) {
PlugDemo.print(`The computer is not plugged in. `);
return null;
}
// ok to scan!
PlugDemo.print(`The scanner ratchets noisily and passes a bright light
across the bill. A new file appears on the computer.
But, uh oh, the scanner fritzes and sparks and grinds to a halt. `);
// Note that is.broken is not a default property
// Authors can create new properties at will.
// Just try not to override existing properties.
PlugDemo.scorecard.completeEvent("scan dollar");
let file = PlugDemo.$("file");
file.setPlace("on", "computer");
character.knowAsset(file, false);
character.seeAsset(file, false);
scanner.setIs("broken", true);
return true;
},
});
PlugDemo.createVerb({
name: "print",
do: function () {
let input = PlugDemo.getInput();
let direct_object = input.getAsset(1);
let printer = PlugDemo.$("printer");
let character = PlugDemo.getInput().getSubject();
if (printer.is.broken) {
PlugDemo.print(`Sadly, the printer has printed its last print. `);
return null;
}
if (!direct_object) {
if (PlugDemo.$("file").$is("on", "computer")) {
direct_object = PlugDemo.$("file");
} else {
PlugDemo.print(`There's nothing printable on the computer. `);
return null;
}
}
if (direct_object && direct_object.id !== "file") {
PlugDemo.print(`{We} can't print ${direct_object.articlename}. `);
return null;
}
if (!direct_object.$is("on", "computer")) {
PlugDemo.print(`{We} {don't} know of any file. `);
return null;
}
if (!printer.$is("pluggedIn")) {
PlugDemo.print(`The printer is not plugged in. `);
return null;
}
if (!PlugDemo.$("computer").$is("pluggedIn")) {
PlugDemo.print(`The computer is not plugged in. `);
return null;
}
// ok to scan!
PlugDemo.print(`The printer clicks and whooshes and spits
out a counterfeit bill.
Now {we} have two dollars! But, uh oh, the printer grinds
to a stop with a very final sounding kerchunk. At least
{we} can pay the paperboy. `);
// Note that is.broken is not a default property
// Authors can create new properties at will.
// Be sure they don't conflict with existing properties!
let counterfeit = PlugDemo.$("counterfeit bill");
counterfeit.moveTo("on", "printer");
character.knowAsset(counterfeit, false);
character.seeAsset(counterfeit, false);
printer.setIs("broken", true);
PlugDemo.scorecard.completeEvent("print dollar");
return true;
},
});
PlugDemo.createAsset({
class: "Paper",
name: "counterfeit bill",
synonyms: ["dollar", "money", "paper"],
adjectives: [],
// article: "the",
// we don't set an initial place for this because it
// will be placed during gameplay
// place: { on: "printer" },
descriptions: { look: `It's a counterfeit dollar bill! ` },
});
// PlugSomethingIntoNothing.js
// ----------
/*global adventurejs A PlugDemo*/
PlugDemo.createAsset({
class: "Room",
name: "Plug Something Into Nothing",
descriptions: {
look: `This room contains a demonstration of plugging an asset into nothing. Try plugging in the radio. An outlet is implied but no asset is created for it. This is handled through the verb subscription for plugIn on the radio. See the example code in PlugSomethingIntoNothing.js for particulars. `,
brief: "You can plug a thing into nothing here. ",
},
exits: { north: "Plug Demo Foyer" },
}); // Plug Something Into Nothing
PlugDemo.createAsset({
class: "Desk",
name: "worn secretary",
place: { in: "Plug Something Into Nothing" },
descriptions: {
look: "It's an old wooden secretary. Once of high quality, now very worn. ",
},
adjectives: "wooden, plain",
});
PlugDemo.createAsset({
class: "Radio",
name: "old fashioned radio",
indefinite_article: "an",
place: { on: "worn secretary" },
descriptions: {
look: () =>
`The old fashioned radio is finished in polished mahogany with a herringbone patterned grill cloth. The on/off button seems to be broken but {we} can plug it in to turn it on. Currently it is ${
PlugDemo.$("old fashioned radio").$is("pluggedIn")
? "plugged in and playing"
: "unplugged and silent"
}. `,
},
dov: {
plugIn: {
with_nothing: true,
// there are several ways to use on_success
// it can return a string or an array or a function
// return a string
// on_success: 'The radio emits a crackle of static. ',
// return a different string from an array each time
// on_success: [
// 'The radio crackles. ',
// 'The radio emits a burst of static. ',
// '{We} feel a small tingle of electricity from the worn plug. '
// ],
// return the results of a traditional function
// if you need scope, use this
on_success: function () {
// console.log( this ); // returns radio
// registerInterval is used to set an event that
// occurs every turn. In this case, emit is a
// function that prints an output from the radio,
// but only if the user is in the room with it.
this.game.registerInterval({ id: this.id, callback: "emit" });
// If you want to print from an array of strings
// without custom logic, you can register an array
// rather than a function, like so
// this.game.registerInterval( this.id, "emit_clips" );
return "The radio emits a crackle of static. ";
},
// return the results of an arrow function
// you can do this but it won't have scope
// on_success: ()=> {
// console.log( this ); // returns window
// return 'The radio emits a crackle of static. ';
// },
// Here, we want to call a different function
// the first time the player plugs in the radio,
// but we also want to call the every-time function.
on_first_success: function () {
PlugDemo.scorecard.completeEvent("plug in radio");
return this.dov.plugIn.on_success();
},
},
unplug: {
with_nothing: true,
on_success: function () {
this.game.unregisterInterval(this.id, "emit_clips");
return "The radio shuts off with a clipped burst of static. ";
},
// Here, we want to call a different function
// the first time the player unplugs the radio,
// but we also want to call the every-time function.
on_first_success: function () {
PlugDemo.scorecard.completeEvent("unplug radio");
return this.dov.unplug.on_success();
},
// then_destroy is a property to destroy an asset
// after a verb has been applied to it.
// then_destroy can return a string,
// or a string from an array, or results of a function.
// Regardless of which is used, the asset will
// be destroyed, aka removed from the game world.
// then_destroy: function(){
// return 'As {we} extract the worn plug, a burst of electricity races up the threadworn cord. The radio bursts into fire and explodes into pieces! ';
// },
// Any string returned will be appended to the
// turn's output.
// You can also print output directly if you like.
// That way it will precede the turn's output.
// then_destroy: function(){
// this.game.print('DESTROY!');
// },
},
},
// We're using emit() as a function to call on every turn.
// It's our common convention to use the name emit but it
// is arbitrary; you can add whatever properties you like.
emit: function () {
var msg = "";
// We use this opportunity to add some custom logic.
// Is the player in the room with this radio?
if (this.getRoomId() === this.game.getRoom().id) {
// If so grab a random string from emit_clips.
msg +=
this.emit_clips[Math.floor(Math.random() * this.emit_clips.length)];
} else {
// Otherwise print a "distant sound" message.
msg += "A muffled radio broadcast emanates from some other room. ";
}
this.game.print(msg);
},
// emit_clips is an arbitrary property added to this asset
emit_clips: [
"A tinny voice from the radio announces an upcoming Cubs game. ",
"The radio's speaker vibrates with an attenuated tuba solo.",
"A pitchman hawks Sudzo Soap on the radio. ",
"The radio plays that big band sound complete with oomphas. ",
"The radio broadcast is interrupted by an announcer breaking in to warn of a Martian attack. ",
"The radio emits a brassy jazz number punctuated by staccato bursts of tap. ",
"Judy Garland warbles on the radio. ",
"The radio announcer promises that justice will be served on an upcoming episode of The Shadow. ",
],
}); //
// PlugASinkWithAPlug.js
// ----------
/*global adventurejs A PlugDemo*/
PlugDemo.createAsset({
class: "Room",
name: "Plug Something With Something",
descriptions: {
look: `This room contains a demonstration of plugging a drain with a plug. Try plugging and unplugging the drain. This is handled through the verb subscription for plug on the sink drain and the plug. See the example code under PlugSomethingWithSomething.js for particulars. `,
brief: "Try to plug and unplug the sink. ",
},
exits: { east: "Plug Demo Foyer" },
}); // Plug Something With Something
// sink
PlugDemo.createAsset({
class: "Table",
name: "bathroom counter",
place: { in: "Plug Something With Something" },
description: "The neat bathroom counter is surfaced in white tile. ",
adjectives: "white, tile",
});
// This vessel sink is a complex asset with
// linked components. The components will be registered
// during initialization to create relationships
// between them.
PlugDemo.createAsset({
class: "Sink",
name: "vessel sink",
place: { on: "bathroom counter" },
descriptions: {
look: function () {
let msg = `A vessel sink with porcelain handles and a stainless steel faucet. Its drain appears to be {sink drain [is] plugged [or] unplugged}. `;
if (PlugDemo.$("dollar bill").$is("in", "sink drain")) {
msg += PlugDemo.$("dollar bill").$is("in", "sink drain")
? `Something odd about the drain demands a closer inspection. `
: ``;
}
return msg;
},
},
aspects: { attached: { know_contents_with_parent: true } },
components: [
"sink's hot water handle",
"sink's cold water handle",
"sink faucet",
"sink drain",
"sink plug",
],
});
PlugDemo.createAsset({
class: "Plug",
name: "sink plug",
synonyms: "plug",
place: { on: "bathroom counter" },
description: "A sink drain plug. ",
});
PlugDemo.createAsset({
class: "Drain",
name: "sink drain",
synonyms: "sink drain",
descriptions: {
look: function () {
let msg = `The dark drain is currently { sink drain [is] plugged [or] unplugged }`;
if (PlugDemo.$("dollar bill").$is("in", "sink drain")) {
msg += PlugDemo.$("dollar bill").$didDo("take")
? `, and the dollar bill has been rolled up and stuffed into it`
: `, but there appears to be a small tube sticking out of it`;
}
msg = msg.trim();
msg += `. `;
return msg;
},
},
aspects: {
in: {
contents_limits: {
count: 2, // to account for plug and dollar bill
},
},
},
// If you look through all the instances of
// PlugDemo.scorecard.complete, you can see that we're doing
// something a little different here. In other instances
// we're calling scorecard.completeEvent from verb subscriptions.
// But in the case of plugging a sink with a drain, players
// should be able to achieve that via "plug sink with drain"
// OR via "put plug in drain". Both are equally valid.
// In order to capture both verbs, we're going to use
// verb reactions. These are called whenever common events result
// from whatever verb. Moving one thing into another thing
// could be the result of a half dozen different verbs,
// and we want to execute some code regardless of which verb
// was used. To learn more, see /doc/Verbs_ReactionHooks.html
doMoveThatToThis: {
"sink plug": function () {
let msg = `{We} plug the sink by putting the plug in the drain. `;
// overrideOutput will replace any other output with this msg.
this.game.overrideOutput(msg);
PlugDemo.scorecard.completeEvent("put plug in sink");
return;
},
},
doRemoveThatFromThis: {
"sink plug": function () {
let msg = `{We} unplug the sink by pulling the sink plug from the sink drain. `;
this.game.overrideOutput(msg);
PlugDemo.scorecard.completeEvent("remove plug from sink");
return;
},
},
});
PlugDemo.createAsset({
class: "Faucet",
name: "sink faucet",
synonyms: ["faucet"],
adjectives: ["stainless steel"],
description: "The sink faucet. ",
substance_id: "water",
max_volume_of_flow_per_turn: 1000,
});
PlugDemo.createAsset({
class: "FaucetHandle",
name: "sink's hot water handle",
synonyms: ["handle", "sink handle"],
adjectives: ["hot water", "sink", "porcelain"],
description: "The sink's hot water handle. ",
set_substance_id: "water",
set_substance_temperature: 70,
});
PlugDemo.createAsset({
class: "FaucetHandle",
name: "sink's cold water handle",
synonyms: ["handle", "sink handle"],
adjectives: ["cold water", "sink", "porcelain"],
description: "The sink's cold water handle. ",
set_substance_id: "water",
set_substance_temperature: 15,
});
PlugDemo.createAsset({
class: "Collection",
name: "sink handles",
synonyms: ["porcelain handles"],
place: { attached: "vessel sink" },
collection: ["sink's hot water handle", "sink's cold water handle"],
is: { listed: false },
description: "Two porcelain sink handles, hot and cold. ",
});
PlugDemo.createAsset({
class: "PaperMoney",
name: "dollar bill",
synonyms: ["one", "tube", "money", "paper"],
adjectives: ["small"],
// article: "the",
place: { in: "sink drain" },
descriptions: {
look: function () {
let msg = PlugDemo.$("dollar bill").$is("in", "sink drain")
? `The small tube seems to be a rolled up piece of paper. `
: `It's a one dollar bill featuring George Washington with an old fashioned twirly mustache drawn on in black ink. `;
return msg;
},
},
dov: {
take: {
on_first_success: function () {
let msg =
"{We} pull out the tube and discover that it's a rolled up dollar bill! You unroll it and flatten it out. ";
PlugDemo.overrideOutput(msg);
//return null;
},
},
put: {
on_success: function () {
if (this.$is("in", "sink drain")) {
let msg = `{We} roll up the dollar bill and stuff it back in the sink drain. `;
PlugDemo.overrideOutput(msg);
}
},
},
},
});
// PlugThis.js
// ----------
/*global adventurejs A PlugDemo*/
PlugDemo.createAsset({
class: "Room",
name: "Plug Something With Nothing",
descriptions: {
look: `This room contains a demonstration of plugging and unplugging an asset without the aid of a plug. Try plugging and unplugging the sink. This is handled through the verb subscription for plug on the sink. See the example code under PlugSomethingWithNothing.js for particulars. `,
brief: "Try to plug and unplug the sink. ",
},
exits: {
west: "Plug Demo Foyer",
},
}); // Plug Something With Nothing
PlugDemo.createAsset({
class: "Sink",
name: "simple pedestal sink",
place: { in: "Plug Something With Nothing" },
descriptions: {
look: () =>
`It's a simple pedestal sink that {we} can plug and unplug. Right now it is ${
PlugDemo.$("simple pedestal sink").$is("plugged")
? "plugged"
: "unplugged"
}. `,
},
dov: {
plug: {
with_nothing: true,
on_first_success: function () {
PlugDemo.scorecard.completeEvent("plug sink");
return "TADA! ";
},
},
unplug: {
with_nothing: true,
on_first_success: function () {
PlugDemo.scorecard.completeEvent("unplug sink");
return "It's probably less exciting than you were imagining. ";
},
},
},
}); //
// Scorecard.js
// ----------
/*global adventurejs PlugDemo*/
PlugDemo.scorecard.set({
// aggregate_updates determines how score updates
// are printed. With aggregate_updates set to true,
// if multiple score events occur in a turn, only
// one score update will be printed, with the
// cumulative score change. If aggregate_updates are
// false, each score update will be printed, and will
// use unique score_message that may be provided.
aggregate_updates: false,
// This is how you set score events for your game.
// You can add as few or as many as you like,
// and set points to whatever number you like.
// The names are up to you, so set them however you like.
score_events: {
"plug sink": 1,
"unplug sink": 1,
"put plug in sink": 1,
"remove plug from sink": 1,
"plug in radio": 1,
"unplug radio": 1,
"plug in any computer part": 1,
"unplug any computer part": 1,
// Let's say you want the game to start with
// some points already set. You can do that like this.
"preset points": { points: 5, complete: true, recorded: true },
// You can set negative points too. These preset
// and unset points cancel each other out.
"unset points": { points: -5, complete: true, recorded: true },
// You can also assign "bonus" points. These won't be
// counted in the total, allowing player to earn a
// score like 110/100.
// Customize the score message by setting score_message
// to a string or array or function.
"scan dollar": {
points: 1,
bonus: true,
message: "[ ** {We} got a bonus point! ** ]",
},
"print dollar": {
points: 1,
bonus: true,
message: "[ ** {We} got a bonus point! ** ]",
},
},
});
Source files
plugIn verb logic
Verb logic falls into a few recognizable patterns. Direction verbs tend to be simple and redirect to tryTravel()
. Manipulation verbs test whether one asset is allowed to interact with another asset. Locomotion verbs test the player's current ability to move in a specified way. Many verbs are similar, but no two verbs are identical. Each verb has its quirks. If you would like to learn more about general verb logic, we recommend you see the Verb Anatomy and Verb Process pages. Verb phases and verb actions / reactions offer various hooks to customize verb behavior. If you find that you want still more flexibility, you may want to investigate the patchVerb method, which lets you replace entire blocks of verb code. You can also write verbs from scratch if you're so inclined. See Modify Verbs for a complete list of verb modification methods.
The following sections provide information that is specific to the verb plugIn
, though they include many features which are common to most verbs.
- Verb Demo
- Sentence Structures help filter player input by defining what sentence structures
plugIn
can handle. - Verb Phrases describe the direct and indirect objects that
plugIn
can handle. - Verb Subscriptions enable
plugIn
to act on specific assets, and provide a collection of properties for customizing those interactions. - Verb Phases offer a broad method for authors to hook into default logic and override it with custom code.
- Verb Actions offer a surgical method for authors to hook into
plugIn
's default logic and inject custom code. - Verb Reactions are Verb Actions that occur as secondary effects of successfully applying
plugIn
. - Verb Params contain properties that are distinct to
plugIn
. Not all verbs have params. - Verb Methods lists the methods that
plugIn
inherits from the Verb class. - Verb Properties lists the properties that
plugIn
inherits from the Verb class.
plugIn sequencing
plugIn subscriptions
An asset must be subscribed to a verb for that verb to act upon that asset (with some exceptions). Though verbs are universal, each asset's verb subscriptions are distinct objects that can be used to customize how a given verb interacts with a given asset. To say it another way, a verb subscription is a collection of properties that defines how a verb should be applied to an asset; which allow authors to override a verb's default behaviors on a per-asset basis.
It's important to note that verb subscriptions need to be declared as direct or indirect, depending on whether the asset will be used as a direct object or indirect object. In the case of "unlock lock with key", the lock is the direct object and the key is the indirect object, and each asset needs to be subscribed to unlock in the appropriate way. (It's allowed, and a common pattern, to subscribe assets directly and indirectly to the same verb.)
Expand for example
MyGame.createAsset({
class: "Lock",
name: "lock",
dov: { unlock: true },
});
MyGame.createAsset({
class: "Key",
name: "key",
iov: { unlock: true },
});
As shown in the above example, dov: { unlock: true }
is the minimum that is required to subscribe an asset to a verb. However, verb subscriptions have many properties that can be used to customize how this verb is applied to this asset. (Setting any property eliminates the need to set verb: true
. ) Below is a list of verb subscription properties that authors may find useful.
automatically
allows for some verbs to be performed automatically if context calls for it; for example, when unlocking a door in order to pass through it. This takes precedence over global settings.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { automatically: true } }, });
automatically_after_use
if automatically is set true, this sets it so that a verb can only be applied automatically after a player has already used it manually. This is to prevent automatic use of tools from breaking puzzles. For example, imagine one door with many keys but only one that works; if choosing the right key is part of the puzzle, this option prevents players from simply saying "unlock door" and having the right key automatically selected for them.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { automatically_after_use: true } }, });
doBeforeTry
Verb phases provide methods to override default verb behaviors. See the verb phases section on this page to learn more aboutplugIn
's verb phases.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { doBeforeTry: function (e) { console.log("plugIn.doBeforeTry"); }, } }, });
doAfterTry
Verb phases provide methods to override default verb behaviors. See the verb phases section on this page to learn more aboutplugIn
's verb phases.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { doAfterTry: function (e) { console.log("plugIn.doAfterTry"); }, } }, });
doBeforeSuccess
Verb phases provide methods to override default verb behaviors. See the verb phases section on this page to learn more aboutplugIn
's verb phases.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { doBeforeSuccess: function (e) { console.log("plugIn.doBeforeSuccess"); }, } }, });
doAfterSuccess
Verb phases provide methods to override default verb behaviors. See the verb phases section on this page to learn more aboutplugIn
's verb phases.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { doAfterSuccess: function (e) { console.log("plugIn.doAfterSuccess"); }, } }, });
enabled
allows changing the state of an asset's responsiveness to a given verb. If set false, a subscribed asset will not respond to the verb. This is useful for temporarily disabling verbs for specific assets; for example, if you had a door that could not be unlocked until another action was completed. Authors can enable or disable an individual verb subscription viaasset.setDOV(verbname)
andasset.unsetDOV(verbname)
Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { enabled: true } }, });
on_success
is an optional parameter. It is set as a string by default, but authors may provide a string or array or function to be served by getStringOrArrayOrFunction(). The resulting string will be appended to the verb's default success message.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { on_success: "You plugIn the thing. " } }, });
on_first_success
is an optional parameter. It is set as a string by default, but may provide a string or array or function to be served by getStringOrArrayOrFunction(). The resulting string will be appended to the verb's default success message the first time it is applied to this asset.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { on_first_success: "You plugIn the thing the first time. " } }, });
on_failure
is an optional parameter. It is set as a string by default, but may provide a string or array or function to be served by getStringOrArrayOrFunction(). The resulting string will be appended to the verb's default failure message.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { on_failure: "You failed to plugIn the thing. " } }, });
on_first_failure
is an optional parameter. It is set as a string by default, but may provide a string or array or function to be served by getStringOrArrayOrFunction(). The resulting string will be appended to the verb's default failure message the first time it is applied to this asset.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { on_first_failure: "You failed to plugIn the thing the first time. " } }, });
once
if true, the verb can only be applied once to the asset. The verb subscription will be disabled after use.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { once: true } }, });
then_destroy
allows author to specify that this asset should be destroyed after using. If then_destroy is set, the asset will be destroyed after a single use regardless of how once is set. By default, then_destroy is set to a boolean. It may optionally be set to string or array or function subject to getStringOrArrayOrFunction(). If any of those types are found, they will be called and returned as results.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { then_destroy: true } }, });
with_anything
pertains only to indirect objects. If true, this asset can be used as an indirect object of this verb with any direct object.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", iov: { plugIn: { with_anything: true } }, });
with_assets
allows author to specify particular assets that can interact with this one using the given verb. For example "unlock door with key" where the specified key is the only asset that can unlock door. This works distinctly for direct and indirect verb subscriptions. So, for instance, in "unlock door with key", the door might have a direct object subscription, while the key has an indirect object description.Expand for example
MyGame.createAsset({ class: "Door", name: "gold door", dov: { unlock: { with_assets: [ "gold key" ] } }, }); MyGame.createAsset({ class: "Key", name: "gold key", iov: { unlock: { with_assets: [ "gold door" ] } }, });
with_classes
allows author to specify particular classes that can interact with this asset using the given verb. For example "unlock door with skeleton key" where any instance of the class SkeletonKey can unlock door. This works distinctly for direct and indirect verb subscriptions. So, for instance, in "unlock door with skeleton key", the door might have a direct object subscription, while the key has an indirect object description.Expand for example
MyGame.createAsset({ class: "Door", name: "red door", dov: { unlock: { with_classes: [ "SkeletonKey" ] } }, }); MyGame.createAsset({ class: "SkeletonKey", name: "skeleton key", iov: { unlock: { with_classes: [ "Door", "Chest" ] } }, });
with_nothing
pertains only to direct objects. If true, the specified verb can be applied to the direct object without the use of any indirect object.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { with_nothing: true } }, });
with_params
is used to contain a set of parameters that are specific to this particular verb. For example, plugIn includeswith_params.max_connections
for setting limits on how many other assets this asset can be plugged in to. See the with_params section on this page to learn more aboutplugIn
's parameters.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { with_params: { max_connections: 1, on_take_break_connections: true, on_take_take_connections: false, } } }, });
with_prepositions
allows author to explicitly permit certain prepositions to be used with a verb on this object. For instance: "knock over umbrella stand" might fail with a message of "you can't knock over the umbrella stand"; settingumbrella_stand.dov.knock.with_prepositions = ["over"]
will allow the action to succeed.Expand for example
MyGame.createAsset({ class: "Thing", name: "universal widget", dov: { plugIn: { with_prepositions: [ "through", "over" ] } }, });
Notes
- To learn more about working with verb subscriptions, see Verb Subscriptions.
- These are most, but not all, of the properties of a verb subscription. For full reference, see the VerbSubscription class.
plugIn sentence structures
accepts_structures: [
"verb noun",
"verb noun noun",
"verb noun preposition noun"
]
The parser uses multiple filtering methods to try to channel player input into useable tokens. Sentence structures are defined for each verb in order to narrow down the input that the verb can handle. For example, the verb "hit" might accept "verb noun" as in "hit troll", or "verb noun preposition noun" as in "hit troll with sword", whereas an intransitive verb like "jump" might accept "verb" as a complete sentence. Input that isn't accepted will return a warning to the player.
A note about adverbs: though the parser does handle some adverbs, such as "carefully examine tiara" and "turn left", it excludes them from consideration in sentence structures. Due to the slipperyness of the English language, an adverb can appear in multiple positions in a sentence while still describing the same verb, which presents enough possible word combinations to make sentence structures less useful as a filtering tool. Instead, the parser puts adverbs aside and handles them separately.
Notes
- It is possible for authors to modify a verb's structures through the use of patchVerb.
- To learn more about modifying verbs, see Modify Verbs.
plugIn phrases
phrase1:
{
accepts_noun: true,
requires_noun: true,
noun_must_be:
{
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
//accepts_preposition: true,
//preposition_must_be: ["in"],
},
phrase2:
{
accepts_noun: true,
//requires_noun: true,
noun_must_be:
{
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
accepts_preposition: true,
//requires_preposition: true,
//preposition_must_be: [ "to" ],
},
The AdventureJS parser uses multiple filtering methods to try to interpret player input. A verb's phrases may consist of a noun and/or a preposition. Whether any noun is defined as a direct or indirect object is up to that verb's unique logic. Each verb defines a unique set of phrases depending on what its logic can handle. Verbs may handle zero, one, two, or three nouns. The nested noun_must_be object sets conditional qualifiers to help narrow down assets that the verb might act upon. Input that isn't accepted will return a warning to the player.
Notes
- It is possible for authors to modify a verb's phrases through the use of patchVerb.
- To see a list of properties that can be set for phrases, see the Phrase class.
- To see a list of properties that can be set for phrase.noun_must_be, see the NounMustBe class.
- To learn more about modifying verbs, see Modify Verbs.
plugIn phase hooks
Verb phase hooks let authors override verb subscriptions for specific assets when plugIn
is applied to them. This is a broad method for customizing verb/noun interactions on a per-asset basis. For example, an author might supply completely different logic for "throw feather" vs "throw baseball" vs "throw anvil".
When plugIn.do()
is called, it attempts to run a sequence of methods, or phases, as listed below. The four hooks have no default logic of their own but provide methods to inject custom code at any point in the life cycle of the verb action. See below for examples of how to use verb phases for plugIn
.
do
doBeforeTry hook
MyGame.createAsset({
class: "Thing",
name: "This Asset",
dov: {
plugIn: {
doBeforeTry: function( params )
{
let msg = `You're about to try to plugIn ${this.articlename}. `;
this.game.print(msg);
return;
},
},
},
});
doTry handles logic to determine if plugIn can be applied
doAfterTry hook
MyGame.createAsset({
class: "Thing",
name: "This Asset",
dov: {
plugIn: {
doAfterTry: function( params )
{
let msg = `You just tried to plugIn ${this.articlename}! `;
this.game.print(msg);
return;
},
},
},
});
doBeforeSuccess hook
MyGame.createAsset({
class: "Thing",
name: "This Asset",
dov: {
plugIn: {
doBeforeSuccess: function( params )
{
let msg = `You're about to succeed in performing plugIn on ${this.articlename}. `;
this.game.print(msg);
return;
},
},
},
});
doSuccess handles state changes and printing messages
doAfterSuccess hook
MyGame.createAsset({
class: "Thing",
name: "This Asset",
dov: {
plugIn: {
doAfterSuccess: function( params )
{
let msg = `You succeeded in performing plugIn on ${this.articlename}. `;
this.game.print(msg);
return;
},
},
},
});
Expand for example
Assets must have separate direct and indirect verb subscriptions. Consider this singing sword, which is directly subscribed to the verb "take". We want our game to print a custom message when the player tries to take the sword, and a different message when the player succeeds in taking it.
MyGame.createAsset({
class: "Sword",
name: "singing sword",
dov: {
take:
{
doAfterTry: function()
{
let msg = "The sword begins to vibrate as your hand curls around its haft. ";
MyGame.print( msg );
},
doAfterSuccess: function()
{
let msg = "The sword bursts into song in your hand. ";
MyGame.print( msg );
},
},
},
});
Now consider this stone, which is indirectly subscribed to "remove". We want to print messages when the sword is removed from it, so we'll hook into the stone's indirect object subscription. We could put this code on either object. A case like this comes down to author's choice.
MyGame.createAsset({
class: "Thing",
name: "stone",
iov: {
remove:
{
doBeforeTry: function()
{
let msg = "Will the stone judge you worthy enough to remove the sword? "
MyGame.print( msg );
},
doAfterSuccess: function()
{
let msg = "With the sword removed, the stone bursts into rubble! ";
MyGame.print( msg );
this.destroy();
},
},
},
});
Notes
- To learn more, see verb phase hooks.
- Verb phase hooks are similar to, but distinct from, verb action hooks and verb reaction hooks, which offer more surgical hooks.
plugIn action hooks
Every asset referred to in the turn's input is checked for verb action hooks. These hooks allow authors to inject custom code or print custom text during verb operations. There are two distinct approaches to defining verb actions, designed to accommodate different levels of scripting experience. Authors may use whichever approach they find most comfortable. For more details, see Action Hooks.
-
Simple approach: Define string properties such as
asset.do_plugIn
. If AdventureJS finds a string, it prints it instead of the default output for that turn. This option is best for authors who want to customize output without writing code. -
Advanced approach: Define method properties such as
asset.doPlugIn()
. If a method is found, it is called with a parameter object containing any relevant assets from the input (e.g.,asset.doPlugIn({asset1,asset2})
). The author may use or ignore these parameters. This approach offers complete control over the turn’s outcome: authors can add conditional logic, force success or failure, or revise the default output.
String properties
Expand any item to see code examples.
try_plugIn_this
Called on This
asset in a phrase such as "plugIn this". Since no indirect object is given, we treat the player character as an indirect object.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of which player character uses the verb.
MyGame.createAsset({ class: "Thing", name: "Thing One", try_plugIn_this: "Found custom string at thing_one.try_plugIn_this", });
-
In this example, we use the name of a player character asset as a nested object key. This variation results in a singular response only when that particular player character uses the verb on this asset.
MyGame.createAsset({ class: "Thing", name: "Thing One", try_plugIn_this: { "Player Two": "Found custom string at thing_one.try_plugIn_this['Player Two']", }, });
do_plugIn_this
Called on This
asset in a phrase such as "plugIn this". Since no indirect object is given, we treat the player character as an indirect object.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of which player character uses the verb.
MyGame.createAsset({ class: "Thing", name: "Thing One", do_plugIn_this: "Found custom string at thing_one.do_plugIn_this", });
-
In this example, we use the name of a player character asset as a nested object key. This variation results in a singular response only when that particular player character uses the verb on this asset.
MyGame.createAsset({ class: "Thing", name: "Thing One", do_plugIn_this: { "Player Two": "Found custom string at thing_one.do_plugIn_this['Player Two']", }, });
try_plugIn_this_that
Called on This
asset in a phrase such as "plugIn this that", where This
is the direct object and That
is the indirect object.
try_plugIn_this_that
mirrors try_plugIn_that_this
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", try_plugIn_this_that: "Found custom string at thing_one.try_plugIn_this_that", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
That
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing One", try_plugIn_this_that: { "Thing Two": "Found custom string at thing_one.try_plugIn_this_that['Thing Two']", }, });
do_plugIn_this_that
Called on This
asset in a phrase such as "plugIn this that", where This
is the direct object and That
is the indirect object.
do_plugIn_this_that
mirrors do_plugIn_that_this
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", do_plugIn_this_that: "Found custom string at thing_one.do_plugIn_this_that", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
That
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing One", do_plugIn_this_that: { "Thing Two": "Found custom string at thing_one.do_plugIn_this_that['Thing Two']", }, });
try_plugIn_that_this
Called on That
asset in a phrase such as "plugIn this that".
try_plugIn_that_this
mirrors try_plugIn_this_that
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing Two", try_plugIn_that_this: "Found custom string at thing_two.try_plugIn_that_this", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
That
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing Two", try_plugIn_that_this: { "Thing One": "Found custom string at thing_two.try_plugIn_that_this['Thing One']", }, });
do_plugIn_that_this
Called on That
asset in a phrase such as "plugIn this that".
do_plugIn_that_this
mirrors do_plugIn_this_that
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing Two", do_plugIn_that_this: "Found custom string at thing_two.do_plugIn_that_this", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
That
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing Two", do_plugIn_that_this: { "Thing One": "Found custom string at thing_two.do_plugIn_that_this['Thing One']", }, });
try_plugIn_this_preposition_that
Called on This
asset in a phrase such as "plugIn this with that", where This
is the direct object and That
is the indirect object.
try_plugIn_this_preposition_that
mirrors try_plugIn_that_preposition_this
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", try_plugIn_this_with_that: "Found custom string at thing_one.try_plugIn_this_with_that", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
That
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing One", try_plugIn_this_with_that: { "Thing Two": "Found custom string at thing_one.try_plugIn_this_with_that['Thing Two']", }, });
do_plugIn_this_preposition_that
Called on This
asset in a phrase such as "plugIn this with that", where This
is the direct object and That
is the indirect object.
do_plugIn_this_preposition_that
mirrors do_plugIn_that_preposition_this
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", do_plugIn_this_with_that: "Found custom string at thing_one.do_plugIn_this_with_that", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
That
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing One", do_plugIn_this_with_that: { "Thing Two": "Found custom string at thing_one.do_plugIn_this_with_that['Thing Two']", }, });
try_plugIn_that_preposition_this
Called on That
asset in a phrase such as "plugIn this with that", where That
is the indirect object and This
is the direct object.
try_plugIn_that_preposition_this
mirrors try_plugIn_this_preposition_that
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
This
asset is.MyGame.createAsset({ class: "Thing", name: "Thing Two", try_plugIn_that_with_this: "Found custom string at thing_two.try_plugIn_that_with_this", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
This
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing Two", try_plugIn_that_with_this: { "Thing One": "Found custom string at thing_two.try_plugIn_that_with_this['Thing One']", }, });
do_plugIn_that_preposition_this
Called on That
asset in a phrase such as "plugIn this with that", where That
is the indirect object and This
is the direct object.
do_plugIn_that_preposition_this
mirrors do_plugIn_this_preposition_that
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we set the value of the top level object key to a string. This variation results in the same response regardless of what
This
asset is.MyGame.createAsset({ class: "Thing", name: "Thing Two", do_plugIn_that_with_this: "Found custom string at thing_two.do_plugIn_that_with_this", });
-
In this example, we use the name of an asset as a nested object key. This variation results in a singular response for
This
particular asset.MyGame.createAsset({ class: "Thing", name: "Thing Two", do_plugIn_that_with_this: { "Thing One": "Found custom string at thing_two.do_plugIn_that_with_this['Thing One']", }, });
Method properties
Expand any item to see code examples. Methods are called with a parameter object in the form of action({asset1, asset2, params})
which authors may use or ignore.
tryPlugInThis
Called on This
asset in a phrase such as "plugIn this". Since no indirect object is given, we treat the player character as an indirect object.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of which player character uses the verb.
MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThis: function () { let msg = "Found custom method at thing_one.tryPlugInThis()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
tryPlugInThis
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThis: { "Player Two": function () { let msg = "Found custom method at thing_one.tryPlugInThis['Player Two']()"; MyGame.print(msg); }, }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this particular verb action, asset1 is the player character, because we've treated it as the indirect object in absence of a player specified object.
MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThis: function ({asset1}) { switch (asset1.name) { case "Player Two": let msg = "Found custom method at thing_one.tryPlugInThis('Player Two')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
doPlugInThis
Called on This
asset in a phrase such as "plugIn this".
Since no indirect object is given, we treat the player character as an indirect object.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of which player character uses the verb.
MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThis: function () { let msg = "Found custom method at thing_one.doPlugInThis()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
doPlugInThis
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThis: { "Player Two": function () { let msg = "Found custom method at thing_one.doPlugInThis['Player Two']()"; MyGame.print(msg); }, }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this particular verb action, asset1 is the player character, because we've treated it as the indirect object in absence of a player specified object.
MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThis: function ({asset1}) { switch (asset1.name) { case "Player Two": let msg = "Found custom method at thing_one.doPlugInThis('Player Two')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
tryPlugInThisThat
Called on This
asset in a phrase such as "plugIn this that".
tryPlugInThisThat
mirrors tryPlugInThatThis
. One is called on a direct object; the other on an indirect object. These are equivalents. Where you place your code is a matter of preference.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThisThat: function () { let msg = "Found custom method at thing_one.tryPlugInThisThat()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
tryPlugInThisThat
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThisThat: { "Thing Two": function (params) { let msg = "Found custom method at thing_one.tryPlugInThisThat['Second Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThisThat: function ({asset1}) { switch (asset1.name) { case "Thing Two": let msg = "Found custom method at thing_one.tryPlugInThisThat('Second Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
doPlugInThisThat
Called on This
asset in a phrase such as "plugIn this that". doPlugInThisThat
mirrors doPlugInThatThis
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThisThat: function () { let msg = "Found custom method at thing_one.doPlugInThisThat()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
doPlugInThisThat
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThisThat: { "Thing Two": function (params) { let msg = "Found custom method at thing_one.doPlugInThisThat['Second Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThisThat: function ({asset1}) { switch (asset1.name) { case "Thing Two": let msg = "Found custom method at thing_one.doPlugInThisThat('Second Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
tryPlugInThatThis
Called on That
asset in a phrase such as "plugIn this that".
tryPlugInThatThis
mirrors tryPlugInThisThat
. One is called on an indirect object; the other on a direct object. These are equivalents. Where you place your code is a matter of preference.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThatThis: function () { let msg = "Found custom method at thing_one.tryPlugInThatThis()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
tryPlugInThatThis
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing Two", tryPlugInThatThis: { "Thing One": function (params) { let msg = "Found custom method at thing_two.tryPlugInThatThis['First Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing Two", tryPlugInThatThis: function ({asset1}) { switch (asset1.name) { case "Thing One": let msg = "Found custom method at thing_two.tryPlugInThatThis('First Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
doPlugInThatThis
Called on That
asset in a phrase such as "plugIn this that".
doPlugInThatThis
mirrors doPlugInThisThat
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThatThis: function () { let msg = "Found custom method at thing_one.doPlugInThatThis()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
doPlugInThatThis
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing Two", doPlugInThatThis: { "Thing One": function (params) { let msg = "Found custom method at thing_two.doPlugInThatThis['First Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing Two", doPlugInThatThis: function ({asset1}) { switch (asset1.name) { case "Thing One": let msg = "Found custom method at thing_two.doPlugInThatThis('First Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
tryPlugInThisPrepositionThat
Called on This
asset in a phrase such as "plugIn this with that", where This
is the direct object and That
is the indirect object.
tryPlugInThisPrepositionThat
mirrors tryPlugInThatPrepositionThis
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThisWithThat: function () { let msg = "Found custom method at thing_one.tryPlugInThisWithThat()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
tryPlugInThisPrepositionThat
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThisWithThat: { "Thing Two": function (params) { let msg = "Found custom method at thing_one.tryPlugInThisWithThat['Second Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing One", tryPlugInThisWithThat: function ({asset1}) { switch (asset1.name) { case "Thing Two": let msg = "Found custom method at thing_one.tryPlugInThisWithThat('Second Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
doPlugInThisPrepositionThat
Called on This
asset in a phrase such as "plugIn this with that", where This
is the direct object and That
is the indirect object.
doPlugInThisPrepositionThat
mirrors doPlugInThatPrepositionThis
. One is called on a direct object; the other on an indirect object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThisWithThat: function () { let msg = "Found custom method at thing_one.doPlugInThisWithThat()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
doPlugInThisPrepositionThat
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThisWithThat: { "Thing Two": function (params) { let msg = "Found custom method at thing_one.doPlugInThisWithThat['Second Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing One", doPlugInThisWithThat: function ({asset1}) { switch (asset1.name) { case "Thing Two": let msg = "Found custom method at thing_one.doPlugInThisWithThat('Second Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
tryPlugInThatPrepositionThis
Called on That
asset in a phrase such as "plugIn this with that", where That
is the indirect object and This
is the direct object.
tryPlugInThatPrepositionThis
mirrors tryPlugInThisPrepositionThat
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing Two", tryPlugInThatWithThis: function () { let msg = "Found custom method at thing_two.tryPlugInThatWithThis()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
tryPlugInThatPrepositionThis
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing Two", tryPlugInThatWithThis: { "Thing One": function (params) { let msg = "Found custom method at thing_two.tryPlugInThatWithThis['First Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing Two", tryPlugInThatWithThis: function ({asset1}) { switch (asset1.name) { case "Thing One": let msg = "Found custom method at thing_two.tryPlugInThatWithThis('First Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
doPlugInThatPrepositionThis
Called on That
asset in a phrase such as "plugIn this with that", where That
is the indirect object and This
is the direct object.
doPlugInThatPrepositionThis
mirrors doPlugInThisPrepositionThat
. One is called on an indirect object; the other on a direct object. These are equivalent, and you may place code on whichever asset makes sense to you.
This example uses "with" as the preposition, but any preposition can set a unique response.
-
In this example, we ignore the passed parameter. This variation results in the same response regardless of what
That
asset is.MyGame.createAsset({ class: "Thing", name: "Thing Two", doPlugInThatWithThis: function () { let msg = "Found custom method at thing_two.doPlugInThatWithThis()"; MyGame.print(msg); }, });
-
To limit the method to act only on a certain asset, change the value of
doPlugInThatPrepositionThis
from a method to an object, use the asset's name as a key on the object, and set that key's value to a method instead.MyGame.createAsset({ class: "Thing", name: "Thing Two", doPlugInThatWithThis: { "Thing One": function (params) { let msg = "Found custom method at thing_two.doPlugInThatWithThis['First Thing']()"; MyGame.print(msg); } }, });
-
Finally, in this example, we apply per-asset logic based on the value of asset1, which is available via our passed parameter. In this verb action, asset1 is the second noun.
MyGame.createAsset({ class: "Thing", name: "Thing Two", doPlugInThatWithThis: function ({asset1}) { switch (asset1.name) { case "Thing One": let msg = "Found custom method at thing_two.doPlugInThatWithThis('First Thing')"; MyGame.print(msg); break; default: // do nothing and allow the default result break; } return; }, });
Notes
- Verb action hooks are specific to their particular verb.
- Which verb action hooks are called depends on the structure of the player's input. Hooks are checked for every asset in the input, including the player character. Which hooks are called depends on the sentence structure of the player's input:
-
Single-object input (e.g., "plugIn this"): The hook is called on
This
asset. Since no indirect object is specified, the player character is treated as an indirect object. -
Multiple-object input (e.g., "plugIn this with that"): The hook is called depending on the object’s role in the phrase.
do_plugIn_this_preposition_that
runs onThis
direct object, whiledo_plugIn_that_preposition_this
runs onThat
indirect object. These are equivalent, and you may place code on whichever asset makes sense to you. Any preposition can be used to define a unique response, for exampleplugIn with
vsplugIn on
. -
Sentence structures are commonly mutated during the doTry verb phase, so
try
anddo
may act on different sentence structures. -
Verb actions are extremely granular and depend on specific combinations of assets and prepositions. Verb actions are called during a verb's doTry and doSuccess phases, which lets them override a verb's operations. Use them if you want to customize output for specific inputs, but beware of that granularity. Consider
doTake()
: it's called when a player takes an asset, so you might want to hook into that; but many other verbs may also move the asset into the player. If you want to catch any method that moves an asset into the player, you may find thedo_move_this_to_that
verb reaction more broadly applicable. - By default, string properties override a turn's output, but they can also be set to append or prepend the turn's default output. See verb action hooks for more information.
- Verb reaction hooks are functionally the same as action hooks. The only difference is that reaction hooks are not specific to any verb.
- Verb phase hooks are a different form of hook that allows authors to override entire verb phases.
plugIn reaction hooks
Every asset affected by the turn is checked for verb reaction hooks. These hooks allow authors to inject custom code or print custom text during verb operations. There are two distinct approaches to defining verb reactions, designed to accommodate different levels of scripting experience. Authors may use whichever approach they find most comfortable. See verb reaction hooks for details.
-
Simple approach: Define string properties (e.g.,
asset.do_move_this_to_that
). If AdventureJS finds a string, it prints it instead of the default output for that turn. This option is best for authors who want to customize output without writing code. -
Advanced approach: Define method properties (e.g.,
asset.doMoveThisToThat()
). If a method is found, it is called with a parameter object containing any relevant assets from the input (e.g.,asset.doMoveThisToThat({asset1})
). The author may use or ignore these parameters. This approach offers complete control over the turn’s outcome: authors can add conditional logic, force success or failure, or revise the default output.
String properties
Expand any item to see code examples. By default, string properties override a turn's output, but they can also be set to append or prepend output.
No verb reactions listed for plugIn
Method properties
Expand any item to see code examples. All methods are called with a parameter object in the form of asset.reaction({asset1, asset2, params})
which authors may use or ignore.
No verb reactions listed for plugIn
Notes
- See verb reaction hooks for more details.
- Reaction hooks aren't specific to any particular verb.
-
Verb reactions fire at the end of a turn after the verb's doSuccess phase. Many verbs may call the same reactions. For instance, any verb that moves an asset into the player calls
do_move_this_to_that
. This makes them more broadly applicable than verb actions and lets you customize the turn's output regardless of what verb is used. - Verb action hooks work the same way as reaction hooks, but are specific to their particular verb.
- Verb phase hooks are a different form of hook that allows authors to override entire verb phases.
plugIn params
Some verbs may have custom params. When an asset subscribes to such a verb, the verb's params are mirrored in the asset's verb subscription, where they are unique to that asset. To put it another way: while each verb may have a unique set of params, each asset may have its own customized version of those params.
with_params: {
max_connections: 1,
on_take_break_connections: true,
on_take_take_connections: false,
},
For example, consider this setting of the verb plugIn:
MyGame.dictionary.verbs.plugIn.with_params.max_connections = 1
By default, assets that can be plugged in will take this setting and can only be plugged in to one other asset. Now imagine that an author wants to create a power cord that needs to be plugged in to both a computer and an outlet. The author can achieve that by customizing the cord's subscription to plugIn.
Expand for example
MyGame.createAsset({
class: "Cable",
name: "power cord",
dov: { plugIn: { with_assets: ['computer','outlet'], with_params: { max_connections: 2 }, }, },
})
MyGame.createAsset({
class: "Computer",
name: "PC",
iov: { plugIn: { with_assets: ['power cord'], }, },
})
MyGame.createAsset({
class: "ElectricalOutlet",
name: "outlet",
iov: { plugIn: { with_assets: ['power cord'], }, },
})
In this example, the power cord verb subscription's max_connections setting overrides the verb's max_connections setting, allowing the player to plug the power cord into two assets. The computer and the outlet don't have any custom value set for max_connections; they'll receive the default value, meaning they each can have only one asset plugged into them.
Notes
- It is possible for authors to modify a verb's params through the use of patchVerb.
- To learn more about modifying verbs, see Modify Verbs.
Private Constructor:
MyGame.createVerb({ "name": "plugIn", [...] });
plugIn is a predefined instance of Verb that gets constructed automatically at runtime. It is defined in the library as a generic object, and then passed to Dictionary#createVerb for construction, validation, and initialization. Because this is predefined, authors should not need to create new instances. For information on modifying predefined Verbs, see Modify Verbs.
- Index
- Methods
- Properties
Index
Methods:
- Inherited from Verb agree
- Inherited from Verb canBeIntransitive
- Inherited from Verb do
- Inherited from Verb doSuccess
- Inherited from Verb doTry
- Inherited from Verb enqueueCollection
- Inherited from Verb getState
- Inherited from Verb handleActions
- Inherited from Verb handleFailure
- Inherited from Verb handleSuccess
- Inherited from Verb hasState
- Inherited from Verb hasStructure
- Inherited from Verb hasVerbSubscriptionConnection
- Inherited from Verb initialize
- Inherited from Verb set
- Inherited from Verb setState
- Inherited from Verb setVerbConnection
- Inherited from Verb tryDestroyAfterUsing
- Inherited from Verb tryDestroyDirectObjectAfterUsing
- Inherited from Verb tryDestroyIndirectObjectAfterUsing
- Inherited from Verb tryPhaseHook
- Inherited from Verb tryToInferIndirectObject
- Inherited from Verb tryToPutThisInThatAspect
- Inherited from Verb unsetVerbConnection
- Inherited from Verb validate
Properties:
- accepts_adverbs
- accepts_direction
- accepts_number
- accepts_string
- accepts_structures
- adjectives
- allow_iov_on_iov
- article
- can_span
- default_direction
- dictionary
- direction_preposition
- doVerb
- doVerbFromThis
- doVerbThatFromThis
- doVerbThatWithThis
- doVerbThis
- doVerbThisFromThat
- doVerbThisWithThat
- doVerbWithThis
- enqueue_collections
- extends
- game
- gerund
- in_can_mean_on
- input_substitutions
- is_compass_direction
- is_direction
- is_relative_direction
- let_verb_handle_disambiguation
- let_verb_handle_remaining_input
- name
- Name
- override_verb_failure_msg
- override_verb_success_msg
- past_tense
- phrase1
- phrase2
- phrase3
- posture
- prettyname
- related
- requires_number
- requires_string
- state
- state_strings
- subject_must_be
- synonyms
- tryVerbFromThis
- tryVerbThatFromThis
- tryVerbThatWithThis
- tryVerbThis
- tryVerbThisFromThat
- tryVerbThisWithThat
- tryVerbWithThis
- type
- unstate
- verb_noun_prep
- verb_noun_prep_noun
- verb_noun_prep_noun_prep_noun
- verb_noun_prep_prep_noun
- verb_prep_noun
- verb_prep_noun_prep_noun
- verb_prep_noun_prep_noun_prep_noun
- verb_prep_prep_noun
- verb_prep_prep_prep_noun
Methods Collapse all |
agree
agree()
Defined in: adventure/dictionary/Verb.js, line 2998
Inherited from: adventurejs.Verb#agree
canBeIntransitive
canBeIntransitive()
Defined in: adventure/dictionary/Verb.js, line 2734
Inherited from: adventurejs.Verb#canBeIntransitive
do
do()
Defined in: adventure/dictionary/Verb.js, line 1077
Inherited from: adventurejs.Verb#do
do ->
- doBeforeTry (hook for authors)
- doTry
- doAfterTry (hook for authors)
- doBeforeSuccess (hook for authors)
- doSuccess
- doAfterSuccess (hook for authors)
A Verb instance doesn't have to use all of these methods. Some specialized Verbs including oops and undo override Verb.do entirely and don't use any submethods.
The other four submethods – Verb.doBeforeTry, Verb.doAfterTry, Verb.doBeforeSuccess, and Verb.doAfterSuccess – exist to provide optional hooks for authors to add custom interactions with individual Assets.
For more information about Verb Actions and Verb Phases, see Verb Actions and Verb Phases.
And so, the first thing Verb.do does is to verify that each method exists on the Verb instance. If the submethod exists, it is called. Each submethod sends a return to Verb.do.
If the Verb is acting on a collection, a false return means that the Asset currently being acted on has responded in a way that blocks further parsing, and brings this turn to a halt. A null return means that the Asset currently being acted on has concluded its own parsing, but not in such a way as to block further parsing, and Verb.do moves on to the next Asset.
doSuccess
doSuccess()
Defined in: adventure/dictionary/Verb.js, line 1804
Inherited from: adventurejs.Verb#doSuccess
doTry
doTry()
Defined in: adventure/dictionary/Verb.js, line 1416
Inherited from: adventurejs.Verb#doTry
enqueueCollection
enqueueCollection()
Defined in: adventure/dictionary/Verb.js, line 2397
Inherited from: adventurejs.Verb#enqueueCollection
getState
getState()
Defined in: adventure/dictionary/Verb.js, line 2752
Inherited from: adventurejs.Verb#getState
handleActions
handleActions()
Defined in: adventure/dictionary/Verb.js, line 1431
Inherited from: adventurejs.Verb#handleActions
handleFailure
handleFailure()
Defined in: adventure/dictionary/Verb.js, line 2441
Inherited from: adventurejs.Verb#handleFailure
handleSuccess
handleSuccess()
Defined in: adventure/dictionary/Verb.js, line 2540
Inherited from: adventurejs.Verb#handleSuccess
hasState
hasState()
Defined in: adventure/dictionary/Verb.js, line 2743
Inherited from: adventurejs.Verb#hasState
hasStructure
hasStructure() → {boolean}
Defined in: adventure/dictionary/Verb.js, line 2770
Inherited from: adventurejs.Verb#hasStructure
Returns:
boolean
hasVerbSubscriptionConnection
hasVerbSubscriptionConnection()
Defined in: adventure/dictionary/Verb.js, line 2901
Inherited from: adventurejs.Verb#hasVerbSubscriptionConnection
initialize
initialize()
Defined in: adventure/dictionary/Verb.js, line 2368
Inherited from: adventurejs.Verb#initialize
Todos: How does patchVerb handle initialization?
set
set(props) → {adventurejs.Verb}
Defined in: adventure/dictionary/Verb.js, line 2429
Inherited from: adventurejs.Verb#set
Parameters:
-
props
Object
A generic object containing properties to copy to the DisplayObject instance.
setState
setState()
Defined in: adventure/dictionary/Verb.js, line 2761
Inherited from: adventurejs.Verb#setState
setVerbConnection
setVerbConnection()
Defined in: adventure/dictionary/Verb.js, line 2780
Inherited from: adventurejs.Verb#setVerbConnection
computer.is.connected_by.plugIn.to_iov = ['socket']
socket.is.connected_by.plugIn.to_dov = ['computer']
tryDestroyAfterUsing
tryDestroyAfterUsing(object_of, asset) → {Object}
Defined in: adventure/asset/tryDestroyAfterUsing.js, line 6
Inherited from: adventurejs.Verb#tryDestroyAfterUsing
Parameters:
-
object_of
String -
asset
Object
Returns:
Object
tryDestroyDirectObjectAfterUsing
tryDestroyDirectObjectAfterUsing(asset) → {Boolean|string}
Defined in: adventure/asset/tryDestroyDirectObjectAfterUsing.js, line 6
Inherited from: adventurejs.Verb#tryDestroyDirectObjectAfterUsing
Parameters:
-
asset
Object
asset.dov[this.name].then_destroy
.
This is intended to provide a hook for authors
to easily destroy an object after a single use, such as a key
that only works once and then breaks or disappears.
Returns:
Boolean
|
string
tryDestroyIndirectObjectAfterUsing
tryDestroyIndirectObjectAfterUsing(asset) → {Boolean|string}
Defined in: adventure/asset/tryDestroyIndirectObjectAfterUsing.js, line 6
Inherited from: adventurejs.Verb#tryDestroyIndirectObjectAfterUsing
Parameters:
-
asset
Object
asset.iov[this.name].then_destroy
.
This is intended to provide a hook for authors
to easily destroy an object after a single use, such as a key
that only works once and then breaks or disappears.
Returns:
Boolean
|
string
tryPhaseHook
tryPhaseHook(phase) → {*}
Defined in: adventure/dictionary/Verb.js, line 1821
Inherited from: adventurejs.Verb#tryPhaseHook
Parameters:
-
phase
*
Returns:
*
tryToInferIndirectObject
tryToInferIndirectObject(options) → {Object}
Defined in: adventure/dictionary/Verb.js, line 1897
Inherited from: adventurejs.Verb#tryToInferIndirectObject
Parameters:
-
options
Object
An object of options.Properties
-
direct_object
Object -
handle_input
Boolean
If true, updates the global input object per standard specs used by most (but not all) of the verb instances that call this method. -
context
Object
The subject, usually player, could be an NPC. -
infer_first_use
Boolean
Optional param to set whether inference should work on first use.
-
Returns:
Object
tryToPutThisInThatAspect
tryToPutThisInThatAspect(direct_object, preposition, indirect_object) → {Object}
Defined in: adventure/dictionary/Verb.js, line 2114
Inherited from: adventurejs.Verb#tryToPutThisInThatAspect
Parameters:
-
direct_object
Object -
preposition
String -
indirect_object
Object
Returns:
Object
unsetVerbConnection
unsetVerbConnection()
Defined in: adventure/dictionary/Verb.js, line 2841
Inherited from: adventurejs.Verb#unsetVerbConnection
computer.is.connected_by.plugIn.to_iov = ['socket']
socket.is.connected_by.plugIn.to_dov = ['computer']
validate
validate()
Defined in: adventure/dictionary/Verb.js, line 2361
Inherited from: adventurejs.Verb#validate
Properties |
accepts_adverbs
accepts_adverbs :Array
Defined in: adventure/dictionary/Verb.js, line 432
Inherited from: adventurejs.Verb#accepts_adverbs
Default value: []
accepts_direction
accepts_direction :String
Defined in: adventure/dictionary/Phrase.js, line 26
Inherited from: adventurejs.Verb#accepts_direction
accepts_number
accepts_number :String
Defined in: adventure/dictionary/Phrase.js, line 40
Inherited from: adventurejs.Verb#accepts_number
accepts_string
accepts_string :String
Defined in: adventure/dictionary/Phrase.js, line 19
Inherited from: adventurejs.Verb#accepts_string
accepts_structures
accepts_structures :Array
Defined in: adventure/dictionary/Verb.js, line 426
Inherited from: adventurejs.Verb#accepts_structures
Default value: []
adjectives
adjectives :String
Defined in: adventure/dictionary/Verb.js, line 299
Overrides from: adventurejs.Verb#adjectives
allow_iov_on_iov
allow_iov_on_iov :Array
Defined in: adventure/dictionary/Verb.js, line 500
Inherited from: adventurejs.Verb#allow_iov_on_iov
Default value: false
allow_iov_on_iov
allows for some
additional checking when querying whether a verb is allowed
to operate on a particular pair of assets.
article
article :Boolean
Defined in: adventure/dictionary/Verb.js, line 388
Inherited from: adventurejs.Verb#article
Default value: false
can_span
can_span :String
Defined in: adventure/dictionary/Verb.js, line 236
Inherited from: adventurejs.Verb#can_span
default_direction
default_direction :String
Defined in: adventure/dictionary/Verb.js, line 163
Inherited from: adventurejs.Verb#default_direction
Default value: ""
dictionary
dictionary :Object
Defined in: adventure/dictionary/Verb.js, line 143
Inherited from: adventurejs.Verb#dictionary
Default value: {}
direction_preposition
direction_preposition :Boolean
Defined in: adventure/dictionary/Verb.js, line 400
Inherited from: adventurejs.Verb#direction_preposition
Default value: ""
doVerb
doVerb :Getter
Defined in: adventure/dictionary/Verb.js, line 596
Inherited from: adventurejs.Verb#doVerb
doVerbFromThis
doVerbFromThis :Getter
Defined in: adventure/dictionary/Verb.js, line 612
Inherited from: adventurejs.Verb#doVerbFromThis
doVerbThatFromThis
doVerbThatFromThis :Getter
Defined in: adventure/dictionary/Verb.js, line 652
Inherited from: adventurejs.Verb#doVerbThatFromThis
doVerbThatWithThis
doVerbThatWithThis :Getter
Defined in: adventure/dictionary/Verb.js, line 636
Inherited from: adventurejs.Verb#doVerbThatWithThis
doVerbThis
doVerbThis :Getter
Defined in: adventure/dictionary/Verb.js, line 604
Inherited from: adventurejs.Verb#doVerbThis
doVerbThisFromThat
doVerbThisFromThat :Getter
Defined in: adventure/dictionary/Verb.js, line 644
Inherited from: adventurejs.Verb#doVerbThisFromThat
doVerbThisWithThat
doVerbThisWithThat :Getter
Defined in: adventure/dictionary/Verb.js, line 628
Inherited from: adventurejs.Verb#doVerbThisWithThat
doVerbWithThis
doVerbWithThis :Getter
Defined in: adventure/dictionary/Verb.js, line 620
Inherited from: adventurejs.Verb#doVerbWithThis
enqueue_collections
enqueue_collections :Array
Defined in: adventure/dictionary/Verb.js, line 487
Inherited from: adventurejs.Verb#enqueue_collections
Default value: false
enqueue_collections
if true allows a verb to
unbundle the members of a collection in order to queue up
separate actions for each. For example, "gems" is a collection
that refers to three unique assets; "diamond", "emerald"
and "ruby". If take.enqueue_collections is true, "take gems"
will act individually on the diamond, the emerald and the ruby.
Only applies to direct object.
extends
extends :String
Defined in: adventure/dictionary/Verb.js, line 171
Inherited from: adventurejs.Verb#extends
Default value: ""
game
game :Object
Defined in: adventure/dictionary/Verb.js, line 136
Inherited from: adventurejs.Verb#game
Default value: {}
gerund
gerund :String
Defined in: adventure/dictionary/Verb.js, line 200
Inherited from: adventurejs.Verb#gerund
in_can_mean_on
in_can_mean_on :Boolean
Defined in: adventure/dictionary/Verb.js, line 355
Inherited from: adventurejs.Verb#in_can_mean_on
Default value: false
input_substitutions
input_substitutions :Object
Defined in: adventure/dictionary/Verb.js, line 438
Inherited from: adventurejs.Verb#input_substitutions
Default value: {}
is_compass_direction
is_compass_direction :Boolean
Defined in: adventure/dictionary/Verb.js, line 371
Inherited from: adventurejs.Verb#is_compass_direction
Default value: false
is_direction
is_direction :Boolean
Defined in: adventure/dictionary/Verb.js, line 364
Inherited from: adventurejs.Verb#is_direction
Default value: false
is_relative_direction
is_relative_direction :Boolean
Defined in: adventure/dictionary/Verb.js, line 379
Inherited from: adventurejs.Verb#is_relative_direction
Default value: false
let_verb_handle_disambiguation
let_verb_handle_disambiguation :Boolean
Defined in: adventure/dictionary/Verb.js, line 335
Inherited from: adventurejs.Verb#let_verb_handle_disambiguation
Default value: false
let_verb_handle_remaining_input
let_verb_handle_remaining_input :Boolean
Defined in: adventure/dictionary/Verb.js, line 344
Inherited from: adventurejs.Verb#let_verb_handle_remaining_input
Default value: false
name
name :String
Defined in: adventure/dictionary/Verb.js, line 179
Inherited from: adventurejs.Verb#name
Default value: ""
Name
Name :Getter
Defined in: adventure/dictionary/Verb.js, line 520
Inherited from: adventurejs.Verb#Name
Default value: []
override_verb_failure_msg
override_verb_failure_msg :String
Defined in: adventure/dictionary/Verb.js, line 450
Inherited from: adventurejs.Verb#override_verb_failure_msg
Default value: undefined
override_verb_success_msg
override_verb_success_msg :String
Defined in: adventure/dictionary/Verb.js, line 459
Inherited from: adventurejs.Verb#override_verb_success_msg
Default value: undefined
past_tense
past_tense :String
Defined in: adventure/dictionary/Verb.js, line 194
Inherited from: adventurejs.Verb#past_tense
phrase1
phrase1 :Object
Defined in: adventure/dictionary/Verb.js, line 408
Inherited from: adventurejs.Verb#phrase1
Default value: {}
phrase2
phrase2 :Object
Defined in: adventure/dictionary/Verb.js, line 414
Inherited from: adventurejs.Verb#phrase2
Default value: {}
phrase3
phrase3 :Object
Defined in: adventure/dictionary/Verb.js, line 420
Inherited from: adventurejs.Verb#phrase3
Default value: {}
posture
posture :String
Defined in: adventure/dictionary/Verb.js, line 206
Overrides from: adventurejs.Verb#posture
prettyname
prettyname :String
Defined in: adventure/dictionary/Verb.js, line 186
Inherited from: adventurejs.Verb#prettyname
related
requires_number
requires_number :String
Defined in: adventure/dictionary/Phrase.js, line 47
Inherited from: adventurejs.Verb#requires_number
requires_string
requires_string :String
Defined in: adventure/dictionary/Phrase.js, line 33
Inherited from: adventurejs.Verb#requires_string
state
state :String
Defined in: adventure/dictionary/Verb.js, line 247
Inherited from: adventurejs.Verb#state
state
is an optional property for verbs that apply
state to assets, such as close and lock. For example, "close door"
will set door.is.closed to true. When used, state will contain the
state to be set true on an asset. In the case of close, its state
would be "closed".
state_strings
state_strings :String
Defined in: adventure/dictionary/Verb.js, line 267
Inherited from: adventurejs.Verb#state_strings
state_strings
is an optional property for verbs that is
used to provide string substitutions for authors using the string
substitution form of {sink drain [is] plugged [or] unplugged}.
Because "unplugged" isn't a proper verb state, we'll use this as a
reverse lookup to test whether the asset, sink_drain in this case,
is subscribed to the relevant verb and has the specified state.
state_strings only apply to direct objects.
subject_must_be
subject_must_be :Object
Defined in: adventure/dictionary/Verb.js, line 315
Inherited from: adventurejs.Verb#subject_must_be
Default value: {}
synonyms
synonyms :Getter/Setter
Defined in: adventure/dictionary/Verb.js, line 660
Inherited from: adventurejs.Verb#synonyms
Default value: []
tryVerbFromThis
tryVerbFromThis :Getter
Defined in: adventure/dictionary/Verb.js, line 556
Inherited from: adventurejs.Verb#tryVerbFromThis
tryVerbThatFromThis
tryVerbThatFromThis :Getter
Defined in: adventure/dictionary/Verb.js, line 588
Inherited from: adventurejs.Verb#tryVerbThatFromThis
tryVerbThatWithThis
tryVerbThatWithThis :Getter
Defined in: adventure/dictionary/Verb.js, line 572
Inherited from: adventurejs.Verb#tryVerbThatWithThis
tryVerbThis
tryVerbThis :Getter
Defined in: adventure/dictionary/Verb.js, line 540
Inherited from: adventurejs.Verb#tryVerbThis
tryVerbThisFromThat
tryVerbThisFromThat :Getter
Defined in: adventure/dictionary/Verb.js, line 580
Inherited from: adventurejs.Verb#tryVerbThisFromThat
tryVerbThisWithThat
tryVerbThisWithThat :Getter
Defined in: adventure/dictionary/Verb.js, line 564
Inherited from: adventurejs.Verb#tryVerbThisWithThat
tryVerbWithThis
tryVerbWithThis :Getter
Defined in: adventure/dictionary/Verb.js, line 548
Inherited from: adventurejs.Verb#tryVerbWithThis
type
type :String
Defined in: adventure/dictionary/Verb.js, line 151
Inherited from: adventurejs.Verb#type
Default value: ""
unstate
unstate :String
Defined in: adventure/dictionary/Verb.js, line 257
Inherited from: adventurejs.Verb#unstate
unstate
is an optional property for verbs that unset
state from assets, such as open and unlock. For example, "open door"
will set door.is.closed to false. When used, unstate will contain the
state to be set false on an asset. In the case of open, its unstate
would be "closed".
verb_noun_prep
verb_noun_prep :Array
Defined in: adventure/dictionary/Verb.js, line 726
Inherited from: adventurejs.Verb#verb_noun_prep
Default value: []
verb_noun_prep_noun
verb_noun_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 890
Inherited from: adventurejs.Verb#verb_noun_prep_noun
Default value: []
Though verb_prep_noun and verb_noun_prep_noun look similar, the reason they are separate fields is because we have to use different regex patterns to find each type in user input.
verb_noun_prep_noun_prep_noun
verb_noun_prep_noun_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 979
Inherited from: adventurejs.Verb#verb_noun_prep_noun_prep_noun
Default value: []
verb_noun_prep_prep_noun
verb_noun_prep_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 937
Inherited from: adventurejs.Verb#verb_noun_prep_prep_noun
Default value: []
verb_prep_noun
verb_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 767
Inherited from: adventurejs.Verb#verb_prep_noun
Default value: []
verb_prep_noun_prep_noun
verb_prep_noun_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 684
Inherited from: adventurejs.Verb#verb_prep_noun_prep_noun
Default value: []
verb_prep_noun_prep_noun_prep_noun
verb_prep_noun_prep_noun_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 1025
Inherited from: adventurejs.Verb#verb_prep_noun_prep_noun_prep_noun
Default value: []
verb_prep_prep_noun
verb_prep_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 808
Inherited from: adventurejs.Verb#verb_prep_prep_noun
Default value: []
verb_prep_prep_prep_noun
verb_prep_prep_prep_noun :Array
Defined in: adventure/dictionary/Verb.js, line 849
Inherited from: adventurejs.Verb#verb_prep_prep_prep_noun
Default value: []