Fixed entity script loading functionality for the jsstreamplayer.

This commit is contained in:
Kevini M. Thomas 2016-01-13 14:34:44 -05:00
parent 6f85ee135f
commit 007013254e
2 changed files with 23 additions and 9 deletions

View file

@ -28,6 +28,6 @@
};
if (!isScriptRunning(SCRIPT_NAME)) {
Script.load(SCRIPT_NAME);
ScriptDiscoveryService.loadOneScript(SCRIPT_NAME);
}
})

View file

@ -116,7 +116,7 @@ function mousePressEvent(event) {
// Function checking bool if in proper zone.
function isOurZone(properties) {
return stream != "" && properties.type == "Zone";
return stream != "" && stream != undefined && properties.type == "Zone";
}
// Function to toggle visibile the overlay.
@ -130,6 +130,20 @@ function toggleVisible(newVisibility) {
}
}
// Procedure to check to see if you within a zone with a given stream.
var entities = Entities.findEntities(MyAvatar.position, 0.1);
for (var i in entities) {
var properties = Entities.getEntityProperties(entities[i]);
if (properties.type == "Zone") {
print("Entered zone: " + JSON.stringify(entities[i]));
stream = JSON.parse(properties.userData).stream;
if (isOurZone(properties)) {
print("Entered zone " + JSON.stringify(entities[i]) + " with stream: " + stream);
lastZone = properties.name;
toggleVisible(true);
}
}
}
// Function to check if avatar is in proper domain.
Window.domainChanged.connect(function() {
Script.stop();
@ -139,7 +153,7 @@ Window.domainChanged.connect(function() {
Entities.enterEntity.connect(function(entityID) {
print("Entered..." + JSON.stringify(entityID));
var properties = Entities.getEntityProperties(entityID);
stream = properties.userData;
stream = JSON.parse(properties.userData).stream;
if(isOurZone(properties))
{
lastZone = properties.name;