Adventure.js Docs Downloads
Score: 0 Moves: 0

Verb: plugIn

Instance of: adventurejs.Verb

Defined in: adventure/dictionary/verbs/plugIn.js, line 9

How to: How to: VerbSubscriptions VerbAnatomy VerbProcess ModifyVerbs WriteVerbs

Runtime node: game.dictionary.verbs.plugIn

> 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. If asset.is.direct_object_of_verb.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.is.direct_object_of_verb.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.

plugIn demo + example code


// PlugGame.js
// --------------------------------------------------
/*global adventurejs PlugGame*/ 

var PlugGame = new adventurejs.Game( "PlugGame", "PlugGameDisplay" )
.set({

  // title, version, and author are shown in the title bar
  title: "Plug Game",
  version: "0.0.1",
  author: "Ivan Cockrum",

  description: "This is my great game! Thanks for playing!",

  // 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
});

PlugGame.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 only be shown on first visit
  print_verbose_room_descriptions_on_first_visit: true,

  // if this is true, adventurejs will print
  // debug messages to the game display
  print_debug_messages: true,

});
  
PlugGame.createAsset({
  class: "Room",
  name: "Plug Foyer",

  descriptions: {
    look: `Welcome to the Plug Demo, where you can try plugging and unplugging things with the verbs plug, plugIn and unplug. Adventure.js understands "plug" to have four distinct verb ases. 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 Foyer

PlugGame.createAsset({
  class: "Player",
  name: "Mario",
  place: { in: "Plug Foyer" },
  is: { active: true, },
}); 

// Scoring

PlugGame.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! ** ]" },

  },

  // To attach a score event to your custom function, use
  // PlugGame.scorecard.completeEvent('open window');
  // You'll see these sprinkled throughout this demo code.
  
  // Adventurejs has built-in scoring functions, 
  // but you may, if you like, write custom score handling.

  // return a string

  // score_message: `$(Our) score went up! `,

  // return a custom function

  // score_message: function(){ 
  //   return `Dude, you totally just got ${this.diff} points!`
  // },

  // Or maybe you just want to tweak the score display. 
  // By default score appears in 0/0 format, but let's 
  // say you'd like it to say "Score: 0 out of 0".

  // score_format: function()
  // {
  //   return `Score: ${this.score} out of ${this.total}`;
  // }

  // Technically you don't even need to use numbered scores.
  // You could, if you wanted, set scores as text, like so:

  // score_format: function()
  // {
  //   return `Current danger level: ${this.game.vars.danger_level}`;
  // }

  // score_message and score_format have access to:
  // - this.score (old score)
  // - this.newscore (new score)
  // - this.diff (difference between old/new )
  // - this.total (total of points available)

})



// PlugSomethingIntoSomething.js  
// --------------------------------------------------
/*global adventurejs A PlugGame*/ 

PlugGame.createAsset({
  class: "Room",
  name: "Plug Something Into Something",

  // set this empty to prevent it printing 
  // in lists as "room" rather than "the room"
  definite_article: "", 

  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 under PlugSomethingIntoSomething.js for particulars. ",
    brief: "You can plug one thing into another here. ",
  },
  exits: {
    south: "Plug Foyer",
  },
}); // Plug Something Into Something

PlugGame.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. ",
  },
  can_put: {
    attached: {
      list_in_room: true,
    },
  },
});

PlugGame.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 = PlugGame.$('file');
      if( file.is.created && file.$is('on','computer') ) 
      {
        msg += `The desktop shows a single file. `;
      }
      return msg;
    },
  },
  can_put: {
    on: {
      with_assets: ["file"],
    },
  },
  is: {
    direct_object_of_verb: {
      plugIn: { 
        with_assets: ['brass outlet'],
        with_success: function(){
          if(PlugGame.$('file').is.created)
          {
            // Here we're using a simple hack to move a file
            // when the computer is plugged/unplugged.
            PlugGame.$('file').setPlace('on','computer');
          }
          return "BOUMMMMMMmmmmmmmm. The computer starts up with a deep bassy power chord. ";
        },
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('plug in any computer part');
          return this.is.direct_object_of_verb.plugIn.with_success();
        },
      },
      unplug: { 
        with_success: function(){
          PlugGame.$('file').setPlace();
          return "BEEEooop. The computer display shrinks to a point, then goes black. ";
        },
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('unplug any computer part');
          return this.is.direct_object_of_verb.unplug.with_success();
        },
      },
    },
  },
});

PlugGame.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/tutorial_SetDescriptions.html for more info.
    listen: () => PlugGame.$("printer").$is("pluggedIn")?"The printer's fan wheezes like an asthmatic in an iron lung. ":"The printer is ominously silent. ",
  },
  can_put:{
    on:{
      with_assets: ['counterfeit bill','dollar bill'],
    },
  },
  is: {
    direct_object_of_verb: {
      plugIn: { 
        with_assets: ['brass outlet'],
        with_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.
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('plug in any computer part');
          return this.is.direct_object_of_verb.plugIn.with_success;
        },
      },
      unplug: { 
        with_success: "The printer shuts down with a wheeze. ",
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('unplug any computer part');
          return this.is.direct_object_of_verb.unplug.with_success;
        },
      },
    },
  },
});

PlugGame.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). ",
  },
  can_put:{
    on:{
      with_assets: ['dollar bill'],
    },
  },
  is: {
    direct_object_of_verb: {
      plugIn: { 
        with_assets: ['brass outlet'],
        with_success: function(){
          let msg = PlugGame.$('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;
        },
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('plug in any computer part');
          return this.is.direct_object_of_verb.plugIn.with_success();
        },
      },
      unplug: { 
        with_success: "The scanner shuts down with a loud chunk. ",
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('unplug any computer part');
          return this.is.direct_object_of_verb.unplug.with_success;
        },
      },
    },
  },
});

PlugGame.createAsset({
  class: "Outlet",
  name: "brass outlet",
  synonyms: ['socket','sockets'],
  place: { attached: "workstation" },
  description: ()=> {
    
    let computer_is_plugged = PlugGame.$('computer').DOVisConnectedToAsset('plugIn','brass_outlet'); 

    let printer_is_plugged = PlugGame.$('printer').DOVisConnectedToAsset('plugIn','brass_outlet'); 

    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,
    indirect_object_of_verb: {
      plugIn: { 
        with_assets: ['computer','printer'],
        with_params: {
          max_connections: 2,
        },
      },
    },
  },
});

PlugGame.createAsset({
  class: "Thing",
  name: "file",
  synonyms: [],
  adjectives: [],
  place: {},
  descriptions: {
    look: "A single file sits on the computer's desktop. ",
  },
  is: {
    direct_object_of_verb: {
      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.
 */
PlugGame.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 = PlugGame.getInput();
    let direct_object = input.getAsset(1);
    let scanner = PlugGame.$('scanner');

    if( scanner.is.broken )
    {
      PlugGame.print(`Sadly, the scanner has scanned its last scan. `);
      return null;  
    }

    if( !direct_object )
    {
      if( PlugGame.$('dollar bill').$is('on','scanner') ) 
      {
        direct_object  = PlugGame.$('dollar bill');
      }
      else
      {
        PlugGame.print(`There's nothing scannable on the scanner. `);
        return null;  
      }
    }

    if( direct_object && direct_object.id !== 'dollar_bill' )
    {
      PlugGame.print(`$(We) can't scan ${direct_object.articlename}. `);
      return null;
    }

    if( !direct_object.$is('on','scanner') )
    {
      PlugGame.print(`The dollar bill is not on the scanner. `);
      return null;
    }

    if( !scanner.$is('pluggedIn') )
    {
      PlugGame.print(`The scanner is not plugged in. `);
      return null;
    }

    if( !PlugGame.$('computer').$is('pluggedIn') )
    {
      PlugGame.print(`The computer is not plugged in. `);
      return null;
    }

    // ok to scan!
    PlugGame.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.
    PlugGame.scorecard.completeEvent('scan dollar');
    let file = PlugGame.$('file');
    file.setPlace('on','computer');
    file.is.known = true;
    file.is.seen = true;
    scanner.is.broken = true;
    return true;

  }
});

