Update portal to ensure that properties exist

This commit is contained in:
Ryan Huffman 2016-10-27 15:03:15 -07:00
parent 7227e5770a
commit 47d7e89699

View file

@ -1,24 +1,31 @@
(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');
if (properties) {
portalDestination = properties.userData; 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
if (properties) {
portalDestination = properties.userData; portalDestination = properties.userData;
print("portal.js | enterEntity() .... The portal destination is " + portalDestination); print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
@ -34,7 +41,7 @@
} else { } else {
location.goToEntry(); // going forward: no data means go to appropriate entry point location.goToEntry(); // going forward: no data means go to appropriate entry point
} }
}
}; };
this.leaveEntity = function(entityID) { this.leaveEntity = function(entityID) {