Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// onNestThatToThis.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Tangible.prototype;
  /**
   * Called when a player asset is nested to this.
   * Provides an opportunity to override default behavior
   * through the use of
   * <a href="/doc/Scripting_VerbReactions.html">verb reactions</a>
   * doNestThatToThis.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#onNestThatToThis
   * @param {Object} player
   * @returns {Boolean}
   */
  p.onNestThatToThis = function Tangible_onNestThatToThis(player) {
    if ("string" === typeof player) player = this.game.getAsset(player);
    if (!player) return;
    this.game.log(
      "L1484",
      "log",
      "high",
      `onNestThatToThis.js > nest ${player.id} to ${this.id}`,
      "VerbActions"
    );
    var results;
    var msg = "";

    // Simple vehicles go into player inventory.

    if (this.isDOV("ride") && !this.isWithin(player)) {
      // move this from its parent
      results = this.moveFrom(this.getPlaceAsset());
      if ("undefined" !== typeof results) return results;

      // move this into player inventory
      results = this.moveTo("in", player);
      if ("undefined" !== typeof results) return results;
    }

    // allow for author to add custom interactions per-object
    results = this.callAction("doNestThatToThis", player.name);
    if ("undefined" !== typeof results) return results;

    return;
  };
})();