From a8f223518cd7edfe239e71522e896856c2111c1a Mon Sep 17 00:00:00 2001 From: kunalgosar Date: Fri, 10 Feb 2017 17:27:52 -0800 Subject: [PATCH] modified away script to use MyAvatar.isAway property --- scripts/system/away.js | 49 +++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/scripts/system/away.js b/scripts/system/away.js index 96813031f1..541fe6f679 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -165,9 +165,36 @@ function goAway(fromStartup) { if (!isEnabled || isAway) { return; } - + + // If we're entering away mode from some other state than startup, then we create our move timer immediately. + // However if we're just stating up, we need to delay this process so that we don't think the initial teleport + // is actually a move. + if (fromStartup === undefined || fromStartup === false) { + avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL); + } else { + var WAIT_FOR_MOVE_ON_STARTUP = 3000; // 3 seconds + Script.setTimeout(function() { + avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL); + }, WAIT_FOR_MOVE_ON_STARTUP); + } + UserActivityLogger.toggledAway(true); + MyAvatar.isAway = true; +} +function goActive() { + if (!isAway) { + return; + } + + UserActivityLogger.toggledAway(false); + MyAvatar.isAway = false; +} + +MyAvatar.wentAway.connect(setAwayProperties) +MyAvatar.wentActive.connect(setActiveProperties) + +function setAwayProperties() { isAway = true; wasMuted = AudioDevice.getMuted(); if (!wasMuted) { @@ -189,27 +216,9 @@ function goAway(fromStartup) { wasHmdMounted = HMD.mounted; // always remember the correct state avatarPosition = MyAvatar.position; - - // If we're entering away mode from some other state than startup, then we create our move timer immediately. - // However if we're just stating up, we need to delay this process so that we don't think the initial teleport - // is actually a move. - if (fromStartup === undefined || fromStartup === false) { - avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL); - } else { - var WAIT_FOR_MOVE_ON_STARTUP = 3000; // 3 seconds - Script.setTimeout(function() { - avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL); - }, WAIT_FOR_MOVE_ON_STARTUP); - } } -function goActive() { - if (!isAway) { - return; - } - - UserActivityLogger.toggledAway(false); - +function setActiveProperties() { isAway = false; if (!wasMuted) { AudioDevice.toggleMute();