PlugGame.createVerb({
  name: "print",
  do: function()
  {
    let input = PlugGame.getInput();
    let direct_object = input.getAsset(1);
    let printer = PlugGame.$('printer');

    if( printer.is.broken )
    {
      PlugGame.print(`Sadly, the printer has printed its last print. `);
      return null;  
    }

    if( !direct_object )
    {
      if( PlugGame.$('file').$is('on','computer') ) 
      {
        direct_object  = PlugGame.$('file');
      }
      else
      {
        PlugGame.print(`There's nothing printable on the computer. `);
        return null;  
      }
    }

    if( direct_object && direct_object.id !== 'file' )
    {
      PlugGame.print(`$(We) can't print ${direct_object.articlename}. `);
      return null;
    }

    if( !direct_object.$is('on','computer') )
    {
      PlugGame.print(`$(We) don't know of any file. `);
      return null;
    }

    if( !printer.$is('pluggedIn') )
    {
      PlugGame.print(`The printer is not plugged in. `);
      return null;
    }

    if( !PlugGame.$('computer').$is('pluggedIn') )
    {
      PlugGame.print(`The computer is not plugged in. `);
      return null;
    }

    // ok to scan!
    PlugGame.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 = PlugGame.$('counterfeit bill');
    counterfeit.moveTo('on','printer');
    counterfeit.is.known = true;
    counterfeit.is.seen = true;
    PlugGame.scorecard.completeEvent('print dollar');
    printer.is.broken = true;
    return true;

  }
});


PlugGame.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 PlugGame*/ 

PlugGame.createAsset({
  class: "Room",
  name: "Plug Something Into Nothing",

  // set this empty to prevent it printing 
  // in lists as "room" rather than "the room"
  definite_article: "", 

  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 under PlugSomethingIntoNothing.js for particulars.  ", 
    brief: "You can plug a thing into nothing here. ",
  },
  exits: {
    north: "Plug Foyer",
  }
}); // Plug Something Into Nothing


PlugGame.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",
});

