mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 02:53:10 +02:00
Update portal to ensure that properties exist
This commit is contained in:
parent
7227e5770a
commit
47d7e89699
1 changed files with 24 additions and 17 deletions
|
@ -1,40 +1,47 @@
|
||||||
(function(){
|
(function(){
|
||||||
var teleport;
|
var teleport;
|
||||||
var portalDestination;
|
var portalDestination;
|
||||||
|
var thisEntityID;
|
||||||
|
|
||||||
function playSound() {
|
function playSound() {
|
||||||
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
|
var properties = Entities.getEntityProperties(thisEntityID, 'position');
|
||||||
|
if (properties) {
|
||||||
|
Audio.playSound(teleport, { position: properties.position, volume: 0.40, localOnly: true });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
this.preload = function(entityID) {
|
||||||
|
thisEntityID = entityID;
|
||||||
teleport = SoundCache.getSound("atp:/sounds/teleport.raw");
|
teleport = SoundCache.getSound("atp:/sounds/teleport.raw");
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(entityID);
|
var properties = Entities.getEntityProperties(entityID, 'userData');
|
||||||
portalDestination = properties.userData;
|
if (properties) {
|
||||||
|
portalDestination = properties.userData;
|
||||||
print("portal.js | The portal destination is " + portalDestination);
|
print("portal.js | The portal destination is " + portalDestination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enterEntity = function(entityID) {
|
this.enterEntity = function(entityID) {
|
||||||
print("portal.js | enterEntity");
|
print("portal.js | enterEntity");
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(entityID); // in case the userData/portalURL has changed
|
var properties = Entities.getEntityProperties(entityID, 'userData'); // in case the userData/portalURL has changed
|
||||||
portalDestination = properties.userData;
|
if (properties) {
|
||||||
|
portalDestination = properties.userData;
|
||||||
|
|
||||||
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
|
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
|
||||||
|
|
||||||
if (portalDestination.length > 0) {
|
if (portalDestination.length > 0) {
|
||||||
if (portalDestination[0] == '/') {
|
if (portalDestination[0] == '/') {
|
||||||
print("Teleporting to " + portalDestination);
|
print("Teleporting to " + portalDestination);
|
||||||
Window.location = portalDestination;
|
Window.location = portalDestination;
|
||||||
|
} else {
|
||||||
|
print("Teleporting to hifi://" + portalDestination);
|
||||||
|
Window.location = "hifi://" + portalDestination;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print("Teleporting to hifi://" + portalDestination);
|
location.goToEntry(); // going forward: no data means go to appropriate entry point
|
||||||
Window.location = "hifi://" + portalDestination;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
location.goToEntry(); // going forward: no data means go to appropriate entry point
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.leaveEntity = function(entityID) {
|
this.leaveEntity = function(entityID) {
|
||||||
|
|
Loading…
Reference in a new issue