From 504295cdcf4cfff98c844072b61a3c3af9f4d149 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 4 Oct 2016 11:03:42 -0700 Subject: [PATCH] Add extra logging to tutorial zones --- tutorial/tutorialStartZone.js | 28 +++++++++++++++++++++------- tutorial/tutorialZone.js | 27 +++++++++++++++------------ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/tutorial/tutorialStartZone.js b/tutorial/tutorialStartZone.js index 5adad1d00a..8dec47b7ac 100644 --- a/tutorial/tutorialStartZone.js +++ b/tutorial/tutorialStartZone.js @@ -1,28 +1,42 @@ (function() { var TutorialStartZone = function() { + print("TutorialStartZone | Creating"); }; TutorialStartZone.prototype = { preload: function(entityID) { + print("TutorialStartZone | Preload"); this.entityID = entityID; + this.sendStartIntervalID = null; }, enterEntity: function() { + var self = this; // send message to outer zone - print("Entered the tutorial start area"); + print("TutorialStartZone | Entered the tutorial start area"); if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable()) { - var parentID = Entities.getEntityProperties(this.entityID, 'parentID').parentID; - if (parentID) { - Entities.callEntityMethod(parentID, 'start'); - } else { - print("ERROR: No parent id found on tutorial start zone"); + function sendStart() { + print("TutorialStartZone | Checking parent ID"); + var parentID = Entities.getEntityProperties(self.entityID, 'parentID').parentID; + print("TutorialStartZone | Parent ID is: ", parentID); + if (parentID) { + print("TutorialStartZone | Entered the tutorial start area"); + Entities.callEntityMethod(parentID, 'start'); + } else { + print("TutorialStartZone | ERROR: No parent id found on tutorial start zone"); + } } + this.sendStartIntervalID = Script.setInterval(sendStart, 1500); } else { + print("TutorialStartZone | User tried to go to tutorial with HMD and hand controllers, sending back to /"); Window.alert("To proceed with this tutorial, please connect your VR headset and hand controllers."); location = "/"; } }, leaveEntity: function() { - print("Exited the tutorial start area"); + print("TutorialStartZone | Exited the tutorial start area"); + if (this.sendStartIntervalID) { + Script.clearInterval(this.sendStartIntervalID); + } } }; diff --git a/tutorial/tutorialZone.js b/tutorial/tutorialZone.js index e64d0f2445..db7306a529 100644 --- a/tutorial/tutorialZone.js +++ b/tutorial/tutorialZone.js @@ -33,6 +33,7 @@ if (!Function.prototype.bind) { Script.include(tutorialPath); var TutorialZone = function() { + print("TutorialZone | Creating"); this.token = null; }; @@ -55,34 +56,36 @@ if (!Function.prototype.bind) { } }, preload: function(entityID) { + print("TutorialZone | Preload"); this.entityID = entityID; }, start: function() { - print("Got start"); + print("TutorialZone | Got start"); var self = this; if (!this.token) { + print("TutorialZone | Creating token"); this.token = new OwnershipToken(Math.random() * 100000, this.entityID, { onGainedOwnership: function(token) { - print("GOT OWNERSHIP"); + print("TutorialZone | GOT OWNERSHIP"); if (!self.tutorialManager) { self.tutorialManager = new TutorialManager(); } self.tutorialManager.startTutorial(); - print("making bound release handler"); + print("TutorialZone | making bound release handler"); self.keyReleaseHandlerBound = self.keyReleaseHandler.bind(self); - print("binding"); + print("TutorialZone | binding"); Controller.keyReleaseEvent.connect(self.keyReleaseHandlerBound); - print("done"); + print("TutorialZone | done"); }, onLostOwnership: function(token) { - print("LOST OWNERSHIP"); + print("TutorialZone | LOST OWNERSHIP"); if (self.tutorialManager) { - print("stopping tutorial.."); + print("TutorialZone | stopping tutorial.."); self.tutorialManager.stopTutorial(); - print("done"); + print("TutorialZone | done"); Controller.keyReleaseEvent.disconnect(self.keyReleaseHandlerBound); } else { - print("no tutorial manager..."); + print("TutorialZone | no tutorial manager..."); } } }); @@ -90,12 +93,12 @@ if (!Function.prototype.bind) { }, enterEntity: function() { - print("ENTERED THE TUTORIAL AREA"); + print("TutorialZone | ENTERED THE TUTORIAL AREA"); }, leaveEntity: function() { - print("EXITED THE TUTORIAL AREA"); + print("TutorialZone | EXITED THE TUTORIAL AREA"); if (this.token) { - print("destroying token"); + print("TutorialZone | Destroying token"); this.token.destroy(); this.token = null; }