From 02037e21f305f05681d67922832fbf2c515b7f83 Mon Sep 17 00:00:00 2001 From: An Orbit <68935009+orbit-loona@users.noreply.github.com> Date: Sat, 18 May 2024 00:32:32 -0400 Subject: [PATCH] the fixening, part 1 of many --- mods/a_mod_by_alice.js | 492 ++++++++++++++++++++++++----------------- 1 file changed, 291 insertions(+), 201 deletions(-) diff --git a/mods/a_mod_by_alice.js b/mods/a_mod_by_alice.js index bae9e2fd..b8661677 100644 --- a/mods/a_mod_by_alice.js +++ b/mods/a_mod_by_alice.js @@ -2587,15 +2587,14 @@ color1 and color2 spread through striped paint like dye does with itself. col pixelSizeHalf = newPixelSize/2; height = Math.round(newHeight/newPixelSize)-1; width = Math.round(newWidth/newPixelSize)-1; - mousePos = {x:width/2,y:height/2}; + mousePos = {x:Math.round(width/2),y:Math.round(height/2)}; if (clear!==false) { clearAll(); } - }; + } autoResizeCanvas = function(clear) { + pixelSize = settings.pixelsize || 6; if (window.innerWidth < 700) { - pixelSize = 5; - } else { - pixelSize = 6; + pixelSize--; } if (window.innerWidth < 700) { var newWidth = Math.ceil(window.innerWidth / pixelSize) * pixelSize; @@ -2849,21 +2848,30 @@ color1 and color2 spread through striped paint like dye does with itself. col elements[key].color = "rgb(255,255,255)"; elements[key].colorObject = {r:255,g:255,b:255}; } - // If the element's behavior is an array and contains M1 or M2, set its movable to true - if (elements[key].behavior && typeof elements[key].behavior[0] === "object") { - var bstring = JSON.stringify(elements[key].behavior); - if (bstring.indexOf("M1")!==-1 || bstring.indexOf("M2")!==-1) { elements[key].movable = true; } + if (elements[key].movable === undefined) { + // If the element's behavior is an array and contains M1 or M2, set its movable to true + if (elements[key].behavior && typeof elements[key].behavior[0] === "object") { + var bstring = JSON.stringify(elements[key].behavior); + if (bstring.indexOf("M1")!==-1 || bstring.indexOf("M2")!==-1) { elements[key].movable = true; } + } + if (elements[key].tick) { elements[key].movable = true; } } - if (elements[key].tick) { elements[key].movable = true; } if (elements[key].behavior) { + var behavior = elements[key].behavior; + var behaviorCenterY = behavior[Math.floor(behavior.length/2)] + var behaviorCenter = behaviorCenterY[Math.floor(behaviorCenterY.length/2)] // If the element's behavior[1][1] includes "FX", set it's flippableX to true - if (elements[key].behavior[1][1].indexOf("FX") !== -1) { + if (behaviorCenter.indexOf("FX") !== -1) { elements[key].flippableX = true; } // If the element's behavior[1][1] includes "FY", set it's flippableY to true - if (elements[key].behavior[1][1].indexOf("FY") !== -1) { + if (behaviorCenter.indexOf("FY") !== -1) { elements[key].flippableY = true; } + // If the element's behavior[1][1] includes "RT", set it's rotatable to "true" + if (behaviorCenter.indexOf("RT") !== -1) { + elements[key].rotatable = true; + } // If the element's behavior stringified includes "BO", loop through the behavior if (elements[key].behavior.toString().indexOf("BO") !== -1 && !elements[key].rotatable) { @@ -2887,11 +2895,6 @@ color1 and color2 spread through striped paint like dye does with itself. col } } - // If the element's behavior[1][1] includes "RT", set it's rotatable to "true" - if (elements[key].behavior[1][1].indexOf("RT") !== -1) { - elements[key].rotatable = true; - } - } // If the element's state is "gas", isGas = true @@ -3482,7 +3485,7 @@ color1 and color2 spread through striped paint like dye does with itself. col } // Set the first button in categoryControls div to be the current category document.getElementById("categoryControls").children[0].click() - document.getElementById("extraInfo").innerHTML += "
There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; + document.getElementById("extraInfo").insertAdjacentHTML("beforeend", "v" + currentversion + " • " + elementCount + " elements, with hidden.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"); selectElement(currentElement); focusGame(); }; @@ -5215,7 +5218,7 @@ color1 and color2 spread through striped paint like dye does with itself. col shapeModes = ["normal","circles","triangles"]; settings.shapeMode ??= 0; - settings.doAcid ??= false; + settings.doacid ??= false; settings.acidFunction ??= "none"; function getShapeMode() { @@ -5240,6 +5243,9 @@ color1 and color2 spread through striped paint like dye does with itself. col UL_UR_OPTIMIZED: behaviors.UL_UR_OPTIMIZED.toString() }; + settings ??= {}; + settings.shockoverlay ??= true; + //I hate overwriting drawPixels runAfterAutogen(function() { //rAA because velocity.js already puts its redef in a rAL and rAA comes after that @@ -5498,15 +5504,15 @@ color1 and color2 spread through striped paint like dye does with itself. col var mode = getShapeMode(); settings.acidFunction ??= "none"; var acidFunction; - if([false,"false"].includes(settings.doAcid)) { + if([false,"false"].includes(settings.doacid)) { acidFunction = acidFunctions.none } else { acidFunction = acidFunctions[settings.acidFunction ?? "none"] }; var acidOffset1,acidOffset2; - if(settings.doAcid && settings.acidFunction != "none" && !!acidFunction) { - acidOffset1 = (settings.doAcid ?? false) * (18*acidFunction((pixel.y+incrementt)/4.4)); - acidOffset2 = (settings.doAcid ?? false) * (18*acidFunction((pixel.x+incrementt)/4.4)) + if(settings.doacid && settings.acidFunction != "none" && !!acidFunction) { + acidOffset1 = (settings.doacid ?? false) * (18*acidFunction((pixel.y+incrementt)/4.4)); + acidOffset2 = (settings.doacid ?? false) * (18*acidFunction((pixel.x+incrementt)/4.4)) } else { acidOffset1 = 0; acidOffset2 = 0 @@ -5559,7 +5565,7 @@ color1 and color2 spread through striped paint like dye does with itself. col break; }; } - if (pixel.charge && view !== 2) { // Yellow glow on charge + if (pixel.charge && settings.shockoverlay && view !== 2) { // Yellow glow on charge if (!elements[pixel.element].colorOn) { ctx.fillStyle = "rgba(255,255,0,0.5)"; switch(mode) { @@ -5583,7 +5589,7 @@ color1 and color2 spread through striped paint like dye does with itself. col }; } } - if (pixel.burning && settings.burnOverlay && view !== 2) { // Red glow on burn + if (pixel.burning && settings.burnoverlay && view !== 2) { // Red glow on burn if (!elements[pixel.element].colorOn) { ctx.fillStyle = "rgba(255,0,0,0.5)"; switch(mode) { @@ -5695,36 +5701,13 @@ color1 and color2 spread through striped paint like dye does with itself. col shapeSettingSpan.appendChild(settingDropdown); settingsMenu.appendChild(shapeSettingSpan); - //Acid setting - var acidSettingSpan = document.createElement("span"); - acidSettingSpan.setAttribute("setting","doAcid"); - acidSettingSpan.setAttribute("class","setting-span"); - acidSettingSpan.textContent = "\"Acid\" distortion "; - var settingDropdown = document.createElement("select"); - settingDropdown.setAttribute("onchange","settings.doAcid = (this.value === 'true'); saveSettings();"); - var options = { - "false": "Disabled", - "true": "Enabled" - }; - for(value in options) { - var newOption = document.createElement("option"); - if(value == "0") { - newOption.setAttribute("selected",""); - }; - newOption.setAttribute("value",value); - newOption.innerText = options[value]; - settingDropdown.appendChild(newOption); - }; - acidSettingSpan.appendChild(settingDropdown); - settingsMenu.appendChild(acidSettingSpan); - //Acid function setting var acidFuncSpan = document.createElement("span"); acidFuncSpan.setAttribute("setting","acidFunction"); acidFuncSpan.setAttribute("class","setting-span"); acidFuncSpan.textContent = "\"Acid\" distortion function"; var settingDropdown = document.createElement("select"); - settingDropdown.setAttribute("onchange","settings.acidFunction = this.value; console.log(settings.acidFunction,this.value); saveSettings();"); + settingDropdown.setAttribute("onchange","settings.acidFunction = this.value; saveSettings();"); var options = { "none": "None", "sin": "Sine", @@ -5749,27 +5732,114 @@ color1 and color2 spread through striped paint like dye does with itself. col //console.log(lastSetting); lastSetting.setAttribute("style","padding-bottom:0"); //remove padding from last setting; + settings ??= {}; + settings.burnoverlay ??= false; var redBurnSettingSpan = document.createElement("span"); - redBurnSettingSpan.setAttribute("setting","burnOverlay"); - redBurnSettingSpan.setAttribute("class","setting-span"); - redBurnSettingSpan.textContent = "Red overlay on burning pixels "; - var settingDropdown = document.createElement("select"); - settingDropdown.setAttribute("onchange","settings.burnOverlay = (this.value === 'true'); saveSettings();"); + redBurnSettingSpan.setAttribute("setting","burnoverlay"); + redBurnSettingSpan.setAttribute("title","Default: OFF"); + redBurnSettingSpan.classList.add("setting-span","multisetting"); + var settingInput = document.createElement("input"); + settingInput.setAttribute("type","button"); + settingInput.setAttribute("value","Burning Overlay"); + settingInput.setAttribute("state","0"); + settingInput.classList.add("toggleInput"); + settingInput.setAttribute("onclick","toggleInput(this,'burnoverlay',false)"); var options = { "false": "Disabled", "true": "Enabled" }; - for(value in options) { - var newOption = document.createElement("option"); - if(value == "0") { - newOption.setAttribute("selected",""); - }; - newOption.setAttribute("value",value); - newOption.innerText = options[value]; - settingDropdown.appendChild(newOption); + var newHelpMark = document.createElement("span"); + newHelpMark.setAttribute("title","This adds a red overlay to burning pixels, like the yellow overlay for charged pixels."); + newHelpMark.classList.add("helpMark"); + newHelpMark.innerText = "?"; + redBurnSettingSpan.appendChild(settingInput); + redBurnSettingSpan.appendChild(newHelpMark); + var cheerfulSetting = document.querySelector('span[setting="cheerful"]'); + cheerfulSetting.after(redBurnSettingSpan); + + settings.shockoverlay ??= true; + var yellowShockSettingSpan = document.createElement("span"); + yellowShockSettingSpan.setAttribute("setting","shockoverlay"); + yellowShockSettingSpan.setAttribute("title","Default: ON"); + yellowShockSettingSpan.classList.add("setting-span","multisetting"); + var settingInput = document.createElement("input"); + settingInput.setAttribute("type","button"); + settingInput.setAttribute("value","Charge Overlay"); + settingInput.setAttribute("state","1"); + settingInput.classList.add("toggleInput"); + settingInput.setAttribute("onclick","toggleInput(this,'shockoverlay',false)"); + var options = { + "false": "Disabled", + "true": "Enabled" }; - redBurnSettingSpan.appendChild(settingDropdown); - settingsMenu.appendChild(redBurnSettingSpan); + var newHelpMark = document.createElement("span"); + newHelpMark.setAttribute("title","This adds a yellow overlay for charged pixels (vanilla feature)."); + newHelpMark.classList.add("helpMark"); + newHelpMark.innerText = "?"; + yellowShockSettingSpan.appendChild(settingInput); + yellowShockSettingSpan.appendChild(newHelpMark); + redBurnSettingSpan.after(yellowShockSettingSpan); + + settings.doacid ??= false; + var acidSettingSpan = document.createElement("span"); + acidSettingSpan.setAttribute("setting","doacid"); + acidSettingSpan.setAttribute("title","Default: OFF"); + acidSettingSpan.classList.add("setting-span","multisetting"); + var settingInput = document.createElement("input"); + settingInput.setAttribute("type","button"); + settingInput.setAttribute("value",'"Acid" distortion'); + settingInput.setAttribute("state","0"); + settingInput.classList.add("toggleInput"); + settingInput.setAttribute("onclick","toggleInput(this,'doacid',false)"); + var options = { + "false": "Disabled", + "true": "Enabled" + }; + var newHelpMark = document.createElement("span"); + newHelpMark.setAttribute("title","This adds a yellow overlay for charged pixels (vanilla feature)."); + newHelpMark.classList.add("helpMark"); + newHelpMark.innerText = "?"; + acidSettingSpan.appendChild(settingInput); + acidSettingSpan.appendChild(newHelpMark); + yellowShockSettingSpan.after(acidSettingSpan); + + var sizeSetting = document.querySelector('span[setting="pixelsize"]'); + var sizeDropdown = sizeSetting.querySelector("select"); + sizeDropdown.setAttribute("onchange","var size = (this.value === 'null' ? null : parseFloat(this.value)); console.log(size); if((size >= 0.05) && (size <= 194.73749999999999) && (size !== null) && (size !== false) && !(isNaN(size))) { console.log(size); setSetting('pixelsize',size);this.nextElementSibling.innerText='Reset Scene' }"); + var tinyOption = document.createElement("option"); + tinyOption.setAttribute("value","12"); + tinyOption.innerText = "Tiny"; + sizeDropdown.insertAdjacentElement("afterbegin",tinyOption); + var hugeOption = document.createElement("option"); + hugeOption.setAttribute("value","2"); + hugeOption.innerText = "Huge"; + sizeDropdown.insertAdjacentElement("beforeend",hugeOption); + var otherOption = document.createElement("option"); + otherOption.setAttribute("value","null"); + otherOption.innerText = "Other"; + sizeDropdown.insertAdjacentElement("beforeend",otherOption); + pixelSizeSettingDropdownOtherOptionIndex = (sizeDropdown.children.length) - 1; + + //Append code to showSettings to set every setting toggle button's state according to its setting's value on page load (so if you turned the setting on, the button is already green when you load the page) + function showSettingsButtonAutoUpdateAppendFunction() { + var toggleButtonSettings = document.querySelectorAll('span.setting-span.multisetting[setting]:has(input[type="button"])'); + if(!(toggleButtonSettings?.forEach)) { return false }; + toggleButtonSettings.forEach(function(node) { + var setting = node.getAttribute("setting"); + if(!setting) { return false }; + var button = node.querySelector('input[type="button"]'); + if(!button) { return false }; + var settingValue = !!(settings?.[setting]); + var newState = settingValue ? "1" : "0"; + button.setAttribute("state",newState); + return true + }) + }; + oldShowSettings = showSettings; + showSettings = function() { + oldShowSettings(); + showSettingsButtonAutoUpdateAppendFunction() + }; console.log(everyTick(function() { if(paused) { return }; @@ -5828,6 +5898,7 @@ color1 and color2 spread through striped paint like dye does with itself. col if (pixel.drag && !force) { return true; } var info = elements[pixel.element]; var oob = outOfBounds(nx,ny); + if(pixelMap[nx] === undefined) { return false }; //safety if (isEmpty(nx,ny,false,oob)) { // If coords is empty, move to coords //console.log(`Moving ${pixel.element} (${pixel.x},${pixel.y}) to (${nx},${ny})`); movePixel(pixel,nx,ny,leaveBehind); @@ -12624,22 +12695,18 @@ color1 and color2 spread through striped paint like dye does with itself. col pixelSize = urlParams.get('pixelSize') if(isNaN(pixelSize) || pixelSize === "" || pixelSize === null) { //NaN check //Vanilla code - //[Vanilla comment] If the screen size is under 768px, set pixelSize to 5, otherwise 6 + pixelSize = settings.pixelsize || 6; if (window.innerWidth < 700) { - pixelSize = 5; - } else { - pixelSize = 6; + pixelSize--; } } pixelSize = parseFloat(pixelSize) pixelSize = Math.min(194.73749999999999,Math.max(pixelSize,0.05)) } else { //Vanilla code - //[Vanilla comment] If the screen size is under 768px, set pixelSize to 5, otherwise 6 + pixelSize = settings.pixelsize || 6; if (window.innerWidth < 700) { - pixelSize = 5; - } else { - pixelSize = 6; + pixelSize--; } } @@ -13075,19 +13142,18 @@ Pixel size (rendering only): (Use if the save looks cut o function updateStats() { var statsDiv = document.getElementById("stats"); var stats = "x"+mousePos.x+",y"+mousePos.y+""; - stats += "Pxls:" + currentPixels.length+""; + stats += "Pxls:" + currentPixels.length+""; stats += "" + tps+"tps"; + if(enabledMods.includes("mods/betterStats.js") && typeof(realTps) !== "undefined") { stats += "" + realTps + "tps" }; //i'm sorry but there's no other way to add compatibility + //THAT CODE WAS MADE BY MOLLTHECODER FROM THEIR betterStats.js MOD stats += "" + pixelTicks+""; if ((typeof pixelMap).length === 9) { return; } if (pixelMap[mousePos.x] !== undefined) { var currentPixel = pixelMap[mousePos.x][mousePos.y]; if (typeof(currentPixel) !== "undefined" && currentPixel && currentPixel !== undefined && currentPixel.element) { - var displayName; - var displayElement = (elements[currentPixel?.element]?.name || currentPixel?.element); - if(currentPixel?.displayText) { - displayName = displayElement + ` (${currentPixel?.displayText})` - } else { - displayName = displayElement + var displayName = ((elements[currentPixel?.element]?.name || currentPixel?.element) ?? "undefined").toUpperCase(); + if(currentPixel?.displayText) { //old way that might have predated vanilla hoverText but now I'm not sure... kept for compatibility just in case + displayName += ` (${currentPixel?.displayText})` }; stats += "Elem:"+displayName+""; stats += "Temp:"+formatTemp(currentPixel.temp)+""; @@ -13097,6 +13163,15 @@ Pixel size (rendering only): (Use if the save looks cut o if (currentPixel.burning) { stats += "Burning"; } + if (elements[currentPixel.element].hoverStat) { + stats += ""+elements[currentPixel.element].hoverStat(currentPixel)+""; + } + else if (currentPixel.clone) { + stats += ""+currentPixel.clone.toUpperCase()+""; + } + else if (currentPixel.con && currentPixel.con.element) { + stats += ""+currentPixel.con.element.toUpperCase()+""; + } } } if (shiftDown) { @@ -28394,7 +28469,7 @@ ${eightSpaces}Example full decor definition: bird:0.04:10:#FF0000,#FFFF00,#00FF0 argPixelSize = parseFloat(argPixelSize); if(isNaN(argPixelSize)) { alert("Error: size was NaN"); - console.error("setpixelsize: supplied pixel size was NaN"); + console.error("pixelsize: supplied pixel size was NaN"); return false; }; }; @@ -28402,10 +28477,12 @@ ${eightSpaces}Example full decor definition: bird:0.04:10:#FF0000,#FFFF00,#00FF0 if(typeof(argPixelSize) === "number" && argPixelSize !== null && !isNaN(argPixelSize)) { if(argPixelSize <= 0) { alert("Pixel size must be greater than 0"); - console.error("setpixelsize: supplied pixel size was zero or negative"); + console.error("pixelsize: supplied pixel size was zero or negative"); return false; } else { - pixelSize = argPixelSize; + document.querySelector('span[setting="pixelsize"]').querySelector("select").selectedIndex = pixelSizeSettingDropdownOtherOptionIndex; + settings.pixelsize = argPixelSize; + resizeCanvas(ctx.canvas.height,ctx.canvas.width,settings.pixelsize,false) }; } else { alert(pixelSize); @@ -35996,6 +36073,12 @@ Make sure to save your command in a file if you want to add this preset again.` //AUTOGENERATED CONTENT ## + //Required secondary function + + function canvasfooterTemplate() { //CURSED AF + return `Changelog(NEW) • Feedback • Wiki • YouTube • Discordv${currentversion} • ${elementCount} elements, with hidden.
©2021-${new Date().getFullYear()}. All Rights Reserved. R74n
` + }; + //urlParams reads //Bombs @@ -37958,7 +38041,7 @@ Make sure to save your command in a file if you want to add this preset again.` elementCount++; //increment for new bomb element createElementButton(bombName); elements[bombName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; //update extra info counts (and the copyright year, due to the method used) + document.getElementById("extraInfo").innerHTML = canvasfooterTemplate() }; }; returns.push(bombName); @@ -38163,7 +38246,7 @@ Make sure to save your command in a file if you want to add this preset again.` elementCount++; //increment for new cloud element createElementButton(cloudName); elements[cloudName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; //update extra info counts (and the copyright year, due to the method used) + document.getElementById("extraInfo").innerHTML = canvasfooterTemplate() }; returns.push(cloudName); }; @@ -38390,7 +38473,7 @@ Make sure to save your command in a file if you want to add this preset again.` elements[bodyName].id = nextid++; //repeat with body and head elements[headName].id = nextid++; headBodyObject[headName] = bodyName; - document.getElementById("extraInfo").innerHTML = "There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; //update extra info counts (and the copyright year, due to the method used) + document.getElementById("extraInfo").innerHTML = canvasfooterTemplate() }; if(creeperIncludeRandom) { randomExcl ? elements[placerName].excludeRandom = true : elements[placerName].excludeRandom = false; @@ -38589,7 +38672,7 @@ Make sure to save your command in a file if you want to add this preset again.` createElementButton(fairyName); }; elements[fairyName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; //update extra info counts (and the copyright year, due to the method used) + document.getElementById("extraInfo").innerHTML = canvasfooterTemplate() }; }; returns.push(fairyName); @@ -38758,7 +38841,7 @@ Make sure to save your command in a file if you want to add this preset again.` createElementButton(spoutName); }; elements[spoutName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; //update extra info counts (and the copyright year, due to the method used) + document.getElementById("extraInfo").innerHTML = canvasfooterTemplate() }; eLists.SPOUT.push(spoutName); @@ -40142,7 +40225,7 @@ Make sure to save your command in a file if you want to add this preset again.` createElementButton(singularityName); }; elements[singularityName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.
©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n
"; //update extra info counts (and the copyright year, due to the method used) + document.getElementById("extraInfo").innerHTML = canvasfooterTemplate() }; }; count++; @@ -45948,128 +46031,135 @@ maxPixels (default 1000): Maximum amount of pixels/changes (if xSpacing and ySpa //SPECIFY CURRENT ELEMENT ON LOAD ## - window.addEventListener("load",function() { - currentElement = urlParams.get("currentElement") ?? "sand"; - if(!elementExists(currentElement)) { - currentElement = "sand" - } - var size = urlParams.get("mouseSize") ?? 5; - if(isNaN(size)) { - size = 5; - }; - mouseSize = size - }); + window.addEventListener("load",function() { + currentElement = urlParams.get("currentElement") ?? "sand"; + if(!elementExists(currentElement)) { + currentElement = "sand" + } + var size = urlParams.get("mouseSize") ?? 5; + if(isNaN(size)) { + size = 5; + }; + mouseSize = size + }); + + //FIX ## + + //fsr it's pausing silently on load now so this should fix that by silently unpausing it on load + window.addEventListener("load",function() { + paused = false + }); //MISCELLANEOUS CHANGES ## - eLists.PIPE = ['pipe', 'destroyable_pipe', 'e_pipe', 'destroyable_e_pipe', 'channel_pipe', 'destroyable_channel_pipe', 'bridge_pipe']; + eLists.PIPE = ['pipe', 'destroyable_pipe', 'e_pipe', 'destroyable_e_pipe', 'channel_pipe', 'destroyable_channel_pipe', 'bridge_pipe']; - elements.pipe_stage_shifter = { - tool: function(pixel) { - if(!(eLists.PIPE.includes(pixel.element))) { return false }; - if(typeof(pixel.stage) == "undefined" || !(pixel.stage) || pixel.stage < 2) { return false }; - switch (pixel.stage) { - case 2: pixel.stage = 3; break; - case 3: pixel.stage = 4; break; - case 4: pixel.stage = 2; break; - default: pixel.stage = (((Math.max(2,Math.floor(pixel.stage)) - 2) % 3) + 2); - }; - switch (pixel.stage) { - case 2: newColor = "#003600"; break; - case 3: newColor = "#360000"; break; - case 4: newColor = "#000036"; break; - }; - pixel.color = pixelColorPick(pixel,newColor); - }, - category: "tools", - color: ["#003600","#360000","#000036"], - density: elements.steel.density, - hardness: elements.steel.hardness, - tempHigh: elements.steel.tempHigh, - stateHigh: "molten_steel", - state: "solid", - behavior: behaviors.POWDER - }; - - var notActuallyMovable = ["pipe","e_pipe","steel","vivite"]; - - runAfterLoad(function() { - for(var i = 0; i < notActuallyMovable.length; i++) { - var name = notActuallyMovable[i]; - Object.defineProperty(elements[name], "movable", { - value: false, - writable: false //**** you, you're not changing it to true. - }); - } - }); - - elements.unknown = { - color: "#FFFFFF", - behavior: behaviors.WALL, - maxColorOffset: 0 - }; - - - runAfterLoad(function() { - //Emergency bug fix - elemfillerVar = null; - elements.element_filler = { - category: "special", - color: elements.filler.color, - state: "solid", - movable: "false", - onSelect: function() { - var answer6 = prompt("Please input the desired element of this filler. It will not work if you do multiple filter types while paused.",(elemfillerVar||undefined)); - if (!answer6) { return } - elemfillerVar = answer6; - }, - excludeRandom: true, - tick: function(pixel){ - if(!(elementExists(elemfillerVar))) { - deletePixel(pixel.x,pixel.y); - return + elements.pipe_stage_shifter = { + tool: function(pixel) { + if(!(eLists.PIPE.includes(pixel.element))) { return false }; + if(typeof(pixel.stage) == "undefined" || !(pixel.stage) || pixel.stage < 2) { return false }; + switch (pixel.stage) { + case 2: pixel.stage = 3; break; + case 3: pixel.stage = 4; break; + case 4: pixel.stage = 2; break; + default: pixel.stage = (((Math.max(2,Math.floor(pixel.stage)) - 2) % 3) + 2); }; - var neighbors = 0; - if(!pixel.changeElem){ - pixel.changeElem = elemfillerVar; - } - for (var i = 0; i < squareCoords.length; i++) { - var coord = squareCoords[i]; - var x = pixel.x+coord[0]; - var y = pixel.y+coord[1]; - if (!isEmpty(x,y, true)) { - neighbors = neighbors + 1; - } else if (isEmpty(x, y)){ - createPixel("element_filler", x, y) - pixelMap[x][y].changeElem = pixel.changeElem; - } else ( + switch (pixel.stage) { + case 2: newColor = "#003600"; break; + case 3: newColor = "#360000"; break; + case 4: newColor = "#000036"; break; + }; + pixel.color = pixelColorPick(pixel,newColor); + }, + category: "tools", + color: ["#003600","#360000","#000036"], + density: elements.steel.density, + hardness: elements.steel.hardness, + tempHigh: elements.steel.tempHigh, + stateHigh: "molten_steel", + state: "solid", + behavior: behaviors.POWDER + }; + + var notActuallyMovable = ["pipe","e_pipe","steel","vivite"]; + + runAfterLoad(function() { + for(var i = 0; i < notActuallyMovable.length; i++) { + var name = notActuallyMovable[i]; + Object.defineProperty(elements[name], "movable", { + value: false, + writable: false //**** you, you're not changing it to true. + }); + } + }); + + elements.unknown = { + color: "#FFFFFF", + behavior: behaviors.WALL, + maxColorOffset: 0 + }; + + + runAfterLoad(function() { + //Emergency bug fix + elemfillerVar = null; + elements.element_filler = { + category: "special", + color: elements.filler.color, + state: "solid", + movable: "false", + onSelect: function() { + var answer6 = prompt("Please input the desired element of this filler. It will not work if you do multiple filter types while paused.",(elemfillerVar||undefined)); + if (!answer6) { return } + elemfillerVar = answer6; + }, + excludeRandom: true, + tick: function(pixel){ + if(!(elementExists(elemfillerVar))) { + deletePixel(pixel.x,pixel.y); + return + }; + var neighbors = 0; + if(!pixel.changeElem){ + pixel.changeElem = elemfillerVar; + } + for (var i = 0; i < squareCoords.length; i++) { + var coord = squareCoords[i]; + var x = pixel.x+coord[0]; + var y = pixel.y+coord[1]; + if (!isEmpty(x,y, true)) { + neighbors = neighbors + 1; + } else if (isEmpty(x, y)){ + createPixel("element_filler", x, y) + pixelMap[x][y].changeElem = pixel.changeElem; + } else ( + changePixel(pixel, pixel.changeElem) + ) + } + if (neighbors >= 8){ changePixel(pixel, pixel.changeElem) - ) - } - if (neighbors >= 8){ - changePixel(pixel, pixel.changeElem) + } } } - } - - if(elementExists("ohio")) { - elements.ohio.excludeRandom = true - }; - if(elementExists("rainbow_bomb")) { - elements.rainbow_bomb.excludeRandom = true - }; - if(elementExists("fart")) { - elements.fart.excludeRandom = true - }; - if(elementExists("dark_energy")) { - elements.dark_energy.excludeRandom = true - }; - if(elementExists("rainbow_flash")) { - elements.rainbow_flash.excludeRandom = true; - delete elements.rainbow_flash.reactions.fire - }; - }) + if(elementExists("ohio")) { + elements.ohio.excludeRandom = true + }; + if(elementExists("rainbow_bomb")) { + elements.rainbow_bomb.excludeRandom = true + }; + if(elementExists("fart")) { + elements.fart.excludeRandom = true + }; + if(elementExists("dark_energy")) { + elements.dark_energy.excludeRandom = true + }; + if(elementExists("rainbow_flash")) { + elements.rainbow_flash.excludeRandom = true; + delete elements.rainbow_flash.reactions.fire + }; + }) + //END ## } catch (error) { alert(`Load failed (try reloading).\nThis is likely a sporadic failure caused by inconsistencies in how mods are loaded, and will likely fix itself in a refresh or two. If it persists, then it's an issue.\nError: ${error.stack}`);