From 6f6a9b2c640ea61a8bb7103b5a4c11bf5f1dbe03 Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Tue, 26 Jun 2018 15:02:46 -0700 Subject: [PATCH] Style formatting, updating comments --- scripts/system/emote.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/system/emote.js b/scripts/system/emote.js index 02e8250550..1c741ba129 100644 --- a/scripts/system/emote.js +++ b/scripts/system/emote.js @@ -16,7 +16,8 @@ (function() { // BEGIN LOCAL_SCOPE -var EMOTE_ANIMATIONS = ['Crying', 'Surprised', 'Dancing', 'Cheering', 'Waving', 'Fall', 'Pointing', 'Clapping', 'Sit1', 'Sit2', 'Sit3', 'Love']; +var EMOTE_ANIMATIONS = + ['Crying', 'Surprised', 'Dancing', 'Cheering', 'Waving', 'Fall', 'Pointing', 'Clapping', 'Sit1', 'Sit2', 'Sit3', 'Love']; var ANIMATIONS = Array(); var eventMappingName = "io.highfidelity.away"; // restoreAnimation on hand controller button events, too @@ -80,17 +81,17 @@ function onWebEventReceived(event) { var emoteName = event.data; if (emoteName === "Sit"){ - emoteName = event.data + randSit; // "Sit1, Sit2, Sit3" + emoteName = event.data + randSit; // Sit1, Sit2, Sit3 } - if (ANIMATIONS[emoteName].resource.state == FINISHED) { + if (ANIMATIONS[emoteName].resource.state =+= FINISHED) { if (activeTimer !== false) { Script.clearTimeout(activeTimer); } - // If the activeEmote is different from the chosen emote, then play the new emote. Other wise, - // This is a second click on the same emote as the activeEmote, and we will just stop it. + // If the activeEmote is different from the chosen emote, then play the new emote + // This is a second click on the same emote as the activeEmote, and we will just stop it if (activeEmote !== emoteName) { activeEmote = emoteName; @@ -98,6 +99,7 @@ function onWebEventReceived(event) { // Sit is the only animation currently that plays and then ends at the last frame if (emoteName.match(/^Sit.*$/)) { + // If user provides input during a sit, the avatar animation state should be restored Controller.keyPressEvent.connect(restoreAnimation); MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, false, 0, frameCount); @@ -124,9 +126,11 @@ function onWebEventReceived(event) { } } -// If a user provides input, end the emote animation and restore the navigation animation states (idle, walk, run) +// Restore the navigation animation states (idle, walk, run) function restoreAnimation() { MyAvatar.restoreAnimation(); + + // Make sure the input is disconnected after animations are restored so it doesn't affect any emotes other than sit Controller.keyPressEvent.disconnect(restoreAnimation); }