PlugGame.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 ${PlugGame.$('old fashioned radio').$is('pluggedIn')?'plugged in and playing':'unplugged and silent'}. `, 
  },

  is:{
    direct_object_of_verb:{
      plugIn: {
        with_nothing:true,

        // there are several ways to use with_success
        // it can return a string or an array or a function

        // return a string
        // with_success: 'The radio emits a crackle of static. ',

        // return a different string from an array each time
        // with_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
        with_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( this.id, "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
        // with_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.
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('plug in radio');
          return this.is.direct_object_of_verb.plugIn.with_success();
        },

      },

      unplug: {
        with_nothing:true,
        with_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.
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('unplug radio');
          return this.is.direct_object_of_verb.unplug.with_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.getCurrentRoom().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 PlugGame*/ 

PlugGame.createAsset({
  class: "Room",
  name: "Plug Something With Something",

  // set this empty to prevent it printing 
  // in lists as "room" rather than "the room"
  definite_article: "", 
  
  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 Foyer",
  }
}); // Plug Something With Something

// sink
PlugGame.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 parts. The parts will be registered 
// during initialization to create relationships
// between them.
PlugGame.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( PlugGame.$('dollar bill').$is('in','sink drain') )
      {
        msg += PlugGame.$('dollar bill').$is('in','sink drain') ?
          `Something odd about the drain demands a closer inspection. ` : ``;
      }
      return msg;
    },
  },
  can_put: {
    attached: { know_with_parent: true, },
  },
  parts: [
    "sink's hot water handle",
    "sink's cold water handle",
    "sink faucet",
    "sink drain",
    "sink plug"
  ],
});

PlugGame.createAsset({
  class: "Plug",
  name: "sink plug",
  synonyms: "plug",
  place: { on: "bathroom counter" },
  description: "A sink drain plug. ",
});

PlugGame.createAsset({
  class: "Drain",
  name: "sink drain",
  synonyms: "sink drain",
  can_put: {
    in: {
      maxcount: 2, // to account for plug and dollar bill
    },
  },
  // If you look through all the instances of 
  // PlugGame.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 
  // event hooks. These are called whenever common events occur
  // by 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/tutorial_UseVerbEventHooks.html
  event_hooks:{
    'onMoveThatToThis':{
      '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);
        PlugGame.scorecard.completeEvent('put plug in sink');
        return;
      },
    },
    'onRemoveThatFromThis':{
      'sink plug': function(){
        let msg = `$(We) unplug the sink by pulling the sink plug from the sink drain. `;
        this.game.overrideOutput(msg);
        PlugGame.scorecard.completeEvent('remove plug from sink');
        return;
      },
    },    
  },
  descriptions: {
    look: function(){
      let msg = `The dark drain is currently $( sink drain is plugged or unplugged )`;
      if( PlugGame.$('dollar bill').$is('in','sink drain') )
      {
        msg += PlugGame.$('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 += `. `;
      return msg;
    },
  },
});

PlugGame.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,
});

PlugGame.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
});

PlugGame.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
});

PlugGame.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_in_parent: false },
  description: "Two porcelain sink handles, hot and cold. ",
});

PlugGame.createAsset({
  class: "PaperMoney",
  name: "dollar bill",
  synonyms: ["one","tube","money","paper"],
  adjectives: ["small"],
  // article: "the",
  place: { in: "sink drain" },
  descriptions: {
    look: function(){
      let msg = PlugGame.$('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;
    },
  },
  is: { 
    direct_object_of_verb:{
      take: {
        with_success_first_time: 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. ";
          PlugGame.overrideOutput(msg);
          //return null;
        },
      },
      put: {
        with_success: function(){
          if( this.$is("in","sink drain") ){
            let msg = `$(We) roll up the dollar bill and stuff it back in the sink drain. `;
            PlugGame.overrideOutput(msg);
          }
        },
      },
    },
  },
  event_hooks: {}
});


// PlugThis.js
// --------------------------------------------------
/*global adventurejs A PlugGame*/ 

PlugGame.createAsset({
  class: "Room",
  name: "Plug Something With Nothing",

  // set this empty to prevent it printing
  // in lists as "room" rather than "the room"
  definite_article: "", 

  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. `,
    brief: "Try to plug and unplug the sink. See the example code under PlugThis.js for particulars. ",
  },
  exits: {
    west: "Plug Foyer",
  },
}); // Plug Something With Nothing

