From 370bee406a55966e3e4426a0fdac82b78a02a721 Mon Sep 17 00:00:00 2001 From: Youka Date: Sat, 17 Jan 2015 15:01:56 +0100 Subject: [PATCH] added option to put library in global scope immediately --- docs/content_format.js | 8 ++++---- docs/index.html | 5 ++++- src/Yutils.lua | 7 ++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/content_format.js b/docs/content_format.js index 40dcb00..57a93f1 100644 --- a/docs/content_format.js +++ b/docs/content_format.js @@ -168,11 +168,11 @@ window.addEventListener("load", function(evt){ // Add right space for vertical scrollbar (on appearance) fixScrollBar(code, "vertical"); // Set code highlight - code.addEventListener("mouseover", function(){ - numberBar.style.display = "table-cell"; + code.addEventListener("mouseover", function(evt){ + evt.currentTarget.childNodes[1].style.display = "table-cell"; }) - code.addEventListener("mouseout", function(){ - numberBar.style.display = "none"; + code.addEventListener("mouseout", function(evt){ + evt.currentTarget.childNodes[1].style.display = "none"; }) } } diff --git a/docs/index.html b/docs/index.html index dcbe0c0..dd69fa7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -48,7 +48,10 @@

YutilsAn ASS typeset utilities library

local Ymath = Yutils.math print(Ymath.distance(1,1)) --- 1.4142135623731 +-- 1.4142135623731
+It's also possible to load+execute the library script with the first argument as true to register Yutils to the global scope.
+
loadfile("Yutils.lua")(true) +local Ymath = Yutils.math
diff --git a/src/Yutils.lua b/src/Yutils.lua index 9472e17..49e92d8 100644 --- a/src/Yutils.lua +++ b/src/Yutils.lua @@ -19,7 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------------------------------------------- - Version: 14th November 2014, 15:45 (GMT+1) + Version: 17th January 2015, 15:45 (GMT+1) Yutils table @@ -3525,5 +3525,10 @@ Yutils = { } } +-- Put library in global scope (if first script argument is true) +if ({...})[1] then + _G.Yutils = Yutils +end + -- Return library to script loader return Yutils \ No newline at end of file