// testACSCript.js // created by Mark Brosche 12-17-18 // Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var SEARCH_CENTER = {x: 66.2089, y: -5.3655, z: 1.6316}, SEARCH_AREA= 1000, counterID = "{43a1dc50-149b-43aa-8a51-8f3b7e3109fc}", statusID = "{c375e2c8-a524-4e70-8242-8705d981ee64}"; // This function is used to allow the AC script to see and change entities // in the domain. function allowEntityAccess() { Entities.setPacketsPerSecond(6000); EntityViewer.setPosition(SEARCH_CENTER); EntityViewer.setCenterRadius(10000); // This should allow us to see nano-scale entities from great distances EntityViewer.setVoxelSizeScale(Number.MAX_VALUE); Script.setInterval(function() { EntityViewer.queryOctree(); }, 1000); console.log("This AC script now has access to entities in this domain!"); Script.setTimeout(function(){ console.log("Entities here: ", JSON.stringify(Entities.findEntities(SEARCH_CENTER, SEARCH_AREA))); console.log("counterID here: ", JSON.stringify(Entities.getEntityProperties(counterID, SEARCH_CENTER, SEARCH_AREA))); console.log("Money Tree Counter here: ", JSON.stringify(Entities.findEntitiesByName("Money Tree Counter", SEARCH_CENTER, SEARCH_AREA))); console.log("Money Tree Status here: ", JSON.stringify(Entities.findEntitiesByName("Money Tree Status", SEARCH_CENTER, SEARCH_AREA))); console.log("Money Tree Status Info:", JSON.stringify(Entities.getEntityProperties( Entities.findEntitiesByName("Money Tree Status", SEARCH_CENTER, SEARCH_AREA)[0] ) ) ); },10000); } // This function checks to make sure that the entity server exists // and that the AC script has Rez permissions. // If one or both of those things is false, we'll check again in 5 seconds. function maybeAllowEntityAccess() { console.log("Attempting to give this AC script entity access..."); if (Entities.serversExist() && Entities.canRez()) { allowEntityAccess(); } else { if (!Entities.canRez()) { console.log("This AC script doesn't have rez permissions!"); } Script.setTimeout(maybeAllowEntityAccess, 5000); } } // This function will be called on startup. function startup() { // Listen on the slot machine messaging channel! maybeAllowEntityAccess(); // var trial = entityExistsInDomain(counterID); // Script.setTimeout(function(){ // while (trial == false) { // console.log("trial is ", trial); // trial = entityExistsInDomain(counterID); // var counterText = Entities.getEntityProperties(counterID, ["id"]).id; // Entities.editEntity(counterText, {text: "--"}); // var activeText = Entities.getEntityProperties(statusID, ["id"]).id; // Entities.editEntity(activeText, {text: "BOOTING UP"}); // console.log("[MONEY TREE] Found entities", counterText, activeText); // } // }, 10000); } function entityExistsInDomain(entityID) { if (Entities.getEntityProperties(entityID, ["id"]).id) { return true; } else { console.log("Entity doesn't exist! ID: " + entityID); return false; } } Agent.isAvatar = false; startup();