From e4d630b1fc6b3899d6862f3e26ed6a1dca792f67 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Mon, 21 Sep 2015 15:57:03 -0700 Subject: [PATCH] more light toggling additions --- examples/toybox/entityScripts/lightSwitch.js | 12 ++++++++++-- examples/toybox/masterResetEntity.js | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/toybox/entityScripts/lightSwitch.js b/examples/toybox/entityScripts/lightSwitch.js index bb80d76f57..17709764d6 100644 --- a/examples/toybox/entityScripts/lightSwitch.js +++ b/examples/toybox/entityScripts/lightSwitch.js @@ -31,7 +31,14 @@ startNearGrab: function() { print("TOGGLE LIGHT") - + this.lightState = getEntityCustomData(this.lightStateKey, this.entityID, defaultLightData); + if (this.lightState.on === true) { + //Delete the all the sconce lights + var entities = Entities.findEntities(MyAvatar.position, 100); + entities.forEach(function(entity){ + var resetData = getEntityCustomData(this.resetKey, entity, {}) + }); + } // var position = Entities.getEntityProperties(this.entityID, "position").position; // Audio.playSound(clickSound, { // position: position, @@ -64,7 +71,8 @@ }); setEntityCustomData(this.resetKey, this.sconceLight1, { - resetMe: true + resetMe: true, + lightType: "sconceLight" }); }, diff --git a/examples/toybox/masterResetEntity.js b/examples/toybox/masterResetEntity.js index ecc657ecc7..f7e0f3524b 100644 --- a/examples/toybox/masterResetEntity.js +++ b/examples/toybox/masterResetEntity.js @@ -56,8 +56,9 @@ function deleteAllToys() { entities.forEach(function(entity) { //params: customKey, id, defaultValue - var shouldReset = getEntityCustomData(resetKey, entity, false); - if (shouldReset) { + var shouldReset = getEntityCustomData(resetKey, entity, {}).resetMe; + print("should reset " + JSON.stringify(shouldReset)); + if (shouldReset === true) { Entities.deleteEntity(entity); } })