From ffd61ea2d36cc56de87b0f5f28d46d4c8ef54532 Mon Sep 17 00:00:00 2001 From: Alexthetransfem <124483815+theenchantedsword@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:02:12 -0600 Subject: [PATCH 1/4] Create plants.js --- mods/plants.js | 1190 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1190 insertions(+) create mode 100644 mods/plants.js diff --git a/mods/plants.js b/mods/plants.js new file mode 100644 index 00000000..dd304907 --- /dev/null +++ b/mods/plants.js @@ -0,0 +1,1190 @@ +//This mod was made by Adora the transfem, https://discord.com/users/778753696804765696 on discord and https://www.tiktok.com/@alextheagenenby?_t=8hoCVI3NRhu&_r=1 on tiktok. +let fruits = ["plum", "peach", "pear", "orange", "apple", "cherry", "mango"]; +let vineExclude = ["tomato", "grape", "fruit_vine", "kiwi"]; +let vines = ['tomato', 'grape', 'kiwi']; +let bushes = ["blackberry", "blueberry", "raspberry"]; +let allFruits = fruits.concat(vines, bushes) +function interpolateRgb(rgb1, rgb2, ratio) { + const interpolatedRgb = { + r: Math.round(rgb1.r + (rgb2.r - rgb1.r) * ratio), + g: Math.round(rgb1.g + (rgb2.g - rgb1.g) * ratio), + b: Math.round(rgb1.b + (rgb2.b - rgb1.b) * ratio), + }; + return interpolatedRgb; +} + +elements.fruit_branch = { + color: elements.tree_branch.color, + behavior: [ + "CR:fruit_leaves,fruit_branch%2|CR:fruit_leaves,fruit_leaves,fruit_leaves,fruit_branch%2|CR:fruit_leaves,fruit_branch%2", + "XX|XX|XX", + "XX|XX|XX", + ], + tempHigh: 100, + stateHigh: "wood", + tempLow: -30, + stateLow: "wood", + category: "life", + burn: 40, + burnTime: 50, + burnInto: ["sap","ember","charcoal"], + hidden: true, + state: "solid", + density: 1500, + hardness: 0.15, + breakInto: ["sap","sawdust"], + seed: "apple_seed", + tick: function(pixel){ + for(var i = 0; i < adjacentCoords.length; i++){ + let x = pixel.x+adjacentCoords[i][0]; + let y = pixel.y+adjacentCoords[i][1]; + if(isEmpty(x, y) || outOfBounds(x, y)) { continue; } + let pixel2 = pixelMap[x][y]; + if(pixel2.element == "fruit_branch" || pixel2.element == "fruit_leaves" || pixel2.element == "wood"){ + if(pixel.fruit && !pixel2.fruit){ + pixel2.fruit = pixel.fruit; + } else if (!pixel.fruit && pixel2.fruit){ + pixel.fruit = pixel2.fruit; + } + } + } + } +} +elements.fruit_leaves = { + color: elements.plant.color, + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + reactions: { + "vinegar": { elem1:"dead_plant", elem2:null, chance:0.035 }, + "baking_soda": { elem1:"dead_plant", elem2:null, chance:0.01 }, + "bleach": { elem1:"dead_plant", elem2:null, chance:0.05 }, + "alcohol": { elem1:"dead_plant", elem2:null, chance:0.035 } + }, + category:"life", + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -1.66, + stateLow: "frozen_plant", + burn:65, + burnTime:60, + burnInto: "dead_plant", + breakInto: "dead_plant", + state: "solid", + density: 1050, + hidden: true, + tick: function(pixel){ + if(pixelTicks == pixel.start + 1 && pixel.blooming == undefined){ + if(Math.floor(Math.random() * 3) == 2){ + pixel.blooming = true; + pixel.color = "#FFE2E2"; + } else { + pixel.blooming = false; + } + } + for(var i = 0; i < adjacentCoords.length; i++){ + let x = pixel.x+adjacentCoords[i][0]; + let y = pixel.y+adjacentCoords[i][1]; + if(isEmpty(x, y) || outOfBounds(x, y)) { continue; } + let pixel2 = pixelMap[x][y]; + if(pixel2.element == "fruit_branch" || pixel2.element == "fruit_leaves" || pixel2.element == "wood" || (elements[pixel2.element].properties && elements[pixel2.element].properties.type == "fruit")){ + if(pixel.fruit && !pixel2.fruit){ + pixel2.fruit = pixel.fruit; + } else if (!pixel.fruit && pixel2.fruit){ + pixel.fruit = pixel2.fruit; + } + } + } + if(pixel.blooming){ + if(pixelTicks > pixel.start + 150){ + if(Math.floor(Math.random() * 400) == 3){ + if(pixel.fruit){ + if(pixel.fruit == "random"){ + changePixel(pixel, fruits[Math.floor(Math.random() * fruits.length)]); + } else { + changePixel(pixel, pixel.fruit); + } + } + } + } + } + } +} + +elements.apple_seed = { + color: "#1A0E00", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves" || pixelMap[pixel.x][pixel.y+1].element == "wood"){ + pixelMap[pixel.x][pixel.y+1].fruit = "apple"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"apple" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.apple = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: "#ff0004", + category: "food", + breakInto: "juice", + breakIntoColor: "#FF4747", + isFood: true, + properties: { + fruit: "apple", + type: "fruit", + } +} +elements.pear_seed = { + color: "#1A0E00", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "pear"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"pear" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.pear = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: "#97FF43", + category: "food", + breakInto: "juice", + breakIntoColor: "#ABFF8D", + isFood: true, + properties: { + fruit: "pear", + type: "fruit", + } +} +elements.cherry_seed = { + color: "#b56233", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "cherry"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"cherry" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.cherry = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: "#750000", + category: "food", + breakInto: "juice", + breakIntoColor: "#8a0000", + isFood: true, + properties: { + fruit: "cherry", + type: "fruit", + } +} +elements.milk = { + color: "#fafafa", + behavior: behaviors.LIQUID, + onMix: function(milk1, milk2) { + if (shiftDown && Math.random() < 0.01) { + changePixel(milk1,"butter") + } + }, + reactions: { + "melted_chocolate": { elem1:"chocolate_milk", elem2:null }, + "chocolate": { elem1:"chocolate_milk", elem2:"melted_chocolate", chance:0.05 }, + "coffee_ground": { elem1:"chocolate_milk", chance:0.05 }, + "juice": { elem1:"fruit_milk", elem2:null, chance:0.05, func: function(pixel1, pixel2){ + let newrgb = interpolateRgb(getRGB('rgb(250,250,250)'), getRGB(pixel2.color), 0.25); + pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`; + }}, + "soda": { elem1:"pilk", elem2:null, chance:0.1 }, + "yolk": { elem1:"eggnog", elem2:null, chance:0.1 }, + "dirt": { elem1: null, elem2: "mud" }, + "sand": { elem1: null, elem2: "wet_sand" }, + "clay_soil": { elem1: null, elem2: "clay" }, + "caramel": { color1:"#C8B39A", elem2:null, chance:0.05 }, + "sugar": { elem2:null, chance:0.005}, + }, + tempLow: 0, + stateLow: "ice_cream", + stateLowColorMultiplier: [0.97,0.93,0.87], + tempHigh: 93, + stateHigh: "yogurt", + viscosity: 1.5, + category: "liquids", + state: "liquid", + density: 1036.86, + isFood: true +} +elements.cream = { + color: "#f7f7f7", + behavior: behaviors.LIQUID, + onMix: function(milk1, milk2) { + if ((shiftDown && Math.random() < 0.01) || (elements[milk2.element].id === elements.milk.id && Math.random() < 0.00025)) { + changePixel(milk1,"butter") + } + }, + reactions: { + "dirt": { elem1: null, elem2: "mud" }, + "sand": { elem1: null, elem2: "wet_sand" }, + "clay_soil": { elem1: null, elem2: "clay" }, + "melted_chocolate": { color1:"#664934", elem2:null }, + "chocolate": { color1:"#664934", elem2:"melted_chocolate", chance:0.05 }, + "juice": { elem1:"fruit_milk", elem2:null, chance:0.05, func: function(pixel1, pixel2){ + let newrgb = interpolateRgb(getRGB('rgb(250,250,250)'), getRGB(pixel2.color), 0.25); + pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`; + }}, + "soda": { elem1:"pilk", elem2:null, chance:0.1 }, + "yolk": { elem1:"#eggnog", elem2:null, chance:0.1 }, + "caramel": { color1:"#C8B39A", chance:0.05 }, + "sugar": { elem2:null, chance:0.005}, + }, + viscosity: 1.5, + tempHigh: 1000, + stateHigh: ["smoke","smoke","smoke","steam","steam","calcium"], + tempLow: 0, + stateLow: "ice_cream", + stateLowColorMultiplier: 0.97, + category: "liquids", + hidden: true, + isFood: true, + state: "liquid", + density: 959.97, +} +function getRGB(rgb){ + let rgb2 = rgb.replace(")", "").replace("rgb(", "").replace(/,/g, "r").split("r") + return { r: parseInt(rgb2[0]), g: parseInt(rgb2[1]), b: parseInt(rgb2[2]) }; +} +elements.peach = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: ["#ffb485", "#ffa770", "#ff7b61", "#ff512e", "#ff350d"], + category: "food", + breakInto: "juice", + breakIntoColor: "#ffa74f", + isFood: true, + properties: { + fruit: "peach", + type: "fruit", + } +} +elements.peach_seed = { + color: "#240c00", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "peach"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"peach" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.plum = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: "#1c0030", + category: "food", + breakInto: "juice", + breakIntoColor: "#d2880a", + isFood: true, + properties: { + fruit: "plum", + type: "fruit", + } +} +elements.plum_seed = { + color: "#240c00", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "plum"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"plum" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.juice.reactions.juice = { + func: function(pixel1, pixel2){ + if(pixel1.color != pixel2.color){ + if(Math.floor(Math.random() * 1000) == 1){ + let newrgb = interpolateRgb(getRGB(pixel1.color), getRGB(pixel2.color), 0.5); + pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`; + pixel2.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`; + } + } + } +} +elements.juice.onMix = function(pixel){ + let num = Math.floor(Math.random() * 4); + let x = pixel.x + adjacentCoords[num][0]; + let y = pixel.y + adjacentCoords[num][1]; + if(!isEmpty(x,y) && !outOfBounds(x,y)){ + let pixel2 = pixelMap[x][y]; + if(pixel.color != pixel2.color && pixel2.element == "juice"){ + let condition; + if(shiftDown == 0){ + condition = (Math.floor(Math.random() * 2) == 1); + } else { + condition = true; + } + if(condition){ + let newrgb = interpolateRgb(getRGB(pixel.color), getRGB(pixel2.color), 0.5); + pixel.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`; + pixel2.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`; + } + } + } + } +elements.vine.behavior = [["XX", "ST:vine", "XX"],["ST:vine", "XX", "ST:vine"],["XX", "ST:vine AND M1", "XX"]] +elements.apricot = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: ["#ffa100", "#FF5D00", "#FF7A00", "#FF9700"], + category: "food", + breakInto: "juice", + breakIntoColor: "#ffa836", + isFood: true, + properties: { + fruit: "apricot", + type: "fruit", + } +} +elements.apricot_seed = { + color: "#291300", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "apricot"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"apricot" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.orange = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: "#FFB400", + category: "food", + breakInto: "juice", + breakIntoColor: "#FFDB00", + isFood: true, + properties: { + fruit: "orange", + type: "fruit", + } +} +elements.orange_seed = { + color: "#291300", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "orange"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"orange" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.random_seed = { + color: "#291300", + tick: function(pixel) { + if(pixel.start == pixelTicks){ + pixel.fruit = fruits[Math.floor(Math.random() * fruits.length)]; + } + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = pixel.fruit; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.multi_seed = { + color: "#291300", + tick: function(pixel) { + pixel.fruit = fruits[Math.floor(Math.random() * fruits.length)] + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "random"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +elements.fruit_vine = { + category: "life", + color: elements.plant.color, + behavior: [["XX", "ST:fruit_vine AND ST:wood", "XX"], ["ST:fruit_vine AND ST:wood", "XX", "ST:fruit_vine AND ST:wood"], ["XX", "ST:fruit_vine AND M1 AND ST:wood", "XX"]], + properties: { + age: 0, + }, + tick: function(pixel){ + if(Math.floor(Math.random() * 100) == 1 && pixel.age > 25 && pixel.age < 500){ + for(var i = 0; i < squareCoords.length; i++){ + let x1 = pixel.x + squareCoords[i][0]; + let y1 = pixel.y + squareCoords[i][1]; + if(!isEmpty(x1,y1) && !outOfBounds(x1,y1) && !vineExclude.includes(pixelMap[x1][y1].element)){ + let randomNum = Math.floor(Math.random() * 4); + let x2 = x1 + squareCoords[randomNum][0]; + let y2 = y1 + squareCoords[randomNum][1]; + if(isEmpty(x2,y2) && !outOfBounds(x2,y2)){ + createPixel("fruit_vine", x2, y2); + pixelMap[x2][y2].fruit = pixel.fruit; + } + } + } + } + pixel.age += 1; + if(pixel.fruit){ + for(var i = 0; i < adjacentCoords.length; i++){ + let x = pixel.x + adjacentCoords[i][0]; + let y = pixel.y + adjacentCoords[i][1]; + if(isEmpty(x,y) && !outOfBounds(x,y) && Math.floor(Math.random() * 1000) == 5){ + createPixel(pixel.fruit, x, y); + } + } + } + if(!pixel.fruit){ + for(var i = 0; i < squareCoords.length; i++){ + let x = pixel.x + squareCoords[i][0]; + let y = pixel.y + squareCoords[i][1]; + if(isEmpty(x,y) || outOfBounds(x,y)){ continue; } + let pixel2 = pixelMap[x][y]; + if(pixel2.fruit){ + pixel.fruit = pixel2.fruit; + } else { continue; } + } + } + } +} +elements.grape.behavior = [["XX", "ST:fruit_vine", "XX"], ["ST:fruit_vine", "XX", "ST:fruit_vine"], ["M2", "ST:fruit_vine AND M1", "M2"]]; +elements.tomato.behavior = elements.grape.behavior; +elements.tomato_seed = { + color: "#FFFAAD", + category: "life", + behavior: behaviors.POWDER, + tick: function(pixel){ + if(pixel.age > 40){ + changePixel(pixel, "fruit_vine"); + pixel.fruit = "tomato"; + } + pixel.age += 1; + }, + properties: { + age: 0, + }, +} +elements.grape_seed = { + color: "#231A00", + category: "life", + behavior: behaviors.POWDER, + tick: function(pixel){ + if(pixel.age > 40){ + changePixel(pixel, "fruit_vine"); + pixel.fruit = "grape"; + } + pixel.age += 1; + }, + properties: { + age: 0, + }, +} +elements.kiwi = { + behavior: elements.grape.behavior, + color: "#403000", + category: "food", + breakInto: "juice", + breakIntoColor: "#21A800", + isFood: true, + properties: { + type: "fruit", + } +} +elements.kiwi_seed = { + color: "#231A00", + category: "life", + behavior: behaviors.POWDER, + tick: function(pixel){ + if(pixel.age > 40){ + changePixel(pixel, "fruit_vine"); + pixel.fruit = "kiwi"; + } + pixel.age += 1; + }, + properties: { + age: 0, + }, +} +elements.bush_base = { + color: elements.wood.color, + behavior: [ + ["CR:bush_cane%25", "XX", "CR:bush_cane%25"], + ["XX", "XX", "XX"], + ["XX", "XX", "XX"] + ], + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -40, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + tick: function(pixel){ + let caneCoords = [[-1,-1],[1,-1]]; + for(var i = 0; i < caneCoords.length; i++){ + let x = pixel.x + caneCoords[i][0]; + let y = pixel.y + caneCoords[i][1]; + if(!isEmpty(x,y) && !outOfBounds(x,y)){ + let pixel2 = pixelMap[x][y]; + if(pixel2.element == "bush_cane" && !pixel2.fruit){ + pixel2.fruit = pixel.fruit; + } + } + } + } +}; +elements.bush_cane = { + color: elements.wood.color, + tick: function(pixel){ + if(pixel.age < 200 && Math.floor(Math.random() * 40) == 1){ + if(!outOfBounds(pixel.x,pixel.y-1)){ + if(isEmpty(pixel.x,pixel.y-1)){ + createPixel("bush_cane",pixel.x,pixel.y-1); + if(pixel.fruit){ + let pixel2 = pixelMap[pixel.x][pixel.y-1]; + pixel2.fruit = pixel.fruit; + pixel2.age = pixel.age; + } + } + } + } + if(pixel.fruit && Math.floor(Math.random() * 400) == 1 && pixel.age > 200){ + for(var i = 0; i < adjacentCoords.length; i++){ + let x = pixel.x + adjacentCoords[i][0]; + let y = pixel.y + adjacentCoords[i][1]; + if(isEmpty(x,y) && !outOfBounds(x,y)){ + createPixel("fruit_leaves", x, y); + pixelMap[x][y].fruit = pixel.fruit; + pixel.blooming = trueFalse(1, 1)[Math.floor(Math.random() * 2)]; + } + } + } + pixel.age += 1; + }, + properties: { + age: 0, + }, + category: "life", + tempLow: -2, + stateLow: "frozen_plant", +} +function trueFalse(numTrue, numFalse){ + let list = []; + for(var i = 0; i < numTrue; i++){ + list.push(true); + } + for(var i = 0; i < numFalse; i++){ + list.push(false); + } + return list; +} +elements.raspberry_seed = { + color: "#ffe099", + behavior: behaviors.STURDYPOWDER, + category: "life", + properties: { + age: 0, + }, + tick: function(pixel){ + if(pixel.age > 40){ + let x1 = pixel.x - 1; + let y = pixel.y; + let x2 = pixel.x + 1; + if(isEmpty(x1,y) && !outOfBounds(x1,y)){ + createPixel("bush_base", x1, y); + pixelMap[x1][y].fruit = "raspberry"; + } + if(isEmpty(x2,y) && !outOfBounds(x2,y)){ + createPixel("bush_base", x2, y); + pixelMap[x2][y].fruit = "raspberry"; + } + if(!isEmpty(x1, y) && !isEmpty(x2, y)){ + deletePixel(pixel.x, pixel.y); + } + } + pixel.age += 1; + } +} +elements.raspberry = { + behavior: [["XX", "ST:bush_cane", "XX"],["ST:bush_cane", "XX", "ST:bush_cane"],["M2", "ST:bush_cane AND M1", "M2"]], + color: ["#b00009", "#bf000a", "#d10812", "#db1822"], + category: "food", + breakInto: "juice", + breakIntoColor: "#ff2b36", + isFood: true, + properties: { + fruit: "raspberry", + type: "fruit", + } +} +elements.blueberry_seed = { + color: "#ffe099", + behavior: behaviors.STURDYPOWDER, + category: "life", + properties: { + age: 0, + }, + tick: function(pixel){ + if(pixel.age > 40){ + let x1 = pixel.x - 1; + let y = pixel.y; + let x2 = pixel.x + 1; + if(isEmpty(x1,y) && !outOfBounds(x1,y)){ + createPixel("bush_base", x1, y); + pixelMap[x1][y].fruit = "blueberry"; + } + if(isEmpty(x2,y) && !outOfBounds(x2,y)){ + createPixel("bush_base", x2, y); + pixelMap[x2][y].fruit = "blueberry"; + } + if(!isEmpty(x1, y) && !isEmpty(x2, y)){ + deletePixel(pixel.x, pixel.y); + } + } + pixel.age += 1; + } +} +elements.blueberry = { + behavior: [["XX", "ST:bush_cane", "XX"],["ST:bush_cane", "XX", "ST:bush_cane"],["M2", "ST:bush_cane AND M1", "M2"]], + color: ["#01082b", "#060e3d", "#111b52", "#1e2866"], + category: "food", + breakInto: "juice", + breakIntoColor: "#726778", + isFood: true, + properties: { + fruit: "blueberry", + type: "fruit", + } +} +elements.blackberry_seed = { + color: "#ffe099", + behavior: behaviors.STURDYPOWDER, + category: "life", + properties: { + age: 0, + }, + tick: function(pixel){ + if(pixel.age > 40){ + let x1 = pixel.x - 1; + let y = pixel.y; + let x2 = pixel.x + 1; + if(isEmpty(x1,y) && !outOfBounds(x1,y)){ + createPixel("bush_base", x1, y); + pixelMap[x1][y].fruit = "blackberry"; + } + if(isEmpty(x2,y) && !outOfBounds(x2,y)){ + createPixel("bush_base", x2, y); + pixelMap[x2][y].fruit = "blackberry"; + } + if(!isEmpty(x1, y) && !isEmpty(x2, y)){ + deletePixel(pixel.x, pixel.y); + } + } + pixel.age += 1; + } +} +elements.blackberry = { + behavior: [["XX", "ST:bush_cane", "XX"],["ST:bush_cane", "XX", "ST:bush_cane"],["M2", "ST:bush_cane AND M1", "M2"]], + color: ["#0c0021", "#070014", "#080017", "#09001a"], + category: "food", + breakInto: "juice", + breakIntoColor: "#2e0000", + isFood: true, + properties: { + fruit: "blackberry", + type: "fruit", + } +} +elements.mango = { + behavior: [["XX", "ST:fruit_leaves AND ST:fruit_branch", "XX"],["ST:fruit_leaves AND ST:fruit_branch", "XX", "ST:fruit_leaves AND ST:fruit_branch"],["M2", "ST:fruit_leaves AND ST:fruit_branch AND M1", "M2"]], + color: ["#d63a45", "#e97341", "#9d9f3e", "#e4791b"], + category: "food", + breakInto: "juice", + breakIntoColor: "#ffa300", + isFood: true, + properties: { + fruit: "mango", + type: "fruit", + } +} +elements.mango_seed = { + color: "#240c00", + tick: function(pixel) { + if (isEmpty(pixel.x,pixel.y+1)) { + movePixel(pixel,pixel.x,pixel.y+1); + } + else { + if (Math.random() < 0.02 && pixel.age > 50 && pixel.temp < 100) { + if (!outOfBounds(pixel.x,pixel.y+1)) { + var dirtPixel = pixelMap[pixel.x][pixel.y+1]; + if (dirtPixel.element === "dirt" || dirtPixel.element === "mud" || dirtPixel.element === "sand" || dirtPixel.element === "wet_sand" || dirtPixel.element === "clay_soil" || dirtPixel.element === "mycelium") { + changePixel(dirtPixel,"root"); + } + } + if (isEmpty(pixel.x,pixel.y-1)) { + movePixel(pixel,pixel.x,pixel.y-1); + createPixel(Math.random() > 0.5 ? "wood" : "fruit_branch",pixel.x,pixel.y+1); + if (pixelMap[pixel.x][pixel.y+1].element == "fruit_branch" || pixelMap[pixel.x][pixel.y+1].element == "fruit_leaves"){ + pixelMap[pixel.x][pixel.y+1].fruit = "mango"; + } + } + } + else if (pixel.age > 1000) { + changePixel(pixel,"wood"); + } + pixel.age++; + } + doDefaults(pixel); + }, + properties: { + "age":0, + fruit:"mango" + }, + tempHigh: 100, + stateHigh: "dead_plant", + tempLow: -2, + stateLow: "frozen_plant", + burn: 65, + burnTime: 15, + category: "life", + state: "solid", + density: 1500, + cooldown: defaultCooldown, + seed: true, +}; +function conditionTrue(condition, pixel){ + let p = pixel; + let string = ""; + condition = condition.split("!OR").join("||").split("&AND").join("&&").split("\"").join("") + + condition = eval(condition); + return condition; +} +let ifCondition = ""; +let currentProp = ""; +let currentPropValue = ""; +elements.propmachine = { + name: "PropMachine", + behavior: behaviors.WALL, + category: "machines", + noMix: true, +onSelect: function(pixel) { + + let item = prompt("enter range for prop changing."); + if(/^\d+$/.test(item)){ + num4 = parseInt(item); + } else { + alert("that is not an integer."); + } + exclude2 = prompt("Enter elements to exclude, seperate them with commas. You can also enter !IF if you wish to enter conditions for it to change the property and add the exclude elements.").replace(/\s/g, ""); + if(exclude2.includes("!IF")){ + exclude2.split("!IF").join(""); + ifCondition = prompt("Enter the condition for the property to change. List of variables you can access can be found at https://5455e34a-cfe9-4576-ac9c-6e64c061433d-00-1psic9s1cgla6.kirk.replit.dev/Mods/morechemistry/conditions%20for%20if.html"); + } else { ifCondition = '1 == 1'; } + exclude2.split(","); + if(exclude2.constructor == [].constructor){ + exclude2.push("propmachine"); + } else { + exclude2 += "propmachine"; + } + var answer1 = prompt("Warning - This tool may break the simulator if used incorrectly.\n\nEnter a pixel attribute to modify:",(currentProp||undefined)); + console.log(answer1) + if (!answer1) { return } + var answer2 = prompt("Now, enter a value for "+answer1+":",(currentPropValue||undefined)); + if (!answer2) { return } + var valueL = answer2.toLowerCase(); + if (valueL === "true") { answer2 = true } + else if (valueL === "false") { answer2 = false } + else if (valueL === "null") { answer2 = null } + else if (valueL === "undefined") { answer2 = undefined } + else if (answer1 === "color" && valueL[0] === "#") { + var rgb = hexToRGB(valueL); + answer2 = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")"; + } + currentProp = answer1; + currentPropValue = answer2; + console.log(answer1); + var num = parseFloat(answer2); + if (!isNaN(num)) { answer2 = num } + currentPropValue = answer2; + logMessage("Prop: "+currentProp); + logMessage("Value: "+currentPropValue); +}, + tick: function(pixel) { + if(pixel.start == pixelTicks) { + pixel.range = num4; + pixel.condition = ifCondition; + pixel.prop = currentProp; + pixel.val = currentPropValue; + } + let range = mouseRange(pixel.x, pixel.y, pixel.range); + prop({ property: pixel.prop, value: pixel.val },range, exclude2, pixel.condition); + } +} +function prop(obj, range, exclude = [], condition = ""){ + let list = []; + for (var i = 0; i < range.length; i++) { + var x = range[i][0]; + var y = range[i][1]; + if (!isEmpty(x,y,true)) { + var pixel = pixelMap[x][y]; + list.push(pixel); + } + } + for (var i = 0; i < list.length; i++) { + if (!isEmpty(list[i].x, list[i].y, true)) { + var pixel = list[i]; + if (!exclude.includes(pixel.element) && conditionTrue(condition, pixel)){ + if(/^\d+$/.test(obj.value)){ + obj.value = parseInt(obj.value); + } + if (!obj.property) { return } + if (pixel[obj.property] !== undefined && typeof pixel[obj.property] !== typeof obj.value) { + logMessage("Error: "+obj.property+" type is "+typeof pixel[obj.property]+", not "+typeof obj.value+"."); + obj.property = null; + obj.value = null; + return; + } + if (obj.property === "element") { + changePixel(pixel, obj.value); + list.splice(list.indexOf(pixel),1); + return; + } + if (obj.property === "burning" && obj.value === "true") { + pixel.burnStart = pixelTicks; + list.splice(list.indexOf(pixel),1); + return; + } + pixel[obj.property] = obj.value; + list.splice(list.indexOf(pixel),1); + } + } + } +} +elements.seed_maker = { + category: "machines", + behavior: behaviors.WALL, + tick: function(pixel){ + for(var i = 0; i < adjacentCoords.length; i++){ + let x = pixel.x + adjacentCoords[i][0]; + let y = pixel.y + adjacentCoords[i][1] + if(!isEmpty(x,y) && !outOfBounds(x,y)){ + let pixel2 = pixelMap[x][y]; + if(allFruits.includes(pixel2.element)){ + changePixel(pixel2, `${pixel2.element}_seed`) + } + } + } + } +} From 7872c7f76cc75e8b93069440507399e2b34115d8 Mon Sep 17 00:00:00 2001 From: Alexthetransfem <124483815+theenchantedsword@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:03:31 -0600 Subject: [PATCH 2/4] Update morechemistry.js --- mods/morechemistry.js | 277 ++++++++++++++++++++++++++++++++---------- 1 file changed, 215 insertions(+), 62 deletions(-) diff --git a/mods/morechemistry.js b/mods/morechemistry.js index c220dfdf..bcbb9122 100644 --- a/mods/morechemistry.js +++ b/mods/morechemistry.js @@ -1,4 +1,4 @@ -//This mod was made by Alex the transfem, https://discord.com/users/778753696804765696 on discord and https://www.tiktok.com/@alextheagenenby?_t=8hoCVI3NRhu&_r=1 on tiktok. +//This mod was made by Adora the transfem, https://discord.com/users/778753696804765696 on discord and https://www.tiktok.com/@alextheagenenby?_t=8hoCVI3NRhu&_r=1 on tiktok. function pixelInRange(pixel, range){ let i = 0; while (i < range.length) { @@ -635,11 +635,6 @@ elements.potassiumhydroxidecrystals = { density: 2040, name: "PotassiumHydroxideCrystals", } -elements.supercooler = { - name: "SuperCooler", - category: "machines" -} -elements.supercooler.behavior = [["XX","CO:10","XX"],["CO:10","XX","CO:10"],["XX","CO:10","XX"]] elements.iron_chloride = { color: ["#010014", "#a2ff94"], reactions: { @@ -695,7 +690,7 @@ elements.kilonova = { temp: 100000000, } elements.supernova.behavior = [ ["XX", "XX", "XX"], [ "XX", "EX:80>plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,molten_iron,molten_uranium,oxygen,molten_sodium,sulfur_gas,neon,chlorine,molten_calcium,molten_nickel,molten_copper,molten_zinc,gallium_gas,hydrogen,hydrogen,hydrogen,hydrogen,helium,helium,helium AND CH:NeutronStar", "XX" ], ["XX", "XX", "XX"] ] -elements.kilonova.behavior = [ ["XX", "XX", "XX"], [ "XX", "EX:200>plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,molten_iron,molten_uranium,molten_lead,oxygen,molten_sodium,molten_gold,molten_tungsten,sulfur_gas,neon,chlorine,molten_calcium,molten_nickel,molten_copper,molten_zinc,gallium_gas,hydrogen,hydrogen,hydrogen,hydrogen,hydrogen,helium,helium,helium,helium AND CH:void", "XX" ], ["XX", "XX", "XX"] ] +elements.kilonova.behavior = [ ["XX", "XX", "XX"], [ "XX", "EX:200>plasma,plasma,plasma,plasma,plasma,plasma,molten_iron,molten_uranium,molten_lead,oxygen,molten_sodium,molten_gold,molten_tungsten,sulfur_gas,neon,chlorine,molten_calcium,molten_nickel,molten_copper,molten_zinc,gallium_gas,hydrogen,hydrogen,hydrogen,hydrogen,hydrogen,helium,helium,helium,helium AND CH:void", "XX" ], ["XX", "XX", "XX"] ] elements.NeutronStar = { behavior: [["XX", "XX", "XX"], ["CR:light", "XX", "CR:light"], ["XX", "XX", "XX"]], name: "NeutronStar", @@ -1057,52 +1052,12 @@ elements.specialmixer = { mix(range, exclude); } } + let num4 = 0; let exclude2 = []; let property1 = ""; let value2 = ""; -elements.propmachine = { - name: "PropMachine", - behavior: behaviors.WALL, - category: "machines", - noMix: true, - onSelect: function(pixel) { - let item = prompt("enter range for prop changing."); - if(/^\d+$/.test(item)){ - num4 = parseInt(item); - } else { - alert("that is not an integer."); - } - exclude2 = prompt("Enter elements to exclude, seperate them with commas.").replace(/\s/g, "").split(","); - exclude2.push("propmachine"); - var answer1 = prompt("Warning - This tool may break the simulator if used incorrectly.\n\nEnter a pixel attribute to modify:",(currentProp||undefined)); - if (!answer1) { return } - var answer2 = prompt("Now, enter a value for "+answer1+":",(currentPropValue||undefined)); - if (!answer2) { return } - var valueL = answer2.toLowerCase(); - if (valueL === "true") { answer2 = true } - else if (valueL === "false") { answer2 = false } - else if (valueL === "null") { answer2 = null } - else if (valueL === "undefined") { answer2 = undefined } - else if (answer1 === "color" && valueL[0] === "#") { - var rgb = hexToRGB(valueL); - answer2 = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")"; - } - currentProp = answer1; - var num = parseFloat(answer2); - if (!isNaN(num)) { answer2 = num } - currentPropValue = answer2; - logMessage("Prop: "+currentProp); - logMessage("Value: "+currentPropValue); - }, - tick: function(pixel) { - if(pixel.start == pixelTicks) { - pixel.range = num4; - } - let range = mouseRange(pixel.x, pixel.y, pixel.range); - prop({ property: property1, value: value2 },range, exclude2); - } - } + let item = ""; elements.improvedsensor = { behavior: behaviors.WALL, @@ -1196,30 +1151,111 @@ elements.incinerator = { color: 'rgb(255, 50, 0)', noMix: true, } -function prop(obj, range, exclude = []){ +function conditionTrue(condition, pixel){ + let p = pixel; + let string = ""; + condition = condition.split("!OR").join("||").split("&AND").join("&&").split("\"").join("") + + condition = eval(condition); + return condition; +} +let ifCondition = ""; +let currentProp = ""; +let currentPropValue = ""; +elements.propmachine = { + name: "PropMachine", + behavior: behaviors.WALL, + category: "machines", + noMix: true, +onSelect: function(pixel) { + + let item = prompt("enter range for prop changing."); + if(/^\d+$/.test(item)){ + num4 = parseInt(item); + } else { + alert("that is not an integer."); + } + exclude2 = prompt("Enter elements to exclude, seperate them with commas. You can also enter !IF if you wish to enter conditions for it to change the property and add the exclude elements.").replace(/\s/g, ""); + if(exclude2.includes("!IF")){ + exclude2.split("!IF").join(""); + ifCondition = prompt("Enter the condition for the property to change. A list of variables can be seen at the bottom of the page. you cannot use \"\" but you can use `` and ''."); + } else { ifCondition = '1 == 1'; } + exclude2.split(","); + if(exclude2.constructor == [].constructor){ + exclude2.push("propmachine"); + } else { + exclude2 += "propmachine"; + } + var answer1 = prompt("Warning - This tool may break the simulator if used incorrectly.\n\nEnter a pixel attribute to modify:",(currentProp||undefined)); + console.log(answer1) + if (!answer1) { return } + var answer2 = prompt("Now, enter a value for "+answer1+":",(currentPropValue||undefined)); + if (!answer2) { return } + var valueL = answer2.toLowerCase(); + if (valueL === "true") { answer2 = true } + else if (valueL === "false") { answer2 = false } + else if (valueL === "null") { answer2 = null } + else if (valueL === "undefined") { answer2 = undefined } + else if (answer1 === "color" && valueL[0] === "#") { + var rgb = hexToRGB(valueL); + answer2 = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")"; + } + currentProp = answer1; + currentPropValue = answer2; + console.log(answer1); + var num = parseFloat(answer2); + if (!isNaN(num)) { answer2 = num } + currentPropValue = answer2; + logMessage("Prop: "+currentProp); + logMessage("Value: "+currentPropValue); +}, + tick: function(pixel) { + if(pixel.start == pixelTicks) { + pixel.range = num4; + pixel.condition = ifCondition; + pixel.prop = currentProp; + pixel.val = currentPropValue; + } + let range = mouseRange(pixel.x, pixel.y, pixel.range); + prop({ property: pixel.prop, value: pixel.val },range, exclude2, pixel.condition); + } +} +function prop(obj, range, exclude = [], condition = ""){ + let list = []; for (var i = 0; i < range.length; i++) { - if (!isEmpty(range[i][0], range[i][1], true)) { - var pixel = pixelMap[range[i][0]][range[i][1]]; - if (!exclude.includes(pixel.element)){ + var x = range[i][0]; + var y = range[i][1]; + if (!isEmpty(x,y,true)) { + var pixel = pixelMap[x][y]; + list.push(pixel); + } + } + for (var i = 0; i < list.length; i++) { + if (!isEmpty(list[i].x, list[i].y, true)) { + var pixel = list[i]; + if (!exclude.includes(pixel.element) && conditionTrue(condition, pixel)){ if(/^\d+$/.test(obj.value)){ obj.value = parseInt(obj.value); } - if (!currentProp) { return } - if (pixel[currentProp] !== undefined && typeof pixel[currentProp] !== typeof currentPropValue) { - logMessage("Error: "+currentProp+" type is "+typeof pixel[currentProp]+", not "+typeof currentPropValue+"."); - currentProp = null; - currentPropValue = null; + if (!obj.property) { return } + if (pixel[obj.property] !== undefined && typeof pixel[obj.property] !== typeof obj.value) { + logMessage("Error: "+obj.property+" type is "+typeof pixel[obj.property]+", not "+typeof obj.value+"."); + obj.property = null; + obj.value = null; return; } - if (currentProp === "element") { - changePixel(pixel, currentPropValue); + if (obj.property === "element") { + changePixel(pixel, obj.value); + list.splice(list.indexOf(pixel),1); return; } - if (currentProp === "burning" && currentPropValue === "true") { + if (obj.property === "burning" && obj.value === "true") { pixel.burnStart = pixelTicks; + list.splice(list.indexOf(pixel),1); return; } - pixel[currentProp] = currentPropValue; + pixel[obj.property] = obj.value; + list.splice(list.indexOf(pixel),1); } } } @@ -1307,3 +1343,120 @@ function pull(range, pixel1, include = []){ } } } + +let prevNum; +elements.etemper = { + name: "E-Temper", + category: "machines", + conduct: 1, + insulate: true, + behavior: behaviors.WALL, + onSelect: function(pixel){ + prevNum = parseInt(prompt("Enter the temperature you want it set to.", (prevNum || undefined))); + }, + tick: function(pixel){ + if(pixel.start === pixelTicks){ + pixel.clone = `Temp: ${prevNum}`; + pixel.Temp = prevNum; + } + for (var i = 0; i < adjacentCoords.length; i++){ + let x = pixel.x + adjacentCoords[i][0]; + let y = pixel.y + adjacentCoords[i][1]; + if(outOfBounds(x,y)){ continue; } + if(isEmpty(x,y)){ continue; } + let pixel2 = pixelMap[x][y]; + + if (pixel2.temp < pixel.Temp && pixel.charge > 0 ){ + pixel2.temp += pixel.Temp / 6; + } + + } + }, +} +let prevString; +elements.sign = { + name: "Sign", + category: "machines", + onSelect: function(){ + prevString = prompt("Enter the text you want it to say.", (prevString || undefined)); + }, + tick: function(pixel){ + if(pixel.start == pixelTicks){ + pixel.clone = prevString; + } + } +} +document.body.innerHTML += ` +these are all properties of the pixel. another way to find pixel properties is using debug on a pixel, it will tell you the property and the value, like x and y, or, in plants.js, fruit. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Variable + + Definition +
+ p.color + + The color of the pixel. it is defined as an RGB value. +
+ p.x and p.y + + The x and y positions of the pixel. +
+ p.element + + The element of the pixel. +
+ p.clone + + Specific to cloners, specifies what the cloner clones. +
+ wc and lc + + Specific to saplings, specifies what colour the wood is (wc) and what colour the leaves are (lc). +
+ p.start + + The start tick of the pixel. +
+ p.tick + + the amount of ticks that have happened so far in the game. +
+` +document.getElementById("extraInfo").innerHTML = ` +Changelog(NEW)FeedbackWikiRedditDiscord • Install OfflineVariables

