Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// onTieThisToThat.js
(function() {
	/*global adventurejs A*/ 
  "use strict";
  var p = adventurejs.Tangible.prototype;	
  /**
   * Called when this asset is tied to another asset.
   * Provides opportunities to override default behavior 
   * through the use of
   * <a href="/doc/Scripting_VerbReactions.html">verb reactions</a> 
   * doTieThisToThat and doTieThatToThis.
   * @memberOf adventurejs.Tangible
	 * @method adventurejs.Tangible#onTieThisToThat
   * @param {Object} asset
   * @returns {Boolean}
   */
   p.onTieThisToThat = function Tangible_onTieThisToThat( asset )
   {
    this.game.log( "log", "medium", this.name + " onTieThisToThat " + asset.name + "." , 'Behavior' );
    var results;
  
    // check rope for custom response
    results = this.callAction('doTieThisToThat', asset.name, {} );
    if( A.isFalseOrNull(results) ) return results;

    // check asset to be tied to for custom response
    results = asset.callAction('doTieThatToThis', this.name, {} );
    if( A.isFalseOrNull(results) ) return results;

    // add asset to rope's list of things its tied to
    if(-1 === this.dov.tie.with_params.connections.indexOf( asset.id )) 
    {
      this.dov.tie.with_params.connections.push( asset.id );
    }

    // add rope to asset's list of things tied to it
    if(-1 === asset.iov.tie.with_params.connections.indexOf( this.id ) )
    {
      asset.iov.tie.with_params.connections.push( this.id );
    }

    return;// results;
   }
 }());