From 894856b6258b249d56f1a73eacafe9089064f862 Mon Sep 17 00:00:00 2001 From: An Orbit <68935009+orbit-loona@users.noreply.github.com> Date: Mon, 8 May 2023 12:56:13 -0400 Subject: [PATCH] Update and rename invisible_dye.js to invisible_things.js merge invisible dye and wall --- mods/invisible_dye.js | 43 --------------------- mods/invisible_things.js | 83 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 43 deletions(-) delete mode 100644 mods/invisible_dye.js create mode 100644 mods/invisible_things.js diff --git a/mods/invisible_dye.js b/mods/invisible_dye.js deleted file mode 100644 index e9f09a23..00000000 --- a/mods/invisible_dye.js +++ /dev/null @@ -1,43 +0,0 @@ -if(!settings) { - settings = {} -} - -if(!settings.bg) { - settings.bg = "#000000" -} - -elements.invisible_dye = { - color: settings.bg, - behavior: behaviors.LIQUID, - tick: function(pixel) { - var backgroundColor = hexToRGB(settings.bg); - var rgbValue = "rgb("+backgroundColor.r+","+backgroundColor.g+","+backgroundColor.b+")"; - pixel.color = rgbValue; - }, - hardness: 0.8, - breakInto: "invisible_dye_gas", - tempHigh: 110, - stateHigh: "invisible_dye_gas", - category: "special", - state: "liquid", - density: 1, - stain: elements.dye.stain, -}; - -elements.invisible_dye_gas = { - color: settings.bg, - behavior: behaviors.GAS, - tick: function(pixel) { - var backgroundColor = hexToRGB(settings.bg); - var rgbValue = "rgb("+backgroundColor.r+","+backgroundColor.g+","+backgroundColor.b+")"; - pixel.color = rgbValue; - }, - hardness: 0.5, - breakInto: "invisible_dye_gas", - tempLow: 109, - stateLow: "invisible_dye", - category: "special", - state: "liquid", - density: 1, - stain: elements.spray_paint.stain, -}; diff --git a/mods/invisible_things.js b/mods/invisible_things.js new file mode 100644 index 00000000..c80c17d8 --- /dev/null +++ b/mods/invisible_things.js @@ -0,0 +1,83 @@ +var modName = "mods/invisible_things.js"; +var libraryMod = "mods/code_library.js"; + +if(enabledMods.includes(libraryMod)) { + if(!settings) { + settings = {} + } + + if(!(settings.bg)) { + settings.bg = "#000000" + } + + function getBackgroundColorOrAverageAsJSON() { + if(!(settings?.bg)) { + return {r: 0, g: 0, b: 0}; + } else if(!(settings.bg instanceof Array)) { + return convertColorFormats(settings.bg,"json") + } else { + return convertColorFormats(averageRgbPrefixedColorArray(settings.bg.map(color => convertColorFormats(color,"rgb"))),"json"); + }; + }; + + function makePixelInvisible(pixel) { + var backgroundColor = getBackgroundColorOrAverageAsJSON(); + pixel.color = `rgba(${backgroundColor.r},${backgroundColor.g},${backgroundColor.b},0)`; + }; + + elements.invisible_wall = { + color: settings.bg, + behavior: behaviors.WALL, + tick: function(pixel) { makePixelInvisible(pixel) }, + insulate: true, + hardness: 1, + category: "special", + state: "solid", + }; + + elements.invisible_dye = { + color: settings.bg, + behavior: behaviors.LIQUID, + tick: function(pixel) { makePixelInvisible(pixel) }, + hardness: 0.8, + breakInto: "invisible_dye_gas", + tempHigh: 110, + stateHigh: "invisible_dye_gas", + category: "special", + state: "liquid", + density: 1, + stain: elements.dye.stain, + }; + + elements.invisible_dye_gas = { + color: settings.bg, + behavior: behaviors.GAS, + tick: function(pixel) { makePixelInvisible(pixel) }, + hardness: 0.5, + breakInto: "invisible_dye_gas", + tempLow: 109, + stateLow: "invisible_dye", + category: "special", + state: "liquid", + density: 1, + stain: elements.spray_paint.stain, + }; + + var temp = { + invisible_wall: "asdfg", + invisible_dye: 2, + invisible_dye_gas: false + }; + + if(enabledMods.includes("mods/gradient_background_support.js")) { + for(var elemName in temp) { + elements[elemName].desc = "Invisible dyes do not work and are not supported with gradient backgrouds"; + elements[elemName].hidden = true; + elements[elemName].excludeRandom = true; + }; + }; +} else { + enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) + localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); + alert(`The ${libraryMod} mod is required and has been automatically inserted (reload for this to take effect).`) +};