v1.9.3 • 559 elements, with 0 hidden.

©2021-2024. All Rights Reserved.

+` From 4b19b0bedf0acb8aea7bf7642f9facd557eb19a6 Mon Sep 17 00:00:00 2001 From: Alexthetransfem <124483815+theenchantedsword@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:04:12 -0600 Subject: [PATCH 3/4] Update allliquids.js --- mods/allliquids.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/mods/allliquids.js b/mods/allliquids.js index ae92e535..80a6bfd1 100644 --- a/mods/allliquids.js +++ b/mods/allliquids.js @@ -1,21 +1,24 @@ +//This mod was made by Adora the transfem, https://discord.com/users/778753696804765696 on discord and https://www.tiktok.com/@alextheagenenby?_t=8hoCVI3NRhu&_r=1 on tiktok. let liquid = [["XX", "XX", "XX"], ["M1", "XX", "M1"], ["M1", "M2", "M1"]] -for (var element in elements){ - - let a = elements[element].behavior; - console.log(a, elements[element], liquid) - if(a != undefined && typeof a != 'function'){ - let i = 0; - while (i < a.length){ - if(typeof a[i] == "string"){ - a[i] = a[i].split("|"); - i += 1; - } else { - i += 1; +runAfterLoad(function(){ + for (var element in elements){ + elements[element].noMix = false; + let a = elements[element].behavior; + console.log(a, elements[element], liquid) + if(a != undefined && typeof a != 'function'){ + let i = 0; + while (i < a.length){ + if(typeof a[i] == "string"){ + a[i] = a[i].split("|"); + i += 1; + } else { + i += 1; + } } + elements[element].behavior = [[a[0][0], a[0][1], a[0][2]], [`${a[1][0]} AND M1`, a[1][1], `${a[1][2]} AND M1`], [`${a[2][0]} AND M1`, `${a[2][1]} AND M2`, `${a[2][2]} AND M1`]]; + } else { + elements[element].behavior = liquid; } - elements[element].behavior = [[a[0][0], a[0][1], a[0][2]], [`${a[1][0]} AND M1`, a[1][1], `${a[1][2]} AND M1`], [`${a[2][0]} AND M1`, `${a[2][1]} AND M2`, `${a[2][2]} AND M1`]]; - } else { - elements[element].behavior = liquid; + } - -} +}); From aad1b147125998fc4ca1f1f35485c0bd5b18cd78 Mon Sep 17 00:00:00 2001 From: Alexthetransfem <124483815+theenchantedsword@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:14:22 -0600 Subject: [PATCH 4/4] Update mod-list.html --- mod-list.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mod-list.html b/mod-list.html index ec35b37d..fb909973 100644 --- a/mod-list.html +++ b/mod-list.html @@ -117,7 +117,7 @@ Tools & Settings adjustablepixelsize.jsAllows you to set the pixelSize with a URL parameterAlice -betaworldgen.jsadds a more advanced world generation to the gameAlex +betaworldgen.jsadds a more advanced world generation to the gameAdora betterModManager.jsImprovements to the Mod Managerggod betterSettings.jsAdds additional settings and functionalityggod betterStats.jsSeparate “real” and “set” TPS, meaning you can see what the TPS actually is, instead of only seeing what it’s set tomollthecoder @@ -168,7 +168,7 @@ metals.jsAdds several metalsAlice mixture.jsAllows many chemicals to be mixedlllllllllwith10ls more_gold.jsAdds Green Goldpixelegend4 -morechemistry.jsAdds many new chemicals and compounds as well as some new machinesAlex +morechemistry.jsAdds many new chemicals and compounds as well as some new machinesAdora moreliquids.jsAdds various liquidste-agma-at nellfire.jsAdds a weird transforming flame and several rock typesAlice Neutronium Mod.jsVariety of scientific elements
ExplosionsStellarX20 @@ -235,6 +235,7 @@ nocancer2.jsRemoves cancer from the game altogether. May be incompatible with other mods that spawn cancermollthecoder nograssgrow.jsPrevents Grass from growingmollthecoder pizzasstuff.jsNew animals, foods, and plants_ilikepizza_ +plants.jsAdds a wide variety of new plants and fruitsAdora primordial_birthpool.jsA cross between Primordial Soup and Birthpool. Requires F&MAlice spring.jsMany nature elements, like sakura trees, butterflies, beehives, and moreR74n the_ground_og.jsSimplified and more stable version of the_ground.jsAlice @@ -244,7 +245,7 @@ Fun & Games all_around_fillers.jsAdds directional Filler variantsidk73248 -allliquids.jsMade all elements liquidsAlex +allliquids.jsMade all elements liquidsAdora amogus.jsAdds a small amogus structureAlice collab_mod.jsCreated by multiple people, adds random thingsmrapple, ilikepizza, stefanblox elem3.jsAdds all elements and combinations from Elemental 3 [Very Large]Sophie