From dfb60273475cdce0d5c15f9f31d1eee8d98f1e98 Mon Sep 17 00:00:00 2001 From: "VRCat\\VRKitten" Date: Wed, 2 Aug 2017 16:50:23 -0600 Subject: [PATCH] Last Fixes - Made parent-ator be off unless it is equipped (this does have the ramification that it does not turn on when it first rezzes. When you equip it it turns on) - Added the localOnly: true setting to the audio --- unpublishedScripts/parent-ator/parentator.js | 104 ++++++++++-------- .../parent-ator/resources/message-0-off.png | Bin 0 -> 5138 bytes 2 files changed, 61 insertions(+), 43 deletions(-) create mode 100644 unpublishedScripts/parent-ator/resources/message-0-off.png diff --git a/unpublishedScripts/parent-ator/parentator.js b/unpublishedScripts/parent-ator/parentator.js index ad38f524e6..546ac38ba1 100644 --- a/unpublishedScripts/parent-ator/parentator.js +++ b/unpublishedScripts/parent-ator/parentator.js @@ -16,6 +16,7 @@ (function() { + var MESSAGE_0_TEXTURE_URL = Script.resolvePath( 'resources/message-0-off.png' ); var MESSAGE_1_TEXTURE_URL = Script.resolvePath( 'resources/message-1-start.png' ); var MESSAGE_2_TEXTURE_URL = Script.resolvePath( 'resources/message-2-noperms.png' ); var MESSAGE_3_TEXTURE_URL = Script.resolvePath( 'resources/message-3-tryagain.png' ); @@ -28,6 +29,8 @@ var SOUND_SUCCESS_URL = Script.resolvePath( 'resources/parent-tool-sound-success.wav' ); var SOUND_1, SOUND_2, SOUND_ERROR, SOUND_SUCCESS; var childEntityID, parentEntityID; + var active = false; + @@ -35,9 +38,17 @@ return; } - Parentator.prototype.reset = function() { + Parentator.prototype.turnOff = function() { childEntityID = 0; parentEntityID = 0; + this.active = false; + Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_0_TEXTURE_URL }) }); + } + + Parentator.prototype.turnOn = function() { + childEntityID = 0; + parentEntityID = 0; + this.active = true; if (Entities.canRez()) { Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_1_TEXTURE_URL }) }); this.playSoundAtCurrentPosition( SOUND_1 ); @@ -47,6 +58,7 @@ } } + Parentator.prototype.preload = function( entityID ) { this.entityID = entityID; SOUND_1 = SoundCache.getSound( SOUND_1_URL ); @@ -54,73 +66,79 @@ SOUND_ERROR = SoundCache.getSound( SOUND_ERROR_URL ); SOUND_SUCCESS = SoundCache.getSound( SOUND_SUCCESS_URL ); - // The following is in case a user has been in a domain where they didn't have permission to rez - // (and that is displayed on the parent-tor screen) and then they move to a domain where they can rez - Window.domainChanged.connect( function() { - this.reset(); - }); + // Makue sure it's off + this.turnOff(); } Parentator.prototype.startEquip = function( args ) { this.hand = args[0]; - this.reset(); + this.turnOn(); + } + + + Parentator.prototype.releaseEquip = function( args ) { + this.hand = undefined; + this.turnOff(); } Parentator.prototype.collisionWithEntity = function( parentatorID, collidedID, collisionInfo ) { - // We don't want to be able to select Lights, Zone, and Particles but they are not collidable anyway so we don't have to worry about them - var collidedEntityProperties = Entities.getEntityProperties( collidedID ); + if ( this.active ) { + // We don't want to be able to select Lights, Zone, and Particles but they are not collidable anyway so we don't have to worry about them + var collidedEntityProperties = Entities.getEntityProperties( collidedID ); - if ( !Entities.canRez() ) { - Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_2_TEXTURE_URL }) }); - this.playSoundAtCurrentPosition( SOUND_ERROR ); - } - - // User has just reclicked the first entity (or it's 'bounced') - if ( childEntityID == collidedID ) { - return; - } - - if ( collidedEntityProperties.locked ) { - Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_3_TEXTURE_URL }) }); - this.playSoundAtCurrentPosition( SOUND_ERROR ); - return; - } - - // If no entity has been chosen - if ( childEntityID == 0 ) { - childEntityID = collidedID; - - // if there is a parentID, remove it - if ( collidedEntityProperties.parentID != "{00000000-0000-0000-0000-000000000000}" ) { - Entities.editEntity( collidedID, { parentID: "{00000000-0000-0000-0000-000000000000}" }); + if ( !Entities.canRez() ) { + Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_2_TEXTURE_URL }) }); + this.playSoundAtCurrentPosition( SOUND_ERROR ); } - if ( collidedEntityProperties.dynamic ) { - Entities.editEntity( collidedID, { dynamic: false }); + // User has just reclicked the first entity (or it's 'bounced') + if ( childEntityID == collidedID ) { + return; } - Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_4_TEXTURE_URL }) }); - this.playSoundAtCurrentPosition( SOUND_2 ); - } else { - parentEntityID = collidedID; - this.setParent(); + if ( collidedEntityProperties.locked ) { + Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_3_TEXTURE_URL }) }); + this.playSoundAtCurrentPosition( SOUND_ERROR ); + return; + } + + // If no entity has been chosen + if ( childEntityID == 0 ) { + childEntityID = collidedID; + + // if there is a parentID, remove it + if ( collidedEntityProperties.parentID != "{00000000-0000-0000-0000-000000000000}" ) { + Entities.editEntity( collidedID, { parentID: "{00000000-0000-0000-0000-000000000000}" }); + } + + if ( collidedEntityProperties.dynamic ) { + Entities.editEntity( collidedID, { dynamic: false }); + } + + Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_4_TEXTURE_URL }) }); + this.playSoundAtCurrentPosition( SOUND_2 ); + } else { + parentEntityID = collidedID; + this.setParent(); + } } } Parentator.prototype.setParent = function() { + var _this = this; Entities.editEntity( childEntityID, { parentID: parentEntityID }); Entities.editEntity( this.entityID, { textures: JSON.stringify({ "texture-message": MESSAGE_5_TEXTURE_URL }) }); this.playSoundAtCurrentPosition( SOUND_SUCCESS ); - Script.setTimeout( function() { - this.reset() - }.bind( this ), 5000 ); + _this.turnOn(); // reset + }, 5000 ); } Parentator.prototype.playSoundAtCurrentPosition = function( sound ) { var audioProperties = { volume: 0.3, - position: Entities.getEntityProperties( this.entityID ).position + position: Entities.getEntityProperties( this.entityID ).position, + localOnly: true } Audio.playSound( sound, audioProperties ); } diff --git a/unpublishedScripts/parent-ator/resources/message-0-off.png b/unpublishedScripts/parent-ator/resources/message-0-off.png new file mode 100644 index 0000000000000000000000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