PlugGame.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 ${PlugGame.$('simple pedestal sink').$is('plugged')?'plugged':'unplugged'}. ` },
  is:{
    direct_object_of_verb:{
      'plug':{ 
        with_nothing:true, 
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('plug sink');
          return "TADA! ";
        },
      },
      'unplug':{ 
        with_nothing:true, 
        with_success_first_time: function(){
          PlugGame.scorecard.completeEvent('unplug sink');
          return "It's probably less exciting than you were imagining. ";
        },
      },
    },
  },
}); // 

plugIn sentence structures

plugIn is parsed as a compound word which means that we 
don't parse 'in' as a separate word and therefore don't 
accept 'verb noun preposition noun' as with many other verbs. 
accepts_structures: [
  'verb noun', // ie 'plug in computer'
  'verb noun noun', // ie 'plug computer into outlet'
],

Adventurejs uses multiple filtering methods to try to interpret player input. Sentence structures are defined for each verb in order to narrow down the sentence structures that a verb can accept. 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. This helps to filter player input. Input that isn't accepted will return a warning to the player.

  • It is possible for authors to modify a verb's structures through the use of patchVerb.
  • To learn more about modifying verbs, see How to Modify Verbs.

plugIn phrases

phrase1:
{
  accepts_noun: true,
  requires_noun: true,
  //accepts_preposition: true,
  //preposition_must_be: ["in"],
  noun_must_be:
  {
    known: true,
    tangible: true,
    present: true,
    visible: true, 
    reachable: true,
  },
},
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" ],
},

Adventurejs uses multiple filtering methods to try to interpret player input. Phrases are defined for each verb in order to narrow down the words that a verb can accept. This applies to preposition/noun pairs: from zero in the case of intransitive verbs, up to three in the case of verbs that can handle input such as "pour water from jug into basin". The nested noun_must_be object sets conditional qualifiers for nouns, that helps narrow down game objects that the verb might act upon. Input that isn't accepted will return a warning to the player.

  • 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 How to Modify Verbs.

plugIn params

with_params: { 
  connections: [],
  max_connections: 1,
  take_breaks_connections: true,
  take_takes_connections: false,
},

A verb may have custom params which will be mirrored in the properties of any asset that the verb can be applied to. 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.

MyGame.createAsset({
  class: "Cable",
  name: "power cord",
  is: { direct_object_of_verb: { plugIn: { with_assets: ['computer','outlet'], with_params: { max_connections: 2 }, }, }, },
})
MyGame.createAsset({
  class: "Computer",
  name: "PC",
  is: { indirect_object_of_verb: { plugIn: { with_assets: ['power cord'], }, }, },
})
MyGame.createAsset({
  class: "ElectricalOutlet",
  name: "outlet",
  is: { indirect_object_of_verb: { plugIn: { with_assets: ['power cord'], }, }, },
})

The power cord's max_connections setting overrides the verb's max_attachment setting, allowing the player to plug the power cord into two assets, while the computer and the outlet can still have only one asset plugged into them.

  • It is possible for authors to modify a verb's params through the use of patchVerb.
  • To learn more about modifying verbs, see How to Modify Verbs.

plugIn event hooks

onTryPlugInThis 
onTryPlugThisIntoThat 
onTryPlugThatIntoThis 
onPlugInThis 
onPlugThisIntoThat 
onPlugThatIntoThis

Verb Event Hooks provide a method for authors to hook custom code into particular actions (or reactions) of a verb. It works by looking for custom functions attached to the specific assets that the verb is being applied to, and calling whatever it finds. It's a fine grained way to control specific verb/noun interactions. Each verb has a unique set of event hooks. For instance, the verb lock has onTryLock and onTryLockThisWithThat and several other lock-specific hooks. There are also common event hooks that are called by multiple verbs. For example, consider onMoveThatToThis, which might be called during the doSuccess phase of verbs give, take, drop, throw, move, etc. In this example, imagine that an author would like the game to print a custom message whenever a certain object enters or leaves another object, by any method.

MyGame.createAsset({
  class: "NPC",
  name: "Elvis",
}),
MyGame.createAsset({
  class: "Room",
  name: "The Building",
  event_hooks: {
    onMoveThatToThis: 
    {
      "Elvis": function() 
      {
        MyGame.print("Elvis has entered The Building! ");
      }
    },
    onRemoveThatFromThis: 
    {
      "Elvis": function() 
      {
        MyGame.print("Elvis has left The Building! ");
      }
    },
  },
}),
  • To learn more, see How to Use Verb Event Hooks.
  • Some hooks are not tied to any specific verbs and though these are technically identical, we refer to them as verb effect hooks. See How to Use Verb Effect Hooks for a list of them.
  • Verb event Hooks are related to but distinct from verb phase hooks, which allow authors to broadly override entire phases of a verb.

plugIn verb hooks

do

  • doBeforeTry
  • doTry
  • doAfterTry
  • doBeforeSuccess
  • doSuccess
  • doAfterSuccess

Every verb has a do function, and most (but not all) verbs go through six distinct phases. doTry handles all the conditional logic to determine whether this verb can be applied to that asset. doSuccess handles the output and state changes. The other four phases don't do anything by themselves; they exist to allow authors to inject custom code via the use of Verb Phase Hooks. This is a broad method for exercising control over verb/noun interactions. For example, consider the verb "take" as applied to this singing sword. Imagine that an author wants the 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",
  verb_hooks: {
    take: 
    {
      doAfterTry: function( params )
      {
        MyGame.print( "The sword begins to vibrate as your hand 
        curls around its haft. ", "concatenate_output" );
      },
      doAfterSuccess: function( params )
      {
        MyGame.print( "The sword bursts into song in your hand. ", 
        "concatenate_output" );
      },
    },
  },
});
  • Verb Phase Hooks are related to but distinct from Verb Event Hooks, which are a more surgical option that allows authors to hook into specific events within doTry and doSuccess.
  • To learn more, see How to Use Verb Phase Hooks.

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 How to Modify Verbs.

Inherited Overrides
IndexMethodsProperties

Index

Methods:

Properties:

Methods Collapse all  |  Expand all

canBeIntransitive()

Defined in: adventure/dictionary/Verb.js, line 1993

Inherited from: adventurejs.Verb#canBeIntransitive

Verb can be intransitive if it doesn't require a noun.
do()

Defined in: adventure/dictionary/Verb.js, line 1022

Inherited from: adventurejs.Verb#do

Verb.do is a coordinating method that sequences six other submethods in a series. In the case of Verb instances that can act on a collection of Assets in a single turn, Verb.do only fires once, but it loops through the Asset collection and calls each submethod for every Asset in the collection. The sequence is:

do -> The two key submethods are Verb.doTry and Verb.doSuccess. For most Verb instances, these two methods contain the bulk of the logic particular to this Verb. Verb.doTry determines whether a Verb can act on an Asset, and if it can't, prints an error message to Display. Verb.doSuccess applies the Verb to the Asset: updates the game state, assembles dynamic output, and prints the results to Display.

A Verb instance isn't required to use all of these methods. Some Verbs may bypass Verb.doTry because no special conditions are required to apply the Verb. Some specialized Verbs such as 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 Event Hooks and Verb Phase Hooks, see How to Use Verb Event Hooks and How to Use Verb Phase Hooks.

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.
doAfterSuccess()

Defined in: adventure/dictionary/Verb.js, line 1369

Inherited from: adventurejs.Verb#doAfterSuccess

doAfterSuccess provides a hook for authors to add custom verb code to individual Assets. doAfterSuccess fires after doSuccess, which means that any custom code here follows the standard doSuccess code. For more information about Verb Phase Hooks, see the How to Use Verb Phase Hooks. For information about modifying Verbs, see How to Modify Verbs.
doAfterTry()

Defined in: adventure/dictionary/Verb.js, line 1253

Inherited from: adventurejs.Verb#doAfterTry

doAfterTry provides a hook for authors to add custom verb code to individual Assets. doAfterTry fires after doTry, which contains most of the specific logic for determining if this Verb is allowed to act on the specified Asset. Hooking into doAfterTry allows authors to inject custom logic that runs after the Asset has successfully passed through the standard doTry logic. This essentially lets you append custom conditional logic to doTry on an item-by-item basis without globally modifying doTry (which is also possible). If doAfterTry returns null or false, Verb.do will exit without executing the remaining methods. If Verb.do is parsing a collection of objects, returning null will continue to the next object and returning false will block all remaining objects. For more information about Verb Phase Hooks, see the How to Use Verb Phase Hooks. For information about modifying Verbs, see How to Modify Verbs.
doBeforeSuccess()

Defined in: adventure/dictionary/Verb.js, line 1304

Inherited from: adventurejs.Verb#doBeforeSuccess

doBeforeSuccess provides a hook for authors to add custom verb code to individual Assets. doBeforeSuccess fires after doTry and before doSuccess, which contains all code for applying this Verb to the specified Asset. Hooking into doBeforeSuccess allows authors to inject custom code that runs before the standard doSuccess code. This essentially lets you override doSuccess on an item-by-item basis without globally modifying doSuccess (which is also possible). If doBeforeSuccess returns null, it will prevent doSuccess from firing. For more information about Verb Phase Hooks, see the How to Use Verb Phase Hooks. For information about modifying Verbs, see How to Modify Verbs.
doBeforeTry()

Defined in: adventure/dictionary/Verb.js, line 1188

Inherited from: adventurejs.Verb#doBeforeTry

doBeforeTry provides a hook for authors to add custom verb code to individual Assets. doBeforeTry fires before doTry, which contains most of the specific logic for determining if this Verb is allowed to act on the specified Asset. Hooking into doBeforeTry allows authors to inject custom logic on an item-by-item basis that runs before any of the standard doTry logic. For more information about Verb Phase Hooks, see How to Use Verb Phase Hooks. For information about modifying Verbs, see How to Modify Verbs.
doSuccess()

Defined in: adventure/dictionary/Verb.js, line 1351

Inherited from: adventurejs.Verb#doSuccess

doSuccess typically contains all the code needed to apply this Verb to the specified Asset once it has successfully passed through all of our conditional logic. doBeforeSuccess and doAfterSuccess are provided so that authors can apply custom success code on an item-by-item basis, but it is also possible to globally modify doSuccess. For information about modifying verbs, see How to Modify Verbs.
doTry()

Defined in: adventure/dictionary/Verb.js, line 1236

Inherited from: adventurejs.Verb#doTry

doTry typically contains all the specific logic needed to determine if this Verb can act on the specified Asset. (We already applied some general logic supplied by NounMustBe before arriving here.) For information about modifying verbs, see How to Modify Verbs.
enqueueCollection()

Defined in: adventure/dictionary/Verb.js, line 1716

Inherited from: adventurejs.Verb#enqueueCollection

enqueueCollection takes a collection of Assets and enqueues them to game.parser for sequential handling.
getState()

Defined in: adventure/dictionary/Verb.js, line 2014

Inherited from: adventurejs.Verb#getState

Get this verb's state or unstate.
handleFailure()

Defined in: adventure/dictionary/Verb.js, line 1760

Inherited from: adventurejs.Verb#handleFailure

handleFailure prints either a given fail message or a generic fail msg if one is specified.
handleSuccess()

Defined in: adventure/dictionary/Verb.js, line 1839

Inherited from: adventurejs.Verb#handleSuccess

handleSuccess prints the provided success message or a generic one that has been defined by author. It also checks direct and indirect objects for custom verb subscription with_success results and tryDestroy results.
hasState()

Defined in: adventure/dictionary/Verb.js, line 2004

Inherited from: adventurejs.Verb#hasState

Does this verb have state or unstate?
hasVerbSubscriptionConnection()

Defined in: adventure/dictionary/Verb.js, line 2115

Inherited from: adventurejs.Verb#hasVerbSubscriptionConnection

Test whether two assets are connected by this verb, for example a rope tied to a tree, or a computer plugged into a socket.
initialize()

Defined in: adventure/dictionary/Verb.js, line 1673

Inherited from: adventurejs.Verb#initialize

Todos: How does patchVerb handle initialization?

If Verb is a direction, initialize adds it to game.dictionary.directionLookup.
set(props) → {adventurejs.Verb}

Defined in: adventure/dictionary/Verb.js, line 1747

Inherited from: adventurejs.Verb#set

Parameters:

  • props Object
    A generic object containing properties to copy to the DisplayObject instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

adventurejs.Verb Returns the instance the method is called on (useful for chaining calls.)
setVerbSubscriptionConnection()

Defined in: adventure/dictionary/Verb.js, line 2024

Inherited from: adventurejs.Verb#setVerbSubscriptionConnection

Connect two assets that share a connection when acted upon by this verb. For example, in the case of 'plug computer into socket', each asset has the other asset's ID saved to its verb subscription like this:

computer.is.direct_object_of_verb.plugIn.with_params.connections = ['socket']
socket.is.indirect_object_of_verb.plugIn.with_params.connections = ['computer']

This is one of two verb subscription properties that are related and very similar, and it's important to understand the distinction between them. ...with_assets defines which assets CAN BE connected. ...with_params.connections stores which assets ARE connected.

with_assets: computer.is.direct_object_of_verb.plugIn.with_assets = ['socket']
connections: computer.is.direct_object_of_verb.plugIn.with_params.connections = ['socket']
tryDestroyAfterUsing(object_of, asset) → {Object}

Defined in: adventure/asset/tryDestroyAfterUsing.js, line 7

Inherited from: adventurejs.Verb#tryDestroyAfterUsing

Parameters:

  • object_of String
  • asset Object
tryDestroyAfterUsing is the underlying function for tryDestroyDirectObjectAfterUsing and tryDestroyIndirectObjectAfterUsing.

Returns:

Object
tryDestroyDirectObjectAfterUsing(asset) → {Boolean|string}

Defined in: adventure/asset/tryDestroyDirectObjectAfterUsing.js, line 7

Inherited from: adventurejs.Verb#tryDestroyDirectObjectAfterUsing

Parameters:

  • asset Object
tryDestroyDirectObjectAfterUsing checks to see if the specified asset can only be used directly once with this verb by checking for asset.is.direct_object_of_verb[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(asset) → {Boolean|string}

Defined in: adventure/asset/tryDestroyIndirectObjectAfterUsing.js, line 7

Inherited from: adventurejs.Verb#tryDestroyIndirectObjectAfterUsing

Parameters:

  • asset Object
tryDestroyIndirectObjectAfterUsing checks to see if the specified asset can only be used indirectly once with this verb by checking for asset.is.indirect_object_of_verb[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
tryPlaceAssetInAspectOfAsset(direct_object, preposition, indirect_object) → {Object}

Defined in: adventure/dictionary/Verb.js, line 1465

Inherited from: adventurejs.Verb#tryPlaceAssetInAspectOfAsset

Parameters:

  • direct_object Object
  • preposition String
  • indirect_object Object
tryPlaceAssetInAspectOfAsset checks to see if a asset can be placed within the specified aspect of another specified asset. For example, "put sword in stone" and "push stone into depression" would both be tested with this function.

Returns:

Object
tryToInferIndirectObject(direct_object) → {Object}

Defined in: adventure/dictionary/Verb.js, line 1411

Inherited from: adventurejs.Verb#tryToInferIndirectObject

Parameters:

  • direct_object Object
tryToInferIndirectObject is called by some verbs when they receive a direct object with no indirect object, to test whether an indirect object can be inferred. In order to be inferred, indirect object must be in player inventory. If player hasn't already interacted with direct object and game.settings.infer_indirect_objects_only_after_interaction is true, tryToInferIndirectObject will fail regardless of other circumstances.

Returns:

Object
unsetVerbSubscriptionConnection()

Defined in: adventure/dictionary/Verb.js, line 2077

Inherited from: adventurejs.Verb#unsetVerbSubscriptionConnection

Disconnect two assets that share a connection when acted upon by this verb. For example, in the case of 'plug computer into socket', each asset has the other asset's ID saved to its verb subscription like this:

computer.is.direct_object_of_verb.plugIn.with_params.connections = ['socket']
socket.is.indirect_object_of_verb.plugIn.with_params.connections = ['computer']
validate()

Defined in: adventure/dictionary/Verb.js, line 1662

Inherited from: adventurejs.Verb#validate

Unused.

Properties Collapse all  |  Expand all

accepts_direction :String

Defined in: adventure/dictionary/Phrase.js, line 27

Inherited from: adventurejs.Verb#accepts_direction

Currently unused.
accepts_number :String

Defined in: adventure/dictionary/Phrase.js, line 41

Inherited from: adventurejs.Verb#accepts_number

Currently unused.
accepts_string :String

Defined in: adventure/dictionary/Phrase.js, line 20

Inherited from: adventurejs.Verb#accepts_string

Currently unused.
adjectives :String

Defined in: adventure/dictionary/Verb.js, line 231

Inherited from: adventurejs.Verb#adjectives

Verb.adjectives are for direction verbs so that, for example, 'south' can be associated with 'southern' and 'southernly'.
dictionary :Object

Defined in: adventure/dictionary/Verb.js, line 144

Inherited from: adventurejs.Verb#dictionary

Default value: {}

A shortcut to the main Game Dictionary.
direction_preposition :Boolean

Defined in: adventure/dictionary/Verb.js, line 309

Inherited from: adventurejs.Verb#direction_preposition

Default value: ""

When player travels, this string may be prepended before the verb name, such as "you walk to the north"
game :Object

Defined in: adventure/dictionary/Verb.js, line 137

Inherited from: adventurejs.Verb#game

Default value: {}

A reference back to the main Game object.
in_can_mean_on :Boolean

Defined in: adventure/dictionary/Verb.js, line 276

Inherited from: adventurejs.Verb#in_can_mean_on

Default value: false

Some types of objects can accept 'in' for 'on' interchangeably, such as 'sit in chair' / 'sit on chair', or 'lie in bed' / 'lie on bed'.
input_substitutions :Object

Defined in: adventure/dictionary/Verb.js, line 326

Inherited from: adventurejs.Verb#input_substitutions

Default value: {}

To simplify identifying verbs in input, specifically with regards to adverbs & prepositions, we can provide a list of synonyms for the verb. The parser will look for these synonyms in the input and replace them with the verb name. Then, the verb can handle the adverb/preposition as it sees fit.
is_compass_direction :Boolean

Defined in: adventure/dictionary/Verb.js, line 292

Inherited from: adventurejs.Verb#is_compass_direction

Default value: false

Set whether direction verb is a compass direction, meaning, it can be found on a compass rose.
is_direction :Boolean

Defined in: adventure/dictionary/Verb.js, line 285

Inherited from: adventurejs.Verb#is_direction

Default value: false

Set whether verb is a direction verb.
is_relative_direction :Boolean

Defined in: adventure/dictionary/Verb.js, line 300

Inherited from: adventurejs.Verb#is_relative_direction

Default value: false

Set whether direction verb is a relative direction such as those used on ships: port, starboard, etc. Also applies to left, right, forward, back, etc.
let_verb_handle_disambiguation :Boolean

Defined in: adventure/dictionary/Verb.js, line 256

Inherited from: adventurejs.Verb#let_verb_handle_disambiguation

Default value: false

Setting this to true allows you to write your own disambiguation script. Warning: going off road! Recommended for experienced Javascript users.
let_verb_handle_remaining_input :Boolean

Defined in: adventure/dictionary/Verb.js, line 265

Inherited from: adventurejs.Verb#let_verb_handle_remaining_input

Default value: false

When input is parsed, parse the verb and then pass the remainder of the input to the verb as a string, for the verb to act on. Chief example is: "oops xxx" where we don't want to parse xxx, we just want to let oops use it as a substitute for last turn's unknown input.
name :String

Defined in: adventure/dictionary/Verb.js, line 152

Inherited from: adventurejs.Verb#name

Default value: ""

String provided in Verb definition file (aka preverb). Compound verb names have underscores instead of spaces, such as ask_about and climb_down.
Name :Getter

Defined in: adventure/dictionary/Verb.js, line 376

Inherited from: adventurejs.Verb#Name

Default value: []

Return uppercase name of the verb.
onDoFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 442

Inherited from: adventurejs.Verb#onDoFromThis

Returns "on[Verb]FromThis" for consistency with tryEventHook()
onDoThatFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 477

Inherited from: adventurejs.Verb#onDoThatFromThis

Returns "on[Verb]ThatFromThis" for consistency with tryEventHook()
onDoThatWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 463

Inherited from: adventurejs.Verb#onDoThatWithThis

Returns "on[Verb]ThatWithThis" for consistency with tryEventHook()
onDoThis :Getter

Defined in: adventure/dictionary/Verb.js, line 435

Inherited from: adventurejs.Verb#onDoThis

Returns "on[Verb]This" for consistency with tryEventHook()
onDoThisFromThat :Getter

Defined in: adventure/dictionary/Verb.js, line 470

Inherited from: adventurejs.Verb#onDoThisFromThat

Returns "on[Verb]ThisFromThat" for consistency with tryEventHook()
onDoThisWithThat :Getter

Defined in: adventure/dictionary/Verb.js, line 456

Inherited from: adventurejs.Verb#onDoThisWithThat

Returns "on[Verb]ThisWithThat" for consistency with tryEventHook()
onDoWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 449

Inherited from: adventurejs.Verb#onDoWithThis

Returns "on[Verb]WithThis" for consistency with tryEventHook()
onTryFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 398

Inherited from: adventurejs.Verb#onTryFromThis

Returns "onTry[Verb]FromThis" for consistency with tryEventHook()
onTryThatFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 426

Inherited from: adventurejs.Verb#onTryThatFromThis

Returns "onTry[Verb]ThatFromThis" for consistency with tryEventHook()
onTryThatWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 412

Inherited from: adventurejs.Verb#onTryThatWithThis

Returns "onTry[Verb]ThatWithThis" for consistency with tryEventHook()
onTryThis :Getter

Defined in: adventure/dictionary/Verb.js, line 384

Inherited from: adventurejs.Verb#onTryThis

Returns "onTry[Verb]This" for consistency with tryEventHook()
onTryThisFromThat :Getter

Defined in: adventure/dictionary/Verb.js, line 419

Inherited from: adventurejs.Verb#onTryThisFromThat

Returns "onTry[Verb]ThisFromThat" for consistency with tryEventHook()
onTryThisWithThat :Getter

Defined in: adventure/dictionary/Verb.js, line 405

Inherited from: adventurejs.Verb#onTryThisWithThat

Returns "onTry[Verb]ThisWithThat" for consistency with tryEventHook()
onTryWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 391

Inherited from: adventurejs.Verb#onTryWithThis

Returns "onTry[Verb]WithThis" for consistency with tryEventHook()
override_verb_failure_msg :String

Defined in: adventure/dictionary/Verb.js, line 345

Inherited from: adventurejs.Verb#override_verb_failure_msg

Default value: undefined

Provides a simple method for an author to override all failure messages for a verb with one generic string.
override_verb_success_msg :String

Defined in: adventure/dictionary/Verb.js, line 354

Inherited from: adventurejs.Verb#override_verb_success_msg

Default value: undefined

Provides a simple method for an author to override success messages for a verb with one generic string.
past_tense :String

Defined in: adventure/dictionary/Verb.js, line 171

Inherited from: adventurejs.Verb#past_tense

The past tense of the verb. May be used in output strings.
player_must_be :Object

Defined in: adventure/dictionary/Verb.js, line 239

Inherited from: adventurejs.Verb#player_must_be

Default value: {}

player_must_be sets conditions that the Player Character must meet in order for the Verb to act.
prettyname :String

Defined in: adventure/dictionary/Verb.js, line 162

Inherited from: adventurejs.Verb#prettyname

String provided in verb definition file. The prettyname is used for printing, and can include spaces, ie ask_about prints as "ask about".
requires_number :String

Defined in: adventure/dictionary/Phrase.js, line 48

Inherited from: adventurejs.Verb#requires_number

Currently unused.
requires_string :String

Defined in: adventure/dictionary/Phrase.js, line 34

Inherited from: adventurejs.Verb#requires_string

Currently unused.
state :String

Defined in: adventure/dictionary/Verb.js, line 178

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 :String

Defined in: adventure/dictionary/Verb.js, line 198

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.
synonyms :Getter/Setter

Defined in: adventure/dictionary/Verb.js, line 485

Inherited from: adventurejs.Verb#synonyms

Default value: []

synonyms provide alternate words for verbs, such as "get" for "take".
unstate :String

Defined in: adventure/dictionary/Verb.js, line 188

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 :Array

Defined in: adventure/dictionary/Verb.js, line 567

Inherited from: adventurejs.Verb#verb_noun_prep

Default value: []

For verb/noun pairs with a trailing preposition, or more likely a direction, such as "push bed north". When player input is parsed, they'll be concatenated, eg to "pushnorth bed".
verb_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 773

Inherited from: adventurejs.Verb#verb_noun_prep_noun

Default value: []

For verb/preposition pairs separated by another word, usually a noun, such as "lock door with key" or "take sword from stone". When player input is parsed, they'll be concatenated, eg to "lockwith door key" or "takefrom sword stone".

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 :Array

Defined in: adventure/dictionary/Verb.js, line 883

Inherited from: adventurejs.Verb#verb_noun_prep_noun_prep_noun

Default value: []

For a verb phrase with three nouns and two prepositions. For example, in the phrase "tie boat to pier with rope", we're looking for "tie" and "to" and "with", and we would parse the phrase as "tietowith boat pier rope"
verb_noun_prep_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 830

Inherited from: adventurejs.Verb#verb_noun_prep_prep_noun

Default value: []

For a verb phrase with two nouns and two prepositions. For example, in the phrase "take skateboard from under bed", we're looking for "take" and "from" and "under", and we would parse the phrase as "takefromunder skateboard bed"
verb_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 620

Inherited from: adventurejs.Verb#verb_prep_noun

Default value: []

For verb/preposition pairs separated by a space, such as "go to" or "look at". When player input is parsed, they'll be concatenated, eg "go to" to "goTo".
verb_prep_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 517

Inherited from: adventurejs.Verb#verb_prep_noun_prep_noun

Default value: []

For phrases like "jump from branch to vine" or "look at sun with glasses", where we have a verb + preposition followed by a noun and then another preposition
verb_prep_noun_prep_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 936

Inherited from: adventurejs.Verb#verb_prep_noun_prep_noun_prep_noun

Default value: []

For a verb phrase with three nouns and three prepositions. For example, in the phrase "swing from branch to tree on vine", we're looking for "swing from with on".
verb_prep_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 673

Inherited from: adventurejs.Verb#verb_prep_prep_noun

Default value: []

For compound preps separated by spaces, verb/prep/prep, such as "get out of"
verb_prep_prep_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 723

Inherited from: adventurejs.Verb#verb_prep_prep_prep_noun

Default value: []

For three part compound preps, verb/prep/prep/prep, such as "get out from behind"
Documentation generated by JSDoc 3.6.11 on Mon Nov 20 2023 18:04:18 GMT-0800 (Pacific Standard Time)
Found a problem or error in the docs? Report it to docs@adventurejs.com.