diff --git a/mods/code_library.js b/mods/code_library.js index 50412627..0afacccf 100644 --- a/mods/code_library.js +++ b/mods/code_library.js @@ -1,7 +1,15 @@ +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //URL urlParams = new URLSearchParams(window.location.search); +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Objects //getKeyByValue code by SO UncleLaz: https://stackoverflow.com/questions/9907419/how-to-get-a-key-in-a-javascript-object-by-its-value @@ -10,6 +18,10 @@ return Object.keys(object).find(key => object[key] === value); }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //RNG //Random integer from 0 to n @@ -77,6 +89,10 @@ return Math.floor(randomFunction() * (max - min + 1)) + min }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Arrays //Shallow array comparer by SO Tim Down: https://stackoverflow.com/a/10260204 @@ -158,6 +174,10 @@ }; }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Checks //Element exists in the elements object @@ -260,6 +280,10 @@ return false; }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Math(s) //Base n logarithm from https://stackoverflow.com/a/3019290 @@ -305,6 +329,10 @@ return (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; } +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Color function rgbStringToUnvalidatedObject(string) { //turns rgb() to {r,g,b} with no bounds checking @@ -1182,7 +1210,11 @@ //console.log(`Hexed to #${f(0)}${f(8)}${f(4)}`) return `#${f(0)}${f(8)}${f(4)}`; }; - + +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Pixels function exposedToAir(pixel) { @@ -1540,6 +1572,10 @@ return true; }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //World function breakCircle(x,y,radius,respectHardness=false,changeTemp=false,defaultBreakIntoDust=false) { @@ -1639,6 +1675,10 @@ return true; }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Logic function xor(c1,c2) { @@ -1651,6 +1691,10 @@ }; }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //currentPixels operations function findInCurrentPixels(x,y) { @@ -1710,6 +1754,10 @@ }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Sugar functions function newElement(name="element_name",color="#FF00FF",otherProps={}) { @@ -1722,6 +1770,10 @@ return elements[name]; }; +libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; + //Fixes //fix -1-caused ghost pixels @@ -1750,8 +1802,13 @@ }; libraryLoaded = true; +this.libraryLoaded = true; +window.libraryLoaded = true; runAfterLoad(function() { - libraryLoaded = true; - const libraryLoaded = true; -}); + if(!libraryLoaded) { + libraryLoaded = true; + this.libraryLoaded = true; + window.libraryLoaded = true + } +})