Update plants.js
This commit is contained in:
parent
55a5d7cf4c
commit
43a91664b8
185
mods/plants.js
185
mods/plants.js
|
|
@ -1,18 +1,14 @@
|
|||
/*
|
||||
Version 2.2.0
|
||||
*/
|
||||
function noiseify(color, range){
|
||||
if(color.startsWith("#")){
|
||||
color = hexToRGB(color);
|
||||
let plants;
|
||||
if(!enabledMods.includes("/mods/orchidslibrary.js")){
|
||||
let continueWithout = confirm("Missing dependency for plants.js: \"orchidslibrary.js\". Continue without? (cancel will add mod and refresh the page)");
|
||||
if(!continueWithout){
|
||||
addMod("/mods/orchidslibrary.js", true);
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
color = getRGB(color);
|
||||
}
|
||||
let num = Math.round(Math.random()*(range*2))-range;
|
||||
for(let value in color){
|
||||
color[value] += num;
|
||||
}
|
||||
return `rgb(${color.r},${color.g},${color.b})`;
|
||||
}
|
||||
let is2d = (arr)=>{
|
||||
return arr.some(item => Array.isArray(item));
|
||||
}
|
||||
|
|
@ -57,11 +53,11 @@ class growInterval {
|
|||
}
|
||||
let flowerExclude = ["pineapple"];
|
||||
let vineGrow = ["wood", "rock_wall", "straw", "wall", "ewall", "bush_cane", "bush_base", "fruit_branch"];
|
||||
let plants = {
|
||||
plants = {
|
||||
tree: [],
|
||||
vine: ["grape", "tomato"],
|
||||
bush: [],
|
||||
other: ["pineapple", "watermelon", "banana"],
|
||||
other: ["pineapple", "watermelon", "banana", "onion"],
|
||||
includes: function(target){
|
||||
for(item in this){
|
||||
if(this[item] && Array.isArray(this[item]) && this[item].includes(target)){return true;}
|
||||
|
|
@ -311,6 +307,108 @@ elements.grape.tick = function(pixel){
|
|||
}
|
||||
elements.wood.properties = {age: 0, fruit: ""};
|
||||
|
||||
elements.nutrient_agar = {
|
||||
category: "life",
|
||||
behavior: behaviors.STURDYPOWDER,
|
||||
properties: {
|
||||
value: null,
|
||||
},
|
||||
state: "solid",
|
||||
color: ["#edeae4", "#f2f0eb", "#e8e7e3", "#f5f1e9"],
|
||||
tick: function(pixel) {
|
||||
for(let coords of adjacentCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1];
|
||||
let p2 = getPixel(x,y);
|
||||
if(p2 != null){
|
||||
if(["wine", "yeast", "grape", "apple", "plum"].includes(p2.element) && pixel.value == null){
|
||||
pixel.value = "yeast";
|
||||
} else if(p2.element == "mold" && pixel.value == null){
|
||||
pixel.value = "mold";
|
||||
}else if(p2.element == "mushroom_spore" && pixel.value == null){
|
||||
pixel.value = "mushroom_spore";
|
||||
}else if (p2.element == pixel.element && p2.value != null && pixel.value == null && Math.random()<0.0035){
|
||||
pixel.value = p2.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Math.random() < 0.00075){
|
||||
if(pixel.value == null && Math.random() < 0.025){
|
||||
let elems = ["mold", "mold", "mushroom_spore"];
|
||||
let elem = elems[Math.round(Math.random()*elems.length)];
|
||||
while(elem == undefined){
|
||||
elem = elems[Math.round(Math.random()*elems.length)];
|
||||
}
|
||||
changePixel(pixel, elem);
|
||||
} else {
|
||||
changePixel(pixel, pixel.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
elements.mold = {
|
||||
category: "life",
|
||||
behavior: behaviors.POWDER,
|
||||
color: ["#33402a", "#303d25", "#2b4f39", "#254231"],
|
||||
reactions: {
|
||||
cheese: {elem2: ["rotten_cheese", "rotten_cheese", "mold"], chance: 0.075},
|
||||
meat: {elem2: ["rotten_meat", "rotten_meat", "mold"], chance: 0.075},
|
||||
},
|
||||
state: "solid",
|
||||
tick: function(pixel){
|
||||
for(let coords of adjacentCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1], p2 = getPixel(x,y);
|
||||
if(p2 != null){
|
||||
if(plants.includes(p2.element) && Math.random() < 0.025){
|
||||
let elems = ["mold", "rotten_fruit", "rotten_fruit"];
|
||||
let elem = elems[Math.round(Math.random()*elems.length)];
|
||||
while(elem == undefined){
|
||||
elem = elems[Math.round(Math.random()*elems.length)];
|
||||
}
|
||||
changePixel(p2, elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
elements.rotten_fruit = {
|
||||
color: ["#5e3d00", "#5c3c01", "#4a3205", "#634102"],
|
||||
category: "life",
|
||||
behavior: behaviors.POWDER,
|
||||
reactions: {
|
||||
cheese: {elem2: ["rotten_cheese", "rotten_cheese", "mold"], chance: 0.075},
|
||||
meat: {elem2: ["rotten_meat", "rotten_meat", "mold"], chance: 0.075},
|
||||
},
|
||||
state: "solid",
|
||||
};
|
||||
|
||||
elements.yeast = {
|
||||
color: ["#e3d3a6", "#f2dea7", "#e3cf98", "#f2dfaa"],
|
||||
category: "life",
|
||||
density: 1033,
|
||||
behavior: behaviors.POWDER,
|
||||
reactions: {
|
||||
sugar_water: {elem2: "wine", color2: ["#6e85b5", "#6d81ab"], chance: 0.00025},
|
||||
water: {elem2: "seltzer", chance: 0.00005},
|
||||
},
|
||||
tick: function(pixel){
|
||||
for(let coords of adjacentCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1], p2 = getPixel(x,y);
|
||||
if(p2 != null){
|
||||
if(p2.element == "juice" && Math.random() < 0.00025){
|
||||
let rgb = getRGB(p2.color);
|
||||
for(key in rgb){
|
||||
rgb[key] = Math.max(rgb[key] - 10, 0);
|
||||
}
|
||||
changePixel(p2, "wine");
|
||||
p2.color = normalize(rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elements.fruit_branch = {
|
||||
color: elements.tree_branch.color,
|
||||
behavior: [
|
||||
|
|
@ -741,22 +839,6 @@ elements.tomato_seed = new vineSeed("tomato", ["#F8F5D1","#E7E5CF","#E3E1C5"]);
|
|||
elements.apple = new fruit("apple", ["#FF0507", "#EC0A0D", "#F22426", "#DC2C2E"], ["#F9C497", "#EED3BB", "#EEDEBB"]);
|
||||
elements.apple.bloomColor = ["#fff0f7", "#fcebf3", "#fff0f7", "#ffe6f2", "#fff7fb"];
|
||||
elements.apple_seed = new treeSeed("apple", ["#3B1C01", "#3E2107", "#3A1C02"]);
|
||||
function colorMix(p1, p2, bias = 0.5){
|
||||
p1.color = interpolateRgb(getRGB(p1.color), getRGB(p2.color), bias);
|
||||
p2.color = interpolateRgb(getRGB(p1.color), getRGB(p2.color), bias);
|
||||
}
|
||||
function interpolateRgb(rgb1, rgb2, ratio = 0.5) {
|
||||
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 normalize(interpolatedRgb);
|
||||
}
|
||||
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.juice.tick = function(pixel){
|
||||
for(let i = 0; i < squareCoords.length; i++){
|
||||
|
|
@ -790,9 +872,6 @@ elements.fruit_milk.onMix = function(pixel){
|
|||
}
|
||||
}
|
||||
}
|
||||
function normalize(obj){
|
||||
return `rgb(${obj.r},${obj.g},${obj.b})`;
|
||||
}
|
||||
|
||||
elements.milk.reactions.juice = {func: function(p1, p2){
|
||||
let rgb = interpolateRgb(getRGB(p1.color), getRGB(p2.color), 0.25);
|
||||
|
|
@ -1502,3 +1581,45 @@ elements.onion_seed = {
|
|||
}
|
||||
}
|
||||
}
|
||||
elements.grape.reactions.sugar_water = {elem2: "wine", chance: 0.0006};
|
||||
elements.grape.reactions.water = {elem2: "wine", chance: 0.00006};
|
||||
elements.wine = {
|
||||
density: 992,
|
||||
color: ["#381b30", "#402137", "#261321", "#38192f"],
|
||||
behavior: behaviors.LIQUID,
|
||||
category: "liquids",
|
||||
state: "liquid",
|
||||
properties: {
|
||||
alcChance: 0.13,
|
||||
},
|
||||
tick: function(pixel){
|
||||
if(Math.random() < 0.00025){
|
||||
pixel.alcChance += 0.01;
|
||||
}
|
||||
if(pixel.temp >70){
|
||||
let chanceMulti = (pixel.temp-70)/20;
|
||||
let chance = (pixel.alcChance/100)*chanceMulti;
|
||||
for(let coords of squareCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1];
|
||||
if(isEmpty(x,y) && !outOfBounds(x,y) && Math.random() < chance){
|
||||
createPixel("alcohol_gas", x,y);
|
||||
if(Math.random() < 0.5){
|
||||
let rgb = getRGB(pixel.color);
|
||||
for(let key in rgb){
|
||||
rgb[key] += 10;
|
||||
rgb[key] = Math.max(rgb[key], 0);
|
||||
}
|
||||
changePixel(pixel, "juice");
|
||||
|
||||
pixel.color = noiseify(RGBToHex(rgb), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
tempHigh: 100,
|
||||
stateHigh: ["sugar", "carbon_dioxide", "steam", "alcohol_gas"],
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue