Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// onUntieThisFromThat.js
(function() {
	/*global adventurejs A*/ 
  "use strict";
  var p = adventurejs.Tangible.prototype;	
  /**
   * Called when this asset is untied from another asset.
   * Provides opportunities to override default behavior 
   * through the use of
   * <a href="/doc/Scripting_VerbReactions.html">verb reactions</a> 
   * doUntieThisFromThat and doUntieThatFromThis.
   * @memberOf adventurejs.Tangible
	 * @method adventurejs.Tangible#onUntieThisFromThat
   * @param {Object} asset
   * @returns {Boolean}
   */
  p.onUntieThisFromThat = function Tangible_onUntieThisFromThat( asset )
  {
    this.game.log( "log", "medium", this.name + " onUntieThisFromThat " + asset.name + "." , 'Behavior' );
    var results;

    // check rope for override
    results = this.callAction('doUntieThisFromThat', asset.name, {} );
    if( "undefined" !== typeof results ) return results;            

    // call actions
    results = asset.callAction('doUntieThatFromThis', this.name, {} );
    if( "undefined" !== typeof results ) return results;            

    // remove asset from rope's list of things its tied to
    var i = this.dov.tie.with_params.connections.indexOf( asset.id );
    this.dov.tie.with_params.connections.splice( i, 1 );

    // remove rope from asset's list of things tied to it
    i = asset.iov.tie.with_params.connections.indexOf( this.id );
    asset.iov.tie.with_params.connections.splice( i, 1 );

    return;
  }   
}());