From 22c9701fafba2c21c2a451b6d77e7d3285644027 Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:14:59 -0500 Subject: [PATCH] nondescript changes --- mods/code_library.js | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/mods/code_library.js b/mods/code_library.js index 8aa6305f..90dc00e7 100644 --- a/mods/code_library.js +++ b/mods/code_library.js @@ -128,6 +128,32 @@ return typeof(elements[elementName]) === "object"; }; + //Has a given state + function isState(elementName,inputState) { + if(!elementExists(elementName)) { + throw new Error(`Element ${elementName} doesn't exist`); + }; + + var infoState = elements[elementName].state; + + if(infoState == undefined) { infoState = "undefined" }; + + if(inputState == undefined) { inputState = "undefined" }; + if(inputState instanceof Array) { + var limit = 0; + while(inputState.includes(undefined) && limit < 3) { + inputState[inputState.indexOf(undefined)] = "undefined" + limit++; + }; + }; + + if(inputState instanceof Array) { + return inputState.includes(infoState); + }; + + return infoState == inputState; + }; + //Check if pixel of given element exists at given location function hasPixel(x,y,elementInput) { if(isEmpty(x,y,true)) { //if empty, it can't have a pixel @@ -1012,9 +1038,10 @@ return convertHslObjects(color,outputType); }; - function colorToHsl(color,outputType) { + function colorToHsl(color,outputType="rgb") { color = convertColorFormats(color,"rgb"); - color = rgbStringToHSL("color",) + color = rgbStringToHSL(color,outputType); + return color; }; //https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex @@ -1229,6 +1256,16 @@ }; }; + function isOpenAndOnSurface(x,y,includeBottomBound=true) { + if(!isEmpty(x,y,false)) { + return false; + }; + if(y + 1 == height) { + return includeBottomBound; + }; + return !isEmpty(x,y+1,true); + }; + //Logic function xor(c1,c2) {