Merge pull request #8890 from howard-stearns/fix-home-portal-destination

add home portal entity script and make it go to correct welcome
This commit is contained in:
Howard Stearns 2016-10-24 14:49:00 -07:00 committed by GitHub
commit ab21487a6d

View file

@ -0,0 +1,45 @@
(function(){
var teleport;
var portalDestination;
function playSound() {
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
};
this.preload = function(entityID) {
teleport = SoundCache.getSound("atp:/sounds/teleport.raw");
var properties = Entities.getEntityProperties(entityID);
portalDestination = properties.userData;
print("portal.js | The portal destination is " + portalDestination);
}
this.enterEntity = function(entityID) {
print("portal.js | enterEntity");
var properties = Entities.getEntityProperties(entityID); // in case the userData/portalURL has changed
portalDestination = properties.userData;
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
if (portalDestination.length > 0) {
if (portalDestination[0] == '/') {
print("Teleporting to " + portalDestination);
Window.location = portalDestination;
} else {
print("Teleporting to hifi://" + portalDestination);
Window.location = "hifi://" + portalDestination;
}
} else {
location.goToEntry(); // going forward: no data means go to appropriate entry point
}
};
this.leaveEntity = function(entityID) {
print("portal.js | leaveEntity");
playSound();
};
})