From f88433b7bb25c1ad3862d1e302f4507dc32e9e45 Mon Sep 17 00:00:00 2001
From: Ryan Huffman <ryanhuffman@gmail.com>
Date: Fri, 27 Jan 2017 11:23:17 -0800
Subject: [PATCH] Add tealight.js entity server script

---
 .../marketplace/teaLight/teaLight.js          | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 unpublishedScripts/marketplace/teaLight/teaLight.js

diff --git a/unpublishedScripts/marketplace/teaLight/teaLight.js b/unpublishedScripts/marketplace/teaLight/teaLight.js
new file mode 100644
index 0000000000..85b0a3c310
--- /dev/null
+++ b/unpublishedScripts/marketplace/teaLight/teaLight.js
@@ -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);
+    }
+});