From b47f718eebc9a4ec198aa61fdec51e03759c3f2a Mon Sep 17 00:00:00 2001 From: Ilikepizza2006 <146470829+Ilikepizza2006@users.noreply.github.com> Date: Sun, 11 Feb 2024 16:25:46 +0100 Subject: [PATCH 1/2] Update 1.9 --- mods/pizzasstuff.js | 172 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 158 insertions(+), 14 deletions(-) diff --git a/mods/pizzasstuff.js b/mods/pizzasstuff.js index 463e692b..7e4fb53b 100644 --- a/mods/pizzasstuff.js +++ b/mods/pizzasstuff.js @@ -1,3 +1,34 @@ +elements.freeze_ray = { + color: ["#9ae4f5","#84d6e8"], + tick: function(pixel) { + var x = pixel.x; + for (var y = pixel.y; y < height; y++) { + if (outOfBounds(x, y)) { + break; + } + if (isEmpty(x, y)) { + if (Math.random() > 0.05) { continue } + createPixel("flash", x, y); + pixelMap[x][y].color = "#aedbe6"; + pixelMap[x][y].temp = -257; + } + else { + if (elements[pixelMap[x][y].element].isGas) { continue } + if (elements[pixelMap[x][y].element].id === elements.heat_ray.id) { break } + pixelMap[x][y].temp -= 100; + pixelTempCheck(pixelMap[x][y]); + break; + } + } + deletePixel(pixel.x, pixel.y); + }, + temp: -257, + category: "energy", + state: "gas", + excludeRandom: true, + noMix: true +}; + elements.beer = { color: ["#ffc43d","#ffc43d"], behavior: behaviors.LIQUID, @@ -16,6 +47,9 @@ elements.root_beer = { elements.fruit_slushy = { color: ["#d43968","#ec5885","#f57ca1","#fba9c2","#ffe3eb"], + stateLowColorMultiplier: 1.3, + stateLow: "slushy_ice", + tempLow: "-50", behavior: behaviors.LIQUID, category: "food", state: "solid", @@ -32,6 +66,9 @@ elements.mold = { elements.chocolate_slushy = { color: ["#c3ae9a","#ae967f","#977b5f","#876b4f","#816346"], + stateLowColorMultiplier: 1.3, + tempLow: "-50", + stateLow: "slushy_ice", behavior: behaviors.LIQUID, category: "food", state: "solid", @@ -136,7 +173,7 @@ elements.fruit_yogurt = { elements.frozen_fruit_yogurt = { color: ["#ffdfdf","#ffc0c0","#ff9b9b"], - stateLowColorMultiplier: 0.7, + stateHighColorMultiplier: 0.7, behavior: behaviors.STURDYPOWDER, category: "food", state: "solid", @@ -149,7 +186,7 @@ elements.frozen_fruit_yogurt = { elements.frozen_chocolate_yogurt = { color: ["#a87848","#a57e57","#c1a07f","#e2c5ac","#efd0b1"], - stateLowColorMultiplier: 0.7, + stateHighColorMultiplier: 0.7, behavior: behaviors.STURDYPOWDER, category: "food", state: "solid", @@ -418,7 +455,7 @@ elements.moss = { }; elements.moth = { - color: "#665233", + color: ["#df8830","#e9b477","#a1591a","#a87a46","#4e3212"], behavior: behaviors.FLY, category: "life", state: "solid", @@ -661,7 +698,6 @@ elements.banana = { breakInto: "juice", breakIntoColor: "#f0f060", reactions: { - "steam": { elem1: "potassium", elem2: null }, "sugar": { elem1: "jelly", elem2: null, tempMin: 100, color1: ["#fdf8d6","#f9efa6"] }, } }; @@ -1074,14 +1110,6 @@ elements.eggplant = { breakIntoColor: ["#674ea7","#351c75"], }; -elements.potassium = { - color: "#a3a333", - behavior: behaviors.POWDER, - category: "states", - state: "solid", - breakInto: "juice", -}; - elements.onion = { color: ["#62121b","#a92940","#c04b65","#d8699e"], behavior: @@ -1282,7 +1310,7 @@ elements.legacy_rocket = { "XX|DL%1|XX", "CR:smoke|CR:fire|CR:smoke", ], - category: "special", + category: "legacy", hidden:true, state: "solid", temp:700, @@ -1292,6 +1320,84 @@ elements.legacy_rocket = { stateHigh: "molten_steel" }; +elements.legacy_dough = { + color: "#bfac91", + behavior: behaviors.STURDYPOWDER, + onMix: function(dough,ingredient) { + if (elements[ingredient.element].isFood && elements[ingredient.element].id !== elements.dough.id && elements[ingredient.element].id !== elements.flour.id && elements[ingredient.element].id !== elements.batter.id && elements[ingredient.element].id !== elements.bread.id) { + var rgb1 = dough.color.match(/\d+/g); + var rgb2 = ingredient.color.match(/\d+/g); + // average the colors + var rgb = [ + Math.round((parseInt(rgb1[0])+parseInt(rgb2[0]))/2), + Math.round((parseInt(rgb1[1])+parseInt(rgb2[1]))/2), + Math.round((parseInt(rgb1[2])+parseInt(rgb2[2]))/2) + ]; + changePixel(ingredient, "dough") + // convert rgb to hex + var hex = RGBToHex(rgb); + dough.color = pixelColorPick(dough, hex); + // 50% change to delete ingredient + if (Math.random() < 0.5) { deletePixel(ingredient.x, ingredient.y); } + else { + ingredient.color = pixelColorPick(ingredient, hex); + } + } + }, + reactions: { + "milk": { elem2:"broth", color2:"#ECC891", tempMin:70 }, + "cream": { elem2:"broth", color2:"#ECC891", tempMin:70 }, + }, + category: "legacy", + tempHigh: 94, + stateHigh: "bread", + //stateHighColorMultiplier: 0.9, + burn:40, + burnTime:25, + burnInto:"ash", + state: "solid", + density: 526.9, + isFood: true +}; + +elements.legacy_batter = { + color: "#d4bc85", + behavior: behaviors.LIQUID, + onMix: function(batter,ingredient) { + if (elements[ingredient.element].isFood && elements[ingredient.element].id !== elements.batter.id && elements[ingredient.element].id !== elements.flour.id && elements[ingredient.element].id !== elements.yolk.id && elements[ingredient.element].id !== elements.dough.id && elements[ingredient.element].id !== elements.baked_batter.id) { + var rgb1 = batter.color.match(/\d+/g); + var rgb2 = ingredient.color.match(/\d+/g); + // average the colors + var rgb = [ + Math.round((parseInt(rgb1[0])+parseInt(rgb2[0]))/2), + Math.round((parseInt(rgb1[1])+parseInt(rgb2[1]))/2), + Math.round((parseInt(rgb1[2])+parseInt(rgb2[2]))/2) + ]; + changePixel(ingredient, "batter") + // convert rgb to hex + var hex = RGBToHex(rgb); + batter.color = pixelColorPick(batter, hex); + // 50% change to delete ingredient + if (Math.random() < 0.5) { deletePixel(ingredient.x, ingredient.y); } + else { + ingredient.color = pixelColorPick(ingredient, hex); + } + } + }, + category: "legacy", + tempHigh: 94, + stateHigh: "baked_batter", + stateHighColorMultiplier: 0.9, + burn:40, + burnTime:25, + burnInto:"ash", + state: "liquid", + viscosity: 10000, + density: 1001, + hidden: true, + isFood: true +}; + elements.legacy_lattice = { color: "#cb4cd9", behavior: [ @@ -1300,7 +1406,7 @@ elements.legacy_lattice = { "CL|XX|CL", ], hidden: true, - category:"special", + category:"legacy", excludeRandom: true }; @@ -1352,6 +1458,37 @@ elements.left_lattice = { excludeRandom: true }; +elements.amethyst = { + color: ["#9868e0","#482888","#7848b8","#c898f0","#a878f0"], + behavior: behaviors.POWDER, + hidden: true, + category: "powders", +}; + +elements.quartz = { + color: ["#f6fff9","#f3f9f9","#f6fcf9","#fefefe","#fdfffe"], + behavior: behaviors.POWDER, + hidden: true, + category: "powders", + tempHigh: 1900, + stateHigh: "magma", + reactions: { + "molten_iron": { elem1: "amethyst", elem2: null }, + } +}; + +elements.slushy_ice = { + color: ["#f6fff9","#f3f9f9","#f6fcf9","#fefefe","#fdfffe"], + behavior: behaviors.WALL, + temp: -5, + tempHigh: 5, + stateHigh: "smashed_ice", + category: "states", + state: "solid", + density: 917, + breakInto: "smashed_ice", +}; + elements.toorhpaste = { color: ["#31ffe0","#65ffe8","#97ffef","#c9fff7","#f3fffd"], behavior: behaviors.LIQUID, @@ -1428,10 +1565,17 @@ elements.algae.breakInto = "seafoam" elements.battery.breakInto = "battery_acid" +elements.art.burn = 5 +elements.art.burnTime = 300 +elements.art.burnInto = ["ember","charcoal","fire"] + + elements.herb.breakInto = "seasoning" elements.chocolate.breakInto = "chocolate_sauce" +elements.magma.stateLow = ["basalt","basalt","basalt","basalt","basalt","basalt","basalt","rock","quartz"] + if (!elements.bless.reactions) elements.bless.reactions = {}; elements.bless.reactions.mold = { elem2: null } From 98d69c2d855959d7422c6405fcb97fc3e539dfae Mon Sep 17 00:00:00 2001 From: An Orbit <68935009+orbit-loona@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:04:27 -0500 Subject: [PATCH 2/2] even cursor sizes, electric gas lightning --- mods/a_mod_by_alice.js | 160 +++++++++++++++++++++++++++++++++++------ 1 file changed, 140 insertions(+), 20 deletions(-) diff --git a/mods/a_mod_by_alice.js b/mods/a_mod_by_alice.js index ddd46a35..804e1714 100644 --- a/mods/a_mod_by_alice.js +++ b/mods/a_mod_by_alice.js @@ -1163,10 +1163,11 @@ try { }; function convertHslObjects(color,outputType="rgb") { + if(color == null) { console.error("convertHslObjects: Color is null"); color = {h: 300, s: 100, l: 50} }; switch(outputType.toLowerCase()) { //RGB cases case "rgb": - color = hexToRGB(hslToHex(...Object.values(color))); //hsl to hex, hex to rgb_json, and rgb_json to rgb() + color = convertColorFormats(hslToHex(...Object.values(color)),"json"); //hsl to hex, hex to rgb_json, and rgb_json to rgb() return `rgb(${color.r},${color.g},${color.b})`; break; case "hex": @@ -1202,8 +1203,8 @@ try { break; default: throw new Error("outputType must be \"rgb\", \"hex\", \"rgb_json\", \"rgb_array\", \"hsl\", \"hsl_json\", or \"hsl_array\""); - }; - } + } + }; function changeSaturation(color,saturationChange,operationType="add",outputType="rgb",arrayType=null,doRounding=true) { color = normalizeColorToHslObject(color,arrayType); @@ -2094,13 +2095,15 @@ try { //fix -1-caused ghost pixels function deletePixel(x,y) { + if(isEmpty(x,y,true)) { return false }; // remove pixelMap[x][y] from currentPixels var pixelIndex = currentPixels.indexOf(pixelMap[x][y]); if(pixelIndex !== -1) { currentPixels.splice(pixelIndex,1) + if (pixelMap[x][y]) { delete pixelMap[x][y] }; }; - if (pixelMap[x][y]) {pixelMap[x][y].del = true} - if (pixelMap[x][y]) { delete pixelMap[x][y] }; + //if (pixelMap[x][y]) {pixelMap[x][y].del = true} + //if (pixelMap[x][y]) { delete pixelMap[x][y] }; /*for (var i = 0; i < currentPixels.length; i++) { if (currentPixels[i].x == x && currentPixels[i].y == y) { currentPixels.splice(i, 1); @@ -3217,6 +3220,32 @@ color1 and color2 spread through striped paint like dye does with itself. col } }; + //redefine mouseRange to support even sizes + function mouseRange(mouseX,mouseY,size) { + var coords = []; + size = size || mouseSize; + if (elements[currentElement].maxSize < mouseSize) { + var mouseOffset = Math.trunc(elements[currentElement].maxSize/2); + } + else { + var mouseOffset = Math.trunc(size/2); + } + var topLeft = [mouseX-mouseOffset,mouseY-mouseOffset]; + var bottomRight = [mouseX+mouseOffset,mouseY+mouseOffset]; + if(size % 2 == 0) { + bottomRight[0]--; + bottomRight[1]--; + }; + // Starting at the top left, go through each pixel + for (var x = topLeft[0]; x <= bottomRight[0]; x++) { + for (var y = topLeft[1]; y <= bottomRight[1]; y++) { + // If the pixel is empty, add it to coords + coords.push([x,y]); + } + } + return coords; + }; + //this part defines basically all of the keybinds function addKeyboardListeners() { document.addEventListener("keydown", function(e) { @@ -3259,16 +3288,26 @@ color1 and color2 spread through striped paint like dye does with itself. col } return; } + // If the user presses [ or -, decrease the mouse size by 2 if (e.keyCode == 219 || e.keyCode == 189) { - if (shiftDown) {mouseSize = 1} + //If a shift key is pressed, set to 1 + if (shiftDown && shiftDown % 2 == 1) {mouseSize = 1} + //If an alt key is pressed, decrease by 1 + else if (shiftDown && shiftDown % 2 == 0) { + mouseSize--; + if (mouseSize < 1) { mouseSize = 1 } + } else { mouseSize -= 2; - if (mouseSize < 1) { mouseSize = 1; } + if (mouseSize < 1) { mouseSize = 1 } } } // If the user presses ] or =, increase the mouse size by 2 if (e.keyCode == 221 || e.keyCode == 187) { - if (shiftDown) {mouseSize = (mouseSize+15)-((mouseSize+15) % 15)} + //If a shift key is pressed, increase by 15 + if (shiftDown && shiftDown % 2 == 1) {mouseSize = (mouseSize+15)-((mouseSize+15) % 15)} + //If an alt key is pressed, increase by 1 + else if (shiftDown && shiftDown % 2 == 0) {mouseSize++} else {mouseSize += 2;} // if height>width and mouseSize>height, set mouseSize to height, if width>height and mouseSize>width, set mouseSize to width if (mouseSize > (height > width ? height : width)) { mouseSize = (height > width ? height : width); } @@ -3607,6 +3646,11 @@ color1 and color2 spread through striped paint like dye does with itself. col velocityBlacklist = []; function explodeAtPlus(x,y,radius,firee="fire",smokee="smoke",beforeFunction=null,afterFunction=null,changeTemp=true) { + var message = "Explosion "; + var pixel = pixelMap[x]?.[y]; + if(pixel) { message += `of ${pixel.element} ` }; + message += `with radius ${radius} at (${x},${y})`; + // if fire contains , split it into an array if(firee !== null) { if (firee.indexOf(",") !== -1) { @@ -3730,6 +3774,15 @@ color1 and color2 spread through striped paint like dye does with itself. col }; oldExplodeAt = explodeAt; + /*explodeAt = function(x,y,radius,fire="fire") { + var message = "Explosion "; + var pixel = pixelMap[x]?.[y]; + if(pixel) { message += `of ${pixel.element} ` }; + message += `with radius ${radius} with "${fire}" at (${x},${y})`; + console.log(message); + + oldExplodeAt(x,y,radius,fire="fire") + };*/ explodeAt = explodeAtPlus; //MORE CONFIGURABLE REACTION TEMPERATURE CHANGES ## @@ -5029,11 +5082,10 @@ color1 and color2 spread through striped paint like dye does with itself. col if (pixel.charge && elementInfo.colorOn) { customColor = elementInfo.colorOn; } - if (customColor != null) { + if (customColor !== null) { if (Array.isArray(customColor)) { customColor = customColor[Math.floor(Math.random() * customColor.length)]; - } - if (customColor.startsWith("#")) { + } else if (customColor.startsWith?.("#")) { customColor = hexToRGB(customColor); } var rgb = customColor; @@ -5224,7 +5276,7 @@ color1 and color2 spread through striped paint like dye does with itself. col if (!settings["bg"]) {ctx.clearRect(0, 0, canvas.width, canvas.height)} else { if(settings["bg"] instanceof Array) { - settings.bgAngle ??= 0; + settings.bgAngle ??= 90; var angle = (settings.bgAngle) * Math.PI / 180; ctx.fillStyle = ctx.createLinearGradient( 0, @@ -5560,6 +5612,10 @@ color1 and color2 spread through striped paint like dye does with itself. col } var topLeft = [mousePos.x-mouseOffset,mousePos.y-mouseOffset]; var bottomRight = [mousePos.x+mouseOffset,mousePos.y+mouseOffset]; + if(mouseSize % 2 == 0) { + bottomRight[0]--; + bottomRight[1]--; + }; // Draw a square around the mouse ctx.strokeStyle = "white"; ctx.strokeRect(topLeft[0]*pixelSize,topLeft[1]*pixelSize,(bottomRight[0]-topLeft[0]+1)*pixelSize,(bottomRight[1]-topLeft[1]+1)*pixelSize); @@ -7930,7 +7986,7 @@ color1 and color2 spread through striped paint like dye does with itself. col } //1010 and 0101 if(pixel.dc1 && !pixel.dc2 && pixel.dc3 && !pixel.dc4) { - if(!pixel.changeTo) { + if(!pixel.changeTo) { //7989 yay soshi! if(ggg < 1/2) { pixel.changeTo = pixel.dc1 } else { @@ -8069,7 +8125,7 @@ color1 and color2 spread through striped paint like dye does with itself. col if(isEmpty(pixel.x+1,pixel.y-1) && isEmpty(pixel.x+1,pixel.y-2) && !outOfBounds(pixel.x+1,pixel.y-1) && !outOfBounds(pixel.x+1,pixel.y-2)) { tryMove(pixelMap[pixel.x][pixel.y-1],pixel.x+1,pixel.y-1) tryMove(pixelMap[pixel.x][pixel.y-2],pixel.x+1,pixel.y-2) - } //7989 yay soshi! + } } } else { if(isEmpty(pixel.x+1,pixel.y-1) && !outOfBounds(pixel.x+1,pixel.y-1)) { @@ -17191,9 +17247,9 @@ Pixel size (rendering only): (Use if the save looks cut o elements.electric_gas = { color: ["#3693b3", "#246e64"], behavior: [ - "M2%33.3 AND CR:electric%1|M1%33.3 AND CR:electric%1|M2%33.3 AND CR:electric%1", - "M1%33.3 AND CR:electric%1|XX%0000000000000000000000|M1%33.3 AND CR:electric%1", - "M2%33.3 AND CR:electric%1|M1%33.3 AND CR:electric%1|M2%33.3 AND CR:electric%1", + "M2%33.3 AND CR:electric%1 AND CR:lightning%0.005|M1%33.3 AND CR:electric%1 AND CR:lightning%0.005|M2%33.3 AND CR:electric%1 AND CR:lightning%0.005", + "M1%33.3 AND CR:electric%1 AND CR:lightning%0.005|XX%000000000000000000000000000000000000000000000|M1%33.3 AND CR:electric%1 AND CR:lightning%0.005", + "M2%33.3 AND CR:electric%1 AND CR:lightning%0.005|M1%33.3 AND CR:electric%1 AND CR:lightning%0.005|M2%33.3 AND CR:electric%1 AND CR:lightning%0.005", ], hardness: 0.8, reactions: { @@ -17202,7 +17258,7 @@ Pixel size (rendering only): (Use if the save looks cut o }, category: "gases", density: 1.225, - state: "gas", + state: "gas" }; corrosiveGasMaxHardness = 0.6 @@ -19256,9 +19312,10 @@ Pixel size (rendering only): (Use if the save looks cut o */ function heejinitoidTick(pixel) { + pixel.color ??= pixelColorPick(pixel); if(pixel.oldColor === null) { pixel.oldColor = pixel.color }; if(pixel.oldColor === undefined) { pixel.oldColor = pixelColorPick(pixel) }; - var color = rgbStringToHSL(convertColorFormats(pixel.oldColor,"rgb"),"json"); + var color = rgbStringToHSL((convertColorFormats(pixel.oldColor,"rgb") ?? pixelColorPick(pixel)),"json"); var heejiniteHueSpread = 30 + (pixel.temp/9.25) var hueOffset = (Math.sin(pixelTicks / 11) * heejiniteHueSpread) + 15; color.h += hueOffset; var color = convertHslObjects(color,"rgb"); @@ -26448,6 +26505,8 @@ Pixel size (rendering only): (Use if the save looks cut o elements.molten_copper ??= {}; elements.molten_copper.tempHigh = 4700; elements.molten_alumina ??= {}; elements.molten_alumina.tempHigh = 5400; + elements.molten_alumina.state = "liquid"; + elements.molten_alumina.autoType = "gas"; elements.molten_alumina.reactions ??= {}; elements.molten_alumina.reactions.iron_scrap = {elem1: "molten_sapphire", elem2: ["molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron",null] }; elements.molten_alumina.reactions.molten_iron = {elem1: "molten_sapphire", elem2: ["molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron","molten_iron",null] }; @@ -35842,7 +35901,7 @@ Make sure to save your command in a file if you want to add this preset again.` }; elements.sponge.onTryMoveInto = function(pixel,otherPixel) { - var absorbedElements = Object.keys(pixel.absorbed); + var absorbedElements = Object.keys(pixel.absorbed ?? {}); if(absorbedElements.length == 0) { return false; }; @@ -45937,6 +45996,67 @@ maxPixels (default 1000): Maximum amount of pixels/changes (if xSpacing and ySpa 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(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}`);