Class:Outlet
Extends: adventurejs.Electronics
Defined in: adventure/assets/tangibles/things/electronics/Outlet.js, line 5
More info: AboutTangibles
Constructor:
MyGame.createAsset({ "class":"Outlet", "name":"foo", [...] })
Description
Outlet is a subclass of Electronics, with no special properties, but meant to build upon. Can be fixed, like a wall outlet, or mobile like a power strip.
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 .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/Scripting_VerbReactions.html
doMoveThatToThis: {
"sink plug": function () {
let msg = `{We} plug the sink by putting the plug in the drain. `;
// overrideTurn will replace any other output with this msg.
this.game.overrideTurn(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.overrideTurn(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.overrideTurn(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.overrideTurn(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
Private Constructor:
var foo = new adventurejs.Outlet(game_name, name)
Though all in-game glasses use a standard constructor method under the hood, it's unlikely that you'd need to call it directly. To create an instance of the Outlet class, it must be defined in a game file as a generic object. That object will be used at runtime to construct a new game class instance, which will be validated and initialized before adding it to the Game. See above for the public constructor, or see Game#createAsset to learn more.
Parameters:
-
game_name
String
The name of the top level game object. -
name
String
A name for the object, to be serialized and used as ID.