51 lines · 2.2 KB · JavaScript
RawDownload
(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("TutorialStartZone | Entered the tutorial start area");            if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable()) {                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 | Sending start");                        Entities.callEntityMethod(parentID, 'onEnteredStartZone');                    } else {                        print("TutorialStartZone | ERROR: No parent id found on tutorial start zone");                    }                }                this.sendStartIntervalID = Script.setInterval(sendStart, 1500);                sendStart();            } 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 Vive headset and hand controllers.");                location = "/";            }        },        leaveEntity: function() {            print("TutorialStartZone | Exited the tutorial start area");            if (this.sendStartIntervalID) {                Script.clearInterval(this.sendStartIntervalID);            }            var parentID = Entities.getEntityProperties(this.entityID, 'parentID').parentID;            print("TutorialStartZone | Parent ID is: ", parentID);            if (parentID) {                print("TutorialStartZone | Sending onLeftStartZone");                Entities.callEntityMethod(parentID, 'on');            }        }    };     return new TutorialStartZone();});