diff --git a/mods/LimesAdditions.js b/mods/LimesAdditions.js index dee1132a..73ffc5e8 100644 --- a/mods/LimesAdditions.js +++ b/mods/LimesAdditions.js @@ -1,3 +1,23 @@ +function sendAlert() { + alert("This mod can be weird with TPS. It won't crash, but not everything will work perfectly. Thank you for your understanding. :)") +} +sendAlert() +function coolArea(centerPixel, radius = 3, amount = 10) { + for (let dx = -radius; dx <= radius; dx++) { + for (let dy = -radius; dy <= radius; dy++) { + let x = centerPixel.x + dx; + let y = centerPixel.y + dy; + let target = pixelMap[x]?.[y]; + + if (target && typeof target.temp === "number") { + target.temp -= amount; + pixelTempCheck(target); // ensures proper state update + } + } + } +} + + elements.EXPLODE = { color: "#FF5555", behavior: [ @@ -95,30 +115,162 @@ elements.right_powder = { } elements.volcano = { - color: "#4f4848", + color: "#2e2e2e", category: "weapons", + cooldown: defaultCooldown, + maxSize: 1, + temp: 0, + //insulate: true, tick: function(pixel) { - let isPlaced = false - if (!tryMove(pixel,pixel.x,pixel.y+1)) { - if (!pixel.isPlaced) { - pixel.y -= 5 + if (!pixelMap[pixel.x]?.[pixel.y]) {return} + + if (!pixel.isPlaced) { + if (!tryMove(pixel,pixel.x,pixel.y+1)) { + movePixel(pixel, pixel.x, pixel.y - 5) pixel.isPlaced = true } - let height = 5; // number of pyramid layers - while (!isEmpty(pixel.x-4,pixel.y+4)) { - for (let row = 2; row < height; row++) { - let width = row + 2; // pyramid gets wider each row - for (let col = 0; col < width; col++) { - let xOffset = col - row; // center the row - let x = pixel.x + xOffset; - let y = pixel.y + row; - - createPixel("basalt", x, y); - - } - } } - } } + if (!pixel.hasRun && pixel.isPlaced) { + createPixel("basalt", pixel.x, pixel.y+4) + createPixel("basalt", pixel.x, pixel.y+3) + createPixel("basalt", pixel.x, pixel.y+2) + createPixel("basalt", pixel.x-1, pixel.y+1) + createPixel("basalt", pixel.x, pixel.y+1) + createPixel("basalt", pixel.x+1, pixel.y+1) + createPixel("basalt", pixel.x+1, pixel.y+2) + createPixel("basalt", pixel.x-1, pixel.y+2) + createPixel("basalt", pixel.x-2, pixel.y+2) + createPixel("basalt", pixel.x+2, pixel.y+2) + createPixel("basalt", pixel.x, pixel.y+2) + createPixel("basalt", pixel.x, pixel.y+3) + createPixel("basalt", pixel.x+1, pixel.y+3) + createPixel("basalt", pixel.x+2, pixel.y+3) + createPixel("basalt", pixel.x+3, pixel.y+3) + createPixel("basalt", pixel.x-1, pixel.y+3) + createPixel("basalt", pixel.x-2, pixel.y+3) + createPixel("basalt", pixel.x-3, pixel.y+3) + createPixel("basalt", pixel.x, pixel.y+4) + createPixel("basalt", pixel.x+1, pixel.y+4) + createPixel("basalt", pixel.x+2, pixel.y+4) + createPixel("basalt", pixel.x+3, pixel.y+4) + createPixel("basalt", pixel.x+4, pixel.y+4) + createPixel("basalt", pixel.x-1, pixel.y+4) + createPixel("basalt", pixel.x-2, pixel.y+4) + createPixel("basalt", pixel.x-3, pixel.y+4) + createPixel("basalt", pixel.x-4, pixel.y+4) + createPixel("basalt", pixel.x, pixel.y+5) + createPixel("basalt", pixel.x+1, pixel.y+5) + createPixel("basalt", pixel.x+2, pixel.y+5) + createPixel("basalt", pixel.x+3, pixel.y+5) + createPixel("basalt", pixel.x+4, pixel.y+5) + createPixel("basalt", pixel.x+5, pixel.y+5) + createPixel("basalt", pixel.x-1, pixel.y+5) + createPixel("basalt", pixel.x-2, pixel.y+5) + createPixel("basalt", pixel.x-3, pixel.y+5) + createPixel("basalt", pixel.x-4, pixel.y+5) + createPixel("basalt", pixel.x-5, pixel.y+5) + pixel.hasRun = true + } + if (pixel.hasRun && pixel.isPlaced) { + let left = pixelMap[pixel.x - 1]?.[pixel.y]; + let right = pixelMap[pixel.x + 1]?.[pixel.y]; + if ( + (left?.element === "basalt" || left?.element === "rock") && + (right?.element === "basalt" || right?.element === "rock") + ){ + if (typeof pixel.height !== "number") { + pixel.height = 0 + } + let oldY = pixel.y; + deletePixel(pixel.x, oldY - 1); + movePixel(pixel, pixel.x, oldY - 1); + createPixel("basalt", pixel.x, oldY + 1); + pixel.height ++ + + + } + if (pixel.height >= 7) { + deletePixel(pixel.x, pixel.y) + let select = pixelMap[pixel.x]?.[pixel.y+5] + coolArea(pixel, 20, 150) + /*if (select) { + select.temp = -273 + pixelTempCheck(select) + togglePause(); + console.log("x: "+pixel.x+" y: "+(pixel.y+5)) + } + return + */ + } + let target = pixelMap[pixel.x]?.[pixel.y] + if (typeof pixel.cool !== "number") { + pixel.cool = 0 + } + pixel.cool += 0.25 + //console.log(Math.round(pixel.cool)) + if (target && Number.isInteger(pixel.cool)) { + target.temp -= Math.round(pixel.cool) + } + /*let target2 = pixelMap[pixel.x-2]?.[pixel.y+3] + if (target2) { + target2.temp -= 40 + } + let target3 = pixelMap[pixel.x+2]?.[pixel.y+3] + if (target3) { + target3.temp -= 40 + } + let target4 = pixelMap[pixel.x-1]?.[pixel.y] + if (target4) { + target4.temp -= 40 + } + let target5 = pixelMap[pixel.x+1]?.[pixel.y] + if (target5) { + target5.temp -= 40 + } + */ + pixel.spread = 1 + if (!pixelMap[pixel.x]?.[pixel.y-1]) { + createPixel("magma", pixel.x, pixel.y-1) + + } + if (!pixelMap[pixel.x-(pixel.spread*-1)]?.[pixel.y-1]) { + createPixel("magma", pixel.x-(pixel.spread*-1), pixel.y-1) + + } + if (!pixelMap[pixel.x+(pixel.spread*1)]?.[pixel.y-1]) { + createPixel("magma", pixel.x+(pixel.spread*1), pixel.y-1) + + } + if (!pixelMap[pixel.x-(pixel.spread*-1)]?.[pixel.y-2]) { + createPixel("magma", pixel.x+(pixel.spread*1), pixel.y-2) + + } + if (!pixelMap[pixel.x+(pixel.spread*1)]?.[pixel.y-2]) { + createPixel("magma", pixel.x+(pixel.spread*1), pixel.y-2) + + } + if (!pixelMap[pixel.x]?.[pixel.y-2]) { + createPixel("magma", pixel.x, pixel.y-2) + + } + if (!pixelMap[pixel.x]?.[pixel.y-3]) { + createPixel("magma", pixel.x, pixel.y-3) + + } + if (!pixelMap[pixel.x-(pixel.spread*-1)]?.[pixel.y-3]) { + createPixel("magma", pixel.x-(pixel.spread*-1), pixel.y-3) + + } + if (!pixelMap[pixel.x+(pixel.spread*1)]?.[pixel.y-3]) { + createPixel("magma", pixel.x+(pixel.spread*1), pixel.y-3) + + } + pixel.spread++ + } + + } + + } elements.cat = { @@ -143,11 +295,14 @@ elements.cat = { if (!tryMove(pixel, pixel.x + lr + lr, pixel.y)) { if (!tryMove(pixel, pixel.x + lr, pixel.y - 1)) { if (!tryMove(pixel, pixel.x + lr, pixel.y + 1)) { - lr = 1 + } } } } + if (!tryMove(pixel, pixel.x + lr, pixel.y - 1)) { + lr = 1 + } @@ -157,10 +312,14 @@ elements.cat = { if (!tryMove(pixel, pixel.x + lr + lr, pixel.y)) { if (!tryMove(pixel, pixel.x + lr, pixel.y - 1)) { if (!tryMove(pixel, pixel.x + lr, pixel.y + 1)) { - lr = -1 + } } } + + } + if (!tryMove(pixel, pixel.x + lr, pixel.y - 1)) { + lr = -1 } } } @@ -229,7 +388,9 @@ elements.hairball = { ], tempHigh: 250, stateHigh: "ash", - hidden: true + hidden: true, + burn: 50, + burnTime: 600, } elements.hot_stuff = { diff --git a/mods/copypaste.js b/mods/copypaste.js index 1bfa9101..7db69ef1 100644 --- a/mods/copypaste.js +++ b/mods/copypaste.js @@ -10,7 +10,7 @@ function pluckMatrix(x, y, w, h) { for (var i = 0; i < w; i++) { var px = pixelMap[x + i]?.[y + j]; if (px) { - row.push({ element: px.element, temp: px.temp, color: px.color }); + row.push({ element: px.element, temp: px.temp, color: px.color, clone: px?.clone }); } else { row.push("#"); } @@ -72,9 +72,11 @@ document.addEventListener("mousedown", (event) => { if (cell !== "#" && cell.element) { var px = createPixel(cell.element, x + i - (size-1)/2, y + j - (size-1)/2); - if (px) { - if (typeof cell.temp === "number") px.temp = cell.temp; - if (typeof cell.color === "string") px.color = cell.color; + var px2 = pixelMap[x + i - (size-1)/2][y + j - (size-1)/2]; + if (px2) { + px2.temp = cell.temp; + px2.clone = cell.clone; + px2.color = cell.color; } } } diff --git a/mods/cubesstuff.js b/mods/cubesstuff.js index 0421591c..772dacbf 100644 --- a/mods/cubesstuff.js +++ b/mods/cubesstuff.js @@ -1,10 +1,10 @@ -//broken rn dont know how to fix it yet -/* elements.button = { color: "#970000", conduct: 1, charge: 0, category: "machines", + behavior: behaviors.WALL, + state: "solid", onSelect: function () { logMessage("Click the button with no elements equipped to charge the button.") }, @@ -27,7 +27,12 @@ elements.button = { } } } -*/ + + +function isPressable(pixel) { + if (elements[pixel.element].pressInto !== undefined) return true; +} + elements.aerogel = { color: "#79ffff", category: "solids", @@ -150,12 +155,457 @@ elements.fire_extinguisher_powder = { } } }, - tool: function(pixel) { - if(pixel.burning === true){ + tool: function (pixel) { + if (pixel.burning === true) { delete pixel.burning; delete pixel.burnStart; } }, canPlace: true, category: "powders" -} \ No newline at end of file +} + +elements.pie_crust = { + color: "#f1f192", + breakInto: "crumb", + tempHigh: 500, + stateHigh: "ash", + burn: 5, + burnTime: 400, + burnInto: ["smoke", "smoke", "smoke", "ash"], + category: "food", + state: "solid", + behavior: behaviors.STURDYPOWDER, + isFood: true, + hidden: true, + density: 230, + reactions: { + "pumpkin": { elem1: "pie", elem2: null, tempMin: 200 }, + "cooked_meat": { elem1: "pie", elem2: null, tempMin: 200 }, + "meat": { elem1: "pie", elem2: null, tempMin: 200 }, + "potato": { elem1: "pie", elem2: null, tempMin: 200 }, + "mashed_potato": { elem1: "pie", elem2: null, tempMin: 200 }, + "baked_potato": { elem1: "pie", elem2: null, tempMin: 200 }, + "grape": { elem1: "pie", elem2: null, tempMin: 200 } + } +} + +elements.pie = { + color: "#fac145", + darkText: false, + behavior: behaviors.STURDYPOWDER, + category: "food", + isFood: true, + density: 240, + burn: 5, + burnTime: 400, + burnInto: ["smoke", "smoke", "smoke", "ash"], + state: "solid", + tempHigh: 500, + stateHigh: "ash", + breakInto: "sauce", + breakIntoColor: ["#ff822e", "#ff8c2e"] +} + +elements.gasoline = { + color: ["#ffff66", "#ffff55", "#ffff44"], + behavior: behaviors.LIQUID, + burn: 80, + burnTime: 100, + burnInto: ["fire", "fire", "fire", "explosion"], + viscosity: 0.7, + density: 750, + category: "liquids", + state: "liquid", + conduct: 0.02, + behaviorOn: [ + "XX|XX|XX", + "XX|EX:10|XX", + "XX|XX|XX" + ] +} + +// Make molten sulfur stinky +elements.molten_sulfur.tick = function (pixel) { + for (var i = 0; i < adjacentCoords.length; i++) { + var coords = adjacentCoords[i]; + var x = pixel.x + coords[0]; + var y = pixel.y + coords[1]; + if (isEmpty(x, y) && Math.random() <= 0.0005) { + createPixel("stench", x, y) + p = getPixel(x, y) + if (p !== null && p.element == "stench") { + p.temp = pixel.temp + } + } + } +} + +elements.disco_floor = { + color: ["#ff0000", "#ff8800", "#ffff00", "#00ff00", "#00ffff", "#0000ff", "#ff00ff"], + breakInto: "glass_shard", + category: "machines", + forceSaveColor: true, + conduct: 1, + behavior: behaviors.WALL, + tick: function (pixel) { + pixel.changeCd ??= 20; + pixel.changeCd--; + + if (pixel.changeCd <= 0) { + let colors = elements.disco_floor.color; + pixel.color = colors[Math.floor(Math.random() * colors.length)]; + pixel.changeCd = 20; + } + } +}; + +elements.moss = { + color: ["#007900", "#006000", "#008300"], + behavior: behaviors.POWDER, + tick: function (pixel) { + for (var i = 0; i < squareCoords.length; i++) { + var coords = squareCoords[i]; + var x = pixel.x + coords[0]; + var y = pixel.y + coords[1]; + if (isEmpty(x, y) && Math.random() <= 0.01 && getPixel(pixel.x, pixel.y + 1) && getPixel(pixel.x, pixel.y + 1).element !== "moss") { + createPixel('moss', x, y) + } + } + }, + tempHigh: 70, + stateHigh: "dead_plant", + extraTempHigh: { + "100": ["dead_plant", "dead_plant", "steam"] + }, + tempLow: -10, + stateLow: "frozen_plant", + burn: 50, + burnTime: 30, + reactions: { + "carbon_dioxide": { elem2: "oxygen", chance: 0.1 }, + "rock": { elem2: "dirt", chance: 0.0025 }, + "rock_wall": { elem2: "dirt", chance: 0.0025 }, + "gravel": { elem2: "dirt", chance: 0.0025 }, + }, + category: "life" +} + +elements.magma.extraTempLow = { "700": "obsidian" } + +elements.obsidian = { + color: ["#1f1f1f", "#1f1f1f", "#1f1f1f", "#1f1f1f", "#292929"], + buttonColor: ["#1a1a1a", "#2b2b2b", "#3b3b3b"], + colorPattern: textures.GLASS, + colorKey: { + "g": "#1f1f1f", + "s": "#292929", + "S": "#252525" + }, + grain: 0, + behavior: behaviors.WALL, + category: "solids", + tempHigh: 1200, + stateHigh: "magma", + state: "solid", + density: 2500, + breakInto: "obsidian_shard" +} + +elements.obsidian_shard = { + color: ["#1f1f1f", "#1f1f1f", "#1f1f1f", "#1f1f1f", "#292929"], + behavior: behaviors.POWDER, + grain: 0, + category: "powders", + tempHigh: 1200, + stateHigh: "magma", + state: "solid", + density: 2500, +} + +elements.cardboard = { + color: ["#9E6B34"], + burn: 70, + burnTime: 300, + burnInto: ["fire", "fire", "fire", "fire", "fire", "ash"], + behavior: behaviors.WALL, + reactions: { + "water": { elem1: "cellulose", elem2: null }, + "dirty_water": { elem1: "cellulose", elem2: null }, + "salt_water": { elem1: "cellulose", elem2: null }, + "sugar_water": { elem1: "cellulose", elem2: null }, + "seltzer": { elem1: "cellulose", elem2: null }, + "soda": { elem1: "cellulose", elem2: null }, + "blood": { elem1: "cellulose", elem2: null }, + "foam": { elem1: "cellulose", elem2: null }, + "bubble": { elem1: "cellulose", elem2: null }, + "oil": { elem1: "cellulose", elem2: null }, + "alcohol": { elem1: "cellulose", elem2: null }, + "vinegar": { elem1: "cellulose", elem2: null } + }, + category: "solids", + tempHigh: 248, + stateHigh: ["fire", "fire", "fire", "fire", "fire", "ash"], + state: "solid", + density: 1200 +} + +elements.paper.pressInto = "cardboard" + +elements.press = { + color: ["#999999", "#c0c0c0", "#999999"], + category: "tools", + tool: function (pixel) { + // edited smash code + if (isPressable(pixel)) { + if (elements[pixel.element].pressInto === undefined) { return; } + // if it is an array, choose a random item, else just use the value + let result; + if (elements[pixel.element].pressInto !== undefined) { + if (Array.isArray(elements[pixel.element].pressInto)) { + result = elements[pixel.element].pressInto[Math.floor(Math.random() * elements[pixel.element].pressInto.length)]; + } + else { + result = elements[pixel.element].pressInto; + } + } + // change the pixel to the result + if (result === null) { + deletePixel(pixel.x, pixel.y); + return; + } + + else if (result !== undefined) { + changePixel(pixel, result); + } + } + } +} + +elements.malware.reactions.wire = { elem2: [null, "faulty_wire"], chance: 0.01 }; + +elements.faulty_wire = { + color: ["#4d0a03", "#4d0a03", "#4d0a03", "#4d0a03", "#4d0a03", "#4d0a03", "#4d0a03", "#4d0a03", "#4d0a03", "#a95232",], + buttonColor: "#4d0a03", + behavior: behaviors.WALL, + behaviorOn: [ + "XX|CR:electric,flash%1|XX", + "CR:electric,flash%1|XX|CR:electric,flash%1", + "XX|CR:electric,flash%1|XX" + ], + category: "machines", + insulate: true, + conduct: 0.7, + noMix: true, +} + +elements.lighter_fluid = { + color: "#f1e185", + behavior: [ + "XX|XX|XX", + "M2 AND SW:lighter_fluid_gas|XX|M2 AND SW:lighter_fluid_gas", + "M1 AND SW:lighter_fluid_gas|M1 AND SW:lighter_fluid_gas|M1 AND SW:lighter_fluid_gas" + ], + category: "liquids", + state: "liquid", + density: 750, + tick: function (pixel) { + pixel.gasMade ??= 0 + for (var i = 0; i < squareCoordsShuffle.length; i++) { + var coord = squareCoordsShuffle[i]; + var x = pixel.x + coord[0]; + var y = pixel.y + coord[1]; + if (isEmpty(x, y)) { + createPixel("lighter_fluid_gas", x, y) + pixel.gasMade += 1 + } + } + + if (pixel.gasMade > 100 && Math.random() <= 0.01) { + deletePixel(pixel.x, pixel.y) + } + } +} + +elements.lighter_fluid_gas = { + color: "#f1e185", + alpha: 0.1, + behavior: behaviors.GAS, + category: "gases", + state: "gas", + burn: 100, + isGas: true, + hidden: true, + density: 20, + tick: function (pixel) { + if (Math.random() <= 0.25) { + deletePixel(pixel.x, pixel.y) + } + } +} + +elements.mold = { + color: "#054e05", + category: "life", + behavior: behaviors.POWDER, + state: "solid", + burn: 70, + burnTime: 100, + tempHigh: 200, + stateHigh: "fire", + tempLow: -10, + stateLow: "frozen_plant", + reactions: { + "meat": { elem1: "rotten_meat", elem2: "rotten_meat" }, + "cheese": { elem1: "rotten_cheese", elem2: "rotten_cheese" } + }, + tick: function (pixel) { + let moldable = ["meat", "cheese", "rotten_meat", "rotten_cheese"] + for (var i = 0; i < squareCoords.length; i++) { + var coords = squareCoords[i]; + var x = pixel.x + coords[0]; + var y = pixel.y + coords[1]; + if (isEmpty(x, y) && Math.random() <= 0.01 && getPixel(pixel.x, pixel.y + 1) && moldable.includes(getPixel(pixel.x, pixel.y + 1).element)) { + createPixel('mold', x, y) + } + } + } +} + +elements.glow_stick = { + color: ["#00ff00", "#ea00ff", "#00eeff"], + glow: true, + behavior: behaviors.POWDER, + breakInto: "glow_stick_liquid", + category: "powders" +} + +elements.glow_stick_liquid = { + color: ["#00ff00", "#ea00ff", "#00eeff"], + glow: true, + behavior: behaviors.LIQUID, + breakInto: "glow_stick_liquid", + category: "liquids" +} + + +// Add TPS keybind +keybinds["KeyT"] = function () { + tpsPrompt() +} + +function addRow() { + const table = document.getElementById("controlsTable"); + const rowCount = table.rows.length; + + const newRow = table.insertRow(rowCount - 1); + + const cell1 = newRow.insertCell(0); + const cell2 = newRow.insertCell(1); + + cell1.textContent = "Change TPS"; + cell2.innerHTML = "T"; +} + +addRow() + +elements.randomizer = { + buttonColor: ["#ff0000", "#ff8800", "#ffff00", "#00ff00", "#00ffff", "#0000ff", "#ff00ff"], + excludeRandom: true, + onSelect: function () { + logMessage("Warning: It can fill up the screen with random elements") + }, + tick: function (pixel) { + pixel.color = randomColor() + for (var i = 0; i < adjacentCoords.length; i++) { + var coords = adjacentCoords[i]; + var x = pixel.x + coords[0]; + var y = pixel.y + coords[1]; + let p = getPixel(x, y) + if (!isEmpty(x, y) && !outOfBounds(x, y)) { + if (p.element !== "randomizer") { + changePixel(p, "random") + } + } + } + }, + behavior: behaviors.WALL, + insulate: true, + hardness: 1, + category: "special" +} + +elements.cloner.ignore.push("randomizer") +elements.ecloner.ignore.push("randomizer") +elements.floating_cloner.ignore.push("randomizer") +elements.slow_cloner.ignore.push("randomizer") +elements.rocket.ignore.push("randomizer") + +elements.antibomb.tick = function (pixel) { + doDefaults(pixel) + if (!tryMove(pixel, pixel.x, pixel.y + 1)) { + if (!outOfBounds(pixel.x, pixel.y + 1)) { + var elem = pixelMap[pixel.x][pixel.y + 1].element; + if (elements[elem].isGas) { return } + } + else { + var elem = "smoke"; + } + if (elem !== "antibomb" && elem !== "randomizer") { + explodeAt(pixel.x, pixel.y, 8, elem) + } + } +} + +function drawCircle(x0, y0, radius, element) { + for (let y = -radius; y <= radius; y++) { + for (let x = -radius; x <= radius; x++) { + if (x * x + y * y <= radius * radius) { + let px = x0 + x; + let py = y0 + y; + if (isEmpty(px, py)) { + createPixel(element, px, py); + } + } + } + } +} + + +let circleRad = 7; +let circleElem = "wood"; + +elements.circle = { + color: "#FF0000", + behavior: behaviors.WALL, + category: "special", + onSelect: function() { + let ans1 = Number(prompt("Select the radius you want your circle to be:")); + let ans2 = prompt("Now give the element your circle should be made of:"); + + // Validate radius + if (Number.isInteger(ans1) && ans1 > 0) { + circleRad = ans1; + } else { + logMessage("Invalid radius, using default/last size: " + circleRad); + } + + // Validate element + let similar = mostSimilarElement(ans2); + if (similar && elements[similar]) { + circleElem = similar; + } else { + logMessage("Invalid element, using default/last element: " + circleElem); + } + }, + onPlace: function(pixel) { + drawCircle(pixel.x, pixel.y, circleRad, circleElem); + changePixel(pixel, circleElem); + }, + maxSize: 1 +}; + +runAfterReset(function() { + circleRad = 7; + circleElem = "wood"; +}) diff --git a/mods/fans.js b/mods/fans.js index a3bf07ad..b7622f9f 100644 --- a/mods/fans.js +++ b/mods/fans.js @@ -81,19 +81,12 @@ runAfterAutogen(function () { return movesSelf; }).map(([name]) => name); - console.log("🚶 Self-Moving Elements:", movableElements); window.movableElementsByBehavior = movableElements; }); - - -runAfterAutogen(function () { - console.log(behaviors) -}) - // Create a global map to track delay for each position if (!window.fanPushDelays) { window.fanPushDelays = new Map(); diff --git a/mods/mush_infection.js b/mods/mush_infection.js new file mode 100644 index 00000000..b44f6619 --- /dev/null +++ b/mods/mush_infection.js @@ -0,0 +1,321 @@ +behaviorRules.CHF = function() { + if (!isEmpty(btemp.newCoords.x,btemp.newCoords.y,true)) { + var newPixel = pixelMap[btemp.newCoords.x][btemp.newCoords.y]; + if (btemp.info.ignore && btemp.info.ignore.indexOf(newPixel.element) !== -1) { + return; + } + if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness || (btemp.newCoords.x == btemp.pixel.x && btemp.newCoords.y == btemp.pixel.y)) { + if (btemp.arg.indexOf(">") !== -1) { + var argfrom = btemp.arg.split(">")[0]; + if (argfrom.indexOf(",") !== -1) { + if (argfrom.split(",").indexOf(newPixel.element) === -1) { + return; + } + } + else if (argfrom !== newPixel.element) { + return; + } + var argto = btemp.arg.split(">")[1]; + } + else { + var argfrom = null; + var argto = btemp.arg; + } + if (argto.indexOf(",") !== -1) { + var argto = choose(argto.split(",")); + } + if (elements[argto]) { + if (elements[newPixel.element].id !== elements[argto].id) { + if (Math.random() < (1-(elements[newPixel.element].hardness || 0)) / (shiftDown ? 1 : 4)) { + changePixel(newPixel,argto); + } + } + } + } + } +} + +elements.mush_spore = { + color: ["#b4d4ae","#b98aba","#805236"], + behavior: [ + "XX|M2%1.5|XX", + "XX|L2:mush_stalk AND C2:mush_gill%20|XX", + "XX|M1|XX", + ], + tick: function(pixel) { + if (Math.random() < 0.02) { + let x = 0; + if (Math.random() < 0.25) { + x += Math.random() < 0.5 ? -1 : 1; + } + if (!isEmpty(pixel.x+x,pixel.y-1,true) && eLists.SOIL.includes(pixelMap[pixel.x+x][pixel.y-1].element)) { + let soil = pixelMap[pixel.x+x][pixel.y-1]; + swapPixels(pixel,soil); + changePixel(soil,"mush_hyphae"); + } + else if (!isEmpty(pixel.x+x,pixel.y-1,true) && !outOfBounds(pixel.x+x,pixel.y-1,true) && Math.random() < (1-(elements[pixelMap[pixel.x+x][pixel.y-1].element].hardness || 0)) / (shiftDown ? 1 : 4)) { + let soil = pixelMap[pixel.x+x][pixel.y-1]; + swapPixels(pixel,soil); + changePixel(soil,"mush_hyphae"); + } + } + }, + reactions: { + "wood": { elem2:"mush_hyphae", chance:0.04 }, + "tree_branch": { elem2:"mush_hyphae", chance:0.04 }, + "plant": { elem2:"mush_hyphae", chance:0.07 }, + "evergreen": { elem2:"mush_hyphae", chance:0.07 }, + "root": { elem2:"mush_hyphae", chance:0.07 }, + "grass": { elem2:"mush_hyphae", chance:0.08 }, + "grass_seed": { elem2:"mush_hyphae", chance:0.08 }, + "epsom_salt": { elem1:null, chance:0.1 }, + "skin": { stain2:"#cc564b" }, + }, + category: "life", + tempHigh: 225, + stateHigh: "fire", + burn: 10, + burnTime: 20, + state: "solid", + density: 123.6, + cooldown: defaultCooldown, + seed: true, + darkText: true, + mush: true +} +elements.mush_stalk = { + color: "#BDC4B6", + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|CHF:mush_hyphae%1 AND M1|XX", + ], + ignore:["mush_hyphae","mush_cap","mush_gill","mush_mulch","mush_stalk","mush_spore"], + reactions: { + "wood": { elem2:"mush_hyphae", chance:0.04 }, + "tree_branch": { elem2:"mush_hyphae", chance:0.04 }, + "plant": { elem2:"mush_hyphae", chance:0.07 }, + "evergreen": { elem2:"mush_hyphae", chance:0.07 }, + "root": { elem2:"mush_hyphae", chance:0.07 }, + "grass": { elem2:"mush_hyphae", chance:0.08 }, + "grass_seed": { elem2:"mush_hyphae", chance:0.08 }, + "ash": { elem2:"mush_hyphae", chance:0.04 }, + "water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "salt_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "sugar_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "seltzer": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "skin": { stain2:"#cc564b" }, + }, + category: "life", + hidden: true, + tempHigh: 225, + stateHigh: "fire", + burn: 10, + burnTime: 65, + state: "solid", + density: 90.445, + seed: "mush_spore", + breakInto: [null,null,"mush_mulch"], + mush: true +} +elements.mush_gill = { + color: "#BFC395", + tick: function(pixel) { + if (!pixel.mColor) { + // make it a hsl random hue, 54% saturation, 52% lightness + pixel.mColor = "hsl(" + Math.floor(Math.random()*200+180)%360 + ",54%,52%)"; + } + if (isEmpty(pixel.x,pixel.y-1) && Math.random() < 0.1) { + createPixel("mush_cap",pixel.x,pixel.y-1); + pixelMap[pixel.x][pixel.y-1].color = pixel.mColor; + } + if (isEmpty(pixel.x-1,pixel.y) && Math.random() < 0.02) { + // create either mush_gill or mush_cap + if (Math.random() < 0.5) { + createPixel("mush_gill",pixel.x-1,pixel.y); + pixelMap[pixel.x-1][pixel.y].mColor = pixel.mColor; + } else { + createPixel("mush_cap",pixel.x-1,pixel.y); + pixelMap[pixel.x-1][pixel.y].color = pixel.mColor; + } + } + if (isEmpty(pixel.x+1,pixel.y) && Math.random() < 0.02) { + if (Math.random() < 0.5) { + createPixel("mush_gill",pixel.x+1,pixel.y); + pixelMap[pixel.x+1][pixel.y].mColor = pixel.mColor; + } else { + createPixel("mush_cap",pixel.x+1,pixel.y); + pixelMap[pixel.x+1][pixel.y].color = pixel.mColor; + } + } + if (!isEmpty(pixel.x,pixel.y+1) && !outOfBounds(pixel.x,pixel.y+1) && (pixel.start + 10) > pixelTicks && pixel.main !== true) { + pixel.main = true + } + if (isEmpty(pixel.x,pixel.y+1) && pixel.main == true) { + createPixel("mush_stalk",pixel.x,pixel.y+1); + } + doDefaults(pixel); + }, + reactions: { + "water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "salt_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "sugar_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "seltzer": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] } + }, + category: "life", + hidden: true, + movable: false, + tempHigh: 225, + stateHigh: "fire", + burn: 10, + burnTime: 65, + burnInto: "mush_spore", + state: "solid", + density: 90.445, + seed: "mush_spore", + breakInto: [null,"mush_mulch","mush_spore","poison"], + mush: true +} +elements.mush_cap = { + color: ["#c76243","#c74442","#c7437e","#c043c7","#7c43c7","#5FEA5F","#c76243","#c74442","#c7437e","#c043c7","#7c43c7","#4543c7","#5FEA5F"], + singleColor: true, + behavior: behaviors.WALL, + reactions: { + "water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "salt_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "sugar_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "seltzer": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] } + }, + category: "life", + hidden: true, + tempHigh: 225, + stateHigh: "fire", + burn: 10, + burnTime: 65, + burnInto: "mush_spore", + state: "solid", + density: 90.445, + seed: "mush_spore", + breakInto: [null,null,"mush_mulch"], + mush: true +} +elements.mush_hyphae = { + color: "#AB8A70", + behavior: [ + "CHF:mush_hyphae,mush_hyphae,mush_mulch%5 AND CH:mush_mulch>mush_hyphae%0.05 AND CR:mush_hyphae%0.05|CR:mush_spore,mush_mulch%0.01 AND CH:mush_hyphae>mush_mulch%0.5|CHF:mush_hyphae,mush_hyphae,mush_mulch%5 AND CH:mush_mulch>mush_hyphae%0.05 AND CR:mush_hyphae%0.05", + "CHF:mush_mulch%0.5 AND CR:mush_mulch%0.01 AND CH:mush_hyphae>mush_mulch%5|XX|CHF:mush_mulch%0.5 AND CR:mush_mulch%0.01 AND CH:mush_hyphae>mush_mulch%5", + "CHF:mush_hyphae,mush_hyphae,mush_mulch%5 AND CH:mush_mulch>mush_hyphae%0.05 AND CR:mush_hyphae%0.5|CH:mush_hyphae>mush_mulch%0.5 AND CR:mush_mulch%0.01|CHF:mush_hyphae,mush_hyphae,mush_mulch%5 AND CH:mush_mulch>mush_hyphae%0.05 AND CR:mush_hyphae%0.5", + ], + ignore:["mush_hyphae","mush_cap","mush_gill","mush_mulch","mush_stalk","mush_spore"], + reactions: { + "wood": { elem2:"mush_mulch", chance:0.04 }, + "tree_brake": { elem2:"mush_mulch", chance:0.04 }, + "plant": { elem2:"mush_mulch", chance:0.07 }, + "evergreen": { elem2:"mush_mulch", chance:0.07 }, + "root": { elem2:"mush_mulch", chance:0.07 }, + "grass": { elem2:"mush_mulch", chance:0.08 }, + "grass_seed": { elem2:"mush_mulch", chance:0.08 }, + "ash": { elem2:"mush_mulch", chance:0.04 }, + "water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "salt_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "sugar_water": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "seltzer": { elem2:"broth", tempMin:70, color2:["#CC9978","#CD8C6F","#BE785E"] }, + "skin": { stain2:"#cc564b" }, + }, + category: "life", + hidden: true, + tempHigh: 225, + stateHigh: "fire", + burn: 30, + burnTime: 20, + state: "solid", + density: 462, + seed: "mush_spore", + conduct: 0.1, + breakInto: ["mush_mulch","mush_mulch","mush_mulch"], + mush: true +} +elements.mush_mulch = { + color: ["#7F494C","#764042","#693A3F"], + behavior: [ + "XX|ST:mush_hyphae%75|XX", + "ST:mush_hyphae%75|FX%0.25|ST:mush_hyphae%75", + "M2%50|ST:mush_hyphae AND M1%75|M1%50", + ], + reactions: { + "dead_plant": { elem2:[null,null,null,"mush_mulch","mush_hyphae"], chance:0.0025 }, + "rotten_meat": { elem2:[null,null,null,"mush_mulch","mush_hyphae"], chance:0.0025 }, + "dead_bug": { elem2:[null,null,null,"mush_mulch","mush_hyphae"], chance:0.0025 }, + "wood": { elem2:[null,"mush_mulch","mush_hyphae"], chance:0.0025 }, + "skin": { stain2:"#cc564b" }, + }, + tick: function(pixel) { + if ((isEmpty(pixel.x+1,pixel.y) || isEmpty(pixel.x-1,pixel.y) || !isEmpty(pixel.x+1,pixel.y) || !isEmpty(pixel.x-1,pixel.y)) && isEmpty(pixel.x,pixel.y-1) && Math.random() < 0.01) { + if (isEmpty(pixel.x+1,pixel.y) && isEmpty(pixel.x-1,pixel.y) && !isEmpty(pixel.x,pixel.y+1)) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + if (elements[pixelMap[pixel.x][pixel.y+1].element].mush !== true) { + changePixel(pixel,"mush_spore") + } + } + else { + changePixel(pixel,"mush_spore") + } + } + if (!isEmpty(pixel.x+1,pixel.y) && !isEmpty(pixel.x-1,pixel.y) && !isEmpty(pixel.x,pixel.y+1)) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + if (elements[pixelMap[pixel.x][pixel.y+1].element].mush !== true) { + if (!isEmpty(pixel.x+1,pixel.y) && !outOfBounds(pixel.x+1,pixel.y)) { + if (elements[pixelMap[pixel.x+1][pixel.y].element].mush !== true) { + changePixel(pixel,"mush_spore") + } + } + if (!isEmpty(pixel.x-1,pixel.y) && !outOfBounds(pixel.x-1,pixel.y)) { + if (elements[pixelMap[pixel.x-1][pixel.y].element].mush !== true) { + changePixel(pixel,"mush_spore") + } + } + } + } + else { + if (!isEmpty(pixel.x+1,pixel.y) && !outOfBounds(pixel.x+1,pixel.y)) { + if (elements[pixelMap[pixel.x+1][pixel.y].element].mush !== true) { + if (!isEmpty(pixel.x-1,pixel.y) && !outOfBounds(pixel.x-1,pixel.y)) { + if (elements[pixelMap[pixel.x-1][pixel.y].element].mush !== true) { + changePixel(pixel,"mush_spore") + } + } + else { + changePixel(pixel,"mush_spore") + } + } + } + if (!isEmpty(pixel.x-1,pixel.y) && !outOfBounds(pixel.x-1,pixel.y)) { + if (elements[pixelMap[pixel.x-1][pixel.y].element].mush !== true) { + if (!isEmpty(pixel.x+1,pixel.y) && !outOfBounds(pixel.x+1,pixel.y)) { + if (elements[pixelMap[pixel.x+1][pixel.y].element].mush !== true) { + changePixel(pixel,"mush_spore") + } + } + else { + changePixel(pixel,"mush_spore") + } + } + } + } + } + } + doDefaults(pixel); + }, + tempHigh:235, + stateHigh: "dirt", + tempLow: -45, + stateLow: "permafrost", + burn: 20, + burnTime: 40, + burnInto: "dirt", + category:"land", + state: "solid", + density: 462, + seed: "mush_spore", + mush: true +} \ No newline at end of file diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 290f48ba..2450dc3a 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -106,7 +106,7 @@ elements.molten_caesium_137 = { stateLow: "caesium_137", tempHigh: 671, hidden: true, - stateHigh: "caesium_vapor_137", + stateHigh: "caesium_137_vapor", density: 1842, temp: 29, conduct: 0.90,