Merge pull request #9539 from huffman/feat/tealight-entity-server

Add tealight.js entity server script
This commit is contained in:
Chris Collins 2017-01-31 20:51:19 -08:00 committed by GitHub
commit 8b94e64082

View file

@ -0,0 +1,21 @@
(function() {
var MINIMUM_LIGHT_INTENSITY = 100.0;
var MAXIMUM_LIGHT_INTENSITY = 125.0;
// Return a random number between `low` (inclusive) and `high` (exclusive)
function randFloat(low, high) {
return low + Math.random() * (high - low);
}
var self = this;
this.preload = function(entityID) {
self.intervalID = Script.setInterval(function() {
Entities.editEntity(entityID, {
intensity: randFloat(MINIMUM_LIGHT_INTENSITY, MAXIMUM_LIGHT_INTENSITY)
});
}, 100);
};
this.unload = function() {
Script.clearInterval(self.intervalID);
}
});