commit
60a6eb3c7d
|
|
@ -243,6 +243,7 @@
|
|||
<tr><td>radioactive.js</td><td>Radioactive elements on the periodic table [WIP]</td><td>kaeud</td></tr>
|
||||
<tr><td>random_rocks.js</td><td>Randomly generates rocks on game load</td><td>Alice</td></tr>
|
||||
<tr><td>roseyiede.js</td><td>Several variants of a substance called roseyiede</td><td>Alice</td></tr>
|
||||
<tr><td>solubility.js</td><td>Adds solubility and a simple-to-use format for other mods to use with it</td><td>Orchid</td></tr>
|
||||
<tr><td>some_tf_liquids.js</td><td>Various liquids from the Thermal Foundation Minecraft mod</td><td>Alice</td></tr>
|
||||
<tr><td>stickystuff.js</td><td>Slime, Honey, and others can stick to other elements</td><td>Suss</td></tr>
|
||||
<tr><td>the_ground.js</td><td>Several rocks, worldgen types, and gemstones</td><td>Alice</td></tr>
|
||||
|
|
|
|||
|
|
@ -1,97 +1,78 @@
|
|||
/*
|
||||
*Version 2.2.0
|
||||
*Version 2.2.1
|
||||
*/
|
||||
|
||||
dependOn("orchidslibrary.js", ()=>{
|
||||
elements.cloner.keyInput = "str:clone", elements.ecloner.keyInput = "str:clone", elements.slow_cloner.keyInput = "str:clone", elements.floating_cloner.keyInput = "str:clone";
|
||||
let xDown = false;
|
||||
elements.copper_sulfate = {
|
||||
behavior: behaviors.POWDER,
|
||||
color: ["#4391fd","#004cfe"],
|
||||
reactions: {
|
||||
ant: {"elem2": "dead_bug"},
|
||||
fly: {"elem2": "dead_bug"},
|
||||
firefly: {"elem2": "dead_bug"},
|
||||
stink_bug: {"elem2": "dead_bug"},
|
||||
bee: {"elem2": "dead_bug"},
|
||||
termite: {"elem2": "dead_bug"},
|
||||
spider: {"elem2": "dead_bug"},
|
||||
plant: {"elem2": "dead_plant"},
|
||||
grass: {"elem2": "dead_plant"},
|
||||
algae: {"elem2": null},
|
||||
kelp: {"elem2": "water"},
|
||||
coral: {"elem2": "water"},
|
||||
mushroom_cap: {"elem2": null},
|
||||
mushroom_stalk: {"elem2": null},
|
||||
mushroom_gill: {"elem2": null},
|
||||
mushroom_spore: {"elem2": null},
|
||||
zinc: {"stain2": "#2A1210"},
|
||||
fire: {"elem1": null,"elem2": "poison_gas","chance": 0.1},
|
||||
sugar: {"elem1": "oxidized_copper","elem2": null,"color1": ["#CB3D3D","#A6292B","#6E1B1B"]},
|
||||
magnesium: {elem1: "copper", elem2: "epsom_salt"},
|
||||
wood: {stain2: "#043023"},
|
||||
},
|
||||
tempHigh: 110,
|
||||
fireColor: [
|
||||
"#91d106",
|
||||
"#feff97",
|
||||
"#248e01"
|
||||
],
|
||||
state: "solid",
|
||||
density: 3600,
|
||||
hidden: true,
|
||||
category: "powders",
|
||||
id: 509,
|
||||
movable: true,
|
||||
properties: {
|
||||
anhydrous: false
|
||||
},
|
||||
tick: function(pixel){
|
||||
if(pixelTicks-pixel.start == 2 && xDown){
|
||||
pixel.anhydrous = true;
|
||||
let rgb = {r: 235, g: 247, b: 250};
|
||||
elements.copper_sulfate.reactions = {
|
||||
ant: {"elem2": "dead_bug"},
|
||||
fly: {"elem2": "dead_bug"},
|
||||
firefly: {"elem2": "dead_bug"},
|
||||
stink_bug: {"elem2": "dead_bug"},
|
||||
bee: {"elem2": "dead_bug"},
|
||||
termite: {"elem2": "dead_bug"},
|
||||
spider: {"elem2": "dead_bug"},
|
||||
plant: {"elem2": "dead_plant"},
|
||||
grass: {"elem2": "dead_plant"},
|
||||
algae: {"elem2": null},
|
||||
kelp: {"elem2": "water"},
|
||||
coral: {"elem2": "water"},
|
||||
mushroom_cap: {"elem2": null},
|
||||
mushroom_stalk: {"elem2": null},
|
||||
mushroom_gill: {"elem2": null},
|
||||
mushroom_spore: {"elem2": null},
|
||||
zinc: {"stain2": "#2A1210"},
|
||||
fire: {"elem1": null,"elem2": "poison_gas","chance": 0.1},
|
||||
sugar: {"elem1": "oxidized_copper","elem2": null,"color1": ["#CB3D3D","#A6292B","#6E1B1B"]},
|
||||
magnesium: {elem1: "copper", elem2: "epsom_salt"},
|
||||
wood: {stain2: "#043023"},
|
||||
}
|
||||
elements.copper_sulfate.tick = function(pixel){
|
||||
if(pixelTicks-pixel.start == 2 && xDown){
|
||||
pixel.anhydrous = true;
|
||||
let rgb = {r: 235, g: 247, b: 250};
|
||||
let num = 6 - (Math.round(Math.random()*12));
|
||||
for(let key in rgb){
|
||||
rgb[key] += num;
|
||||
}
|
||||
pixel.color = `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
||||
}
|
||||
let multi = (pixel.temp-70)/100;
|
||||
multi = (multi < 0) ? 0 : ((multi > 1) ? 1 : multi);
|
||||
if(Math.random() < 0.05*multi){
|
||||
pixel.anhydrous = true;
|
||||
let rgb = {r: 235, g: 247, b: 250};
|
||||
let num = 6 - (Math.round(Math.random()*12));
|
||||
for(let key in rgb){
|
||||
rgb[key] += num;
|
||||
}
|
||||
pixel.color = `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
||||
}
|
||||
if(pixel.anhydrous){
|
||||
let neighbors = [];
|
||||
for(let coords of squareCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1];
|
||||
neighbors[neighbors.length] = (isEmpty(x,y) && !outOfBounds(x,y)) ? "air" : (!outOfBounds(x,y)) ? pixelMap[x][y].element : undefined;
|
||||
}
|
||||
if(neighbors.includes("air") && pixel.temp < 50 && Math.random() < 0.00035){
|
||||
pixel.anhydrous = false;
|
||||
let rgb = (Math.random() > 0.5) ? {r: 67, g: 145, b: 253} : {r: 0, g: 76, b: 254};
|
||||
let num = 6 - (Math.round(Math.random()*12));
|
||||
for(let key in rgb){
|
||||
rgb[key] += num;
|
||||
}
|
||||
pixel.color = `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
||||
}
|
||||
let multi = (pixel.temp-70)/100;
|
||||
multi = (multi < 0) ? 0 : ((multi > 1) ? 1 : multi);
|
||||
if(Math.random() < 0.05*multi){
|
||||
pixel.anhydrous = true;
|
||||
let rgb = {r: 235, g: 247, b: 250};
|
||||
|
||||
} else if (neighbors.includes("steam") || neighbors.includes("water") || neighbors.includes("salt_water") || neighbors.includes("sugar_water") || neighbors.includes("dirty_water") || neighbors.includes("seltzer") || neighbors.includes("pool_water") || neighbors.includes("slush")){
|
||||
pixel.anhydrous = false;
|
||||
let rgb = (Math.random() > 0.5) ? {r: 67, g: 145, b: 253} : {r: 0, g: 76, b: 254};
|
||||
let num = 6 - (Math.round(Math.random()*12));
|
||||
for(let key in rgb){
|
||||
rgb[key] += num;
|
||||
}
|
||||
pixel.color = `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
||||
}
|
||||
if(pixel.anhydrous){
|
||||
let neighbors = [];
|
||||
for(let coords of squareCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1];
|
||||
neighbors[neighbors.length] = (isEmpty(x,y) && !outOfBounds(x,y)) ? "air" : (!outOfBounds(x,y)) ? pixelMap[x][y].element : undefined;
|
||||
}
|
||||
if(neighbors.includes("air") && pixel.temp < 50 && Math.random() < 0.00035){
|
||||
pixel.anhydrous = false;
|
||||
let rgb = (Math.random() > 0.5) ? {r: 67, g: 145, b: 253} : {r: 0, g: 76, b: 254};
|
||||
let num = 6 - (Math.round(Math.random()*12));
|
||||
for(let key in rgb){
|
||||
rgb[key] += num;
|
||||
}
|
||||
pixel.color = `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
||||
|
||||
} else if (neighbors.includes("steam") || neighbors.includes("water") || neighbors.includes("salt_water") || neighbors.includes("sugar_water") || neighbors.includes("dirty_water") || neighbors.includes("seltzer") || neighbors.includes("pool_water") || neighbors.includes("slush")){
|
||||
pixel.anhydrous = false;
|
||||
let rgb = (Math.random() > 0.5) ? {r: 67, g: 145, b: 253} : {r: 0, g: 76, b: 254};
|
||||
let num = 6 - (Math.round(Math.random()*12));
|
||||
for(let key in rgb){
|
||||
rgb[key] += num;
|
||||
}
|
||||
pixel.color = `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elements.water.ignore = ["copper_sulphate"], elements.steam.ignore = ["copper_sulphate"], elements.pool_water.ignore = ["copper_sulphate", 'pool_ice'], elements.salt_water.ignore = ["copper_sulphate", 'salt_ice'], elements.sugar_water.ignore = ["copper_sulphate", 'sugar_ice'], elements.seltzer.ignore = ["copper_sulphate", 'seltzer_ice'],
|
||||
|
|
@ -806,6 +787,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
category: "salts",
|
||||
state: "solid",
|
||||
density: 3900,
|
||||
solubility: {water: 3.5},
|
||||
reactions: {
|
||||
potassium: {elem1: "gold_coin", elem2: "potassium_salt", func: function(pixel){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()<0.25){createPixel("hydrogen", x, y);}}}, color1: ["#574000", "#705200", "#634900", "#755600"]},
|
||||
sodium: {elem1: "gold_coin", elem2: "salt", func: function(pixel){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()<0.25){createPixel("hydrogen", x, y);}}}, color1: ["#574000", "#705200", "#634900", "#755600"]},
|
||||
|
|
@ -823,6 +805,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
color: ["#f2f2f2", "#f5f5f5", "#ebebeb", "#e6e6e6"],
|
||||
density: 2320,
|
||||
solubility: {water: 0.543, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
reactions: {
|
||||
baking_soda: {elem1: "magnesium_carbonate", elem2: "salt"},
|
||||
lye: {elem1: "magnesium_hydroxide", elem2: "salt"},
|
||||
|
|
@ -852,6 +835,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
behavior: behaviors.POWDER,
|
||||
state: "solid",
|
||||
color: ["#f2f2f2", "#f5f5f5", "#ebebeb", "#e6e6e6"],
|
||||
solubility: {water: 0.745, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
reactions: {
|
||||
baking_soda: {elem1: "limestone", elem2: "salt"},
|
||||
lye: {elem1: "slaked_lime", elem2: "salt"},
|
||||
|
|
@ -941,6 +925,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
color: ["#ffffff", "#fcfcfc", "#ffffff", "#ededed"],
|
||||
density: 2470,
|
||||
solubility: {water: 0.8, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
reactions: {
|
||||
water: {elem1: "gallium", elem2: "acid"},
|
||||
steam: {elem1: "gallium", elem2: "acid_gas"},
|
||||
|
|
@ -972,6 +957,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
density: 2480,
|
||||
tempHigh: 630,
|
||||
stateHigh: ["chlorine", "aluminum"],
|
||||
solubility: {water: 0.458, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
}
|
||||
elements.acid.reactions.aluminum = {elem1: "hydrogen", elem2: "aluminum_chloride"};
|
||||
elements.acid.reactions.purple_gold = {elem1: ["aluminum_chloride", "aluminum_chloride", "hydrogen"], elem2: "gold"};
|
||||
|
|
@ -1079,6 +1065,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
category: "salts",
|
||||
alias: "Mg(CH₃COO)₂",
|
||||
solubility: {water: 0.53, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
reactions: {
|
||||
acid: {elem1: "magnesium_chloride", elem2: "vinegar"},
|
||||
baking_soda: {elem1: "magnesium_carbonate", elem2: "sodium_acetate"},
|
||||
|
|
@ -1095,6 +1082,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
category: "salts",
|
||||
alias: "Ca(CH₃COO)₂",
|
||||
solubility: {water: 0.347, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
reactions: {
|
||||
acid: {elem1: "calcium_chloride", elem2: "vinegar"},
|
||||
baking_soda: {elem1: "limestone", elem2: "sodium_acetate"},
|
||||
|
|
@ -1113,6 +1101,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
category: "salts",
|
||||
alias: "CH₃COOK",
|
||||
solubility: {water: 2.55, color: ["#7a9ff0", "#7aa4ff", "#729bf2", "#6f9cfc"]},
|
||||
reactions: {
|
||||
acid: {elem1: "potassium_salt", elem2: "vinegar"},
|
||||
baking_soda: {elem1: "caustic_potash", elem2: "sodium_acetate"},
|
||||
|
|
@ -1128,6 +1117,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
category: "salts",
|
||||
alias: "Cu(CH₃COO)₂",
|
||||
solubility: {water: 0.072},
|
||||
reactions: {
|
||||
sodium: {elem1: "copper", elem2: "sodium_acetate"},
|
||||
potassium: {elem1: "copper", elem2: "potassium_acetate"},
|
||||
|
|
@ -1148,6 +1138,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
state: "solid",
|
||||
category: "salts",
|
||||
alias: "CuCl₂",
|
||||
solubility: {water: 0.743},
|
||||
reactions: {
|
||||
sodium: {elem1: "copper", elem2: "sodium_acetate"},
|
||||
potassium: {elem1: "copper", elem2: "potassium_acetate"},
|
||||
|
|
@ -1265,6 +1256,7 @@ dependOn("orchidslibrary.js", ()=>{
|
|||
alias: "H₂PtCl₆",
|
||||
tempHigh: 500,
|
||||
stateHigh: ["acid_gas", "chlorine", "platinum", "platinum"],
|
||||
solubility: {water: 1, },
|
||||
reactions: {
|
||||
sodium: {elem1: "salt", elem2: "platinum", color2: ["#404040", "#525252", "#454545", "#2e2e2e", "#262626"]},
|
||||
potassium: {elem1: "potassium_salt", elem2: "platinum", color2: ["#404040", "#525252", "#454545", "#2e2e2e", "#262626"]},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* Version 1.0.0
|
||||
*/
|
||||
|
||||
dependOn("orchidslibrary.js", ()=>{
|
||||
elements.water.reactions.salt = undefined;
|
||||
elements.water.reactions.sugar = undefined;
|
||||
elements.water.properties = {capacity: 100, elemsDissolved: {}};
|
||||
elements.salt.solubility = {water: 0.36, color: ["#7ca3f7", "#7798e0", "#89abf5", "#96b8ff"]};
|
||||
elements.sugar.solubility = {water: 2, visc: 850, color: ["#9bb0de", "#a8bbe3", "#a2b8e8", "#a7b7d9"]};
|
||||
elements.lye.solubility = {water: 1.09, color: ["#7ca3f7", "#7798e0", "#89abf5", "#96b8ff"]};
|
||||
elements.caustic_potash.solubility = {water: 1.1, color: ["#7ca3f7", "#7798e0", "#89abf5", "#96b8ff"]};
|
||||
elements.potassium_salt.solubility = {water: 0.3397, color: ["#7ca3f7", "#7798e0", "#89abf5", "#96b8ff"]};
|
||||
elements.borax.solubility = {water: 0.041, color: ["#658ce0", "#7299ed", "#7597e0", "#78a1fa"]};
|
||||
elements.epsom_salt.solubility = {water: 0.351, color: ["#658ce0", "#7299ed", "#7597e0", "#78a1fa"]};
|
||||
elements.sodium_acetate.solubility = {water: 1.233, color: ["#7ca3f7", "#7798e0", "#89abf5", "#96b8ff"]};
|
||||
elements.baking_soda.solubility = {water: 0.097, color: ["#7ca3f7", "#7798e0", "#89abf5", "#96b8ff"]};
|
||||
elements.copper_sulfate.solubility = {water: 0.32, color: ["#4a68f0", "#3358ff", "#2948d6", "#2146ed"]};
|
||||
elements.lye.reactions.water = undefined;
|
||||
elements.soap.reactions.water = undefined;
|
||||
elements.ash.solubility = {water: 1.1, func: function(p1, p2){
|
||||
if(p1.elemsDissolved.caustic_potash != undefined){
|
||||
p1.elemsDissolved.caustic_potash += p1.elemsDissolved.ash;
|
||||
p1.elemsDissolved.ash = 0;
|
||||
} else {
|
||||
p1.elemsDissolved.caustic_potash = p1.elemsDissolved.ash;
|
||||
p1.elemsDissolved.ash = 0;
|
||||
}
|
||||
if(p2.dissolved >= 100){
|
||||
changePixel(p2, getItem(["limestone", "quicklime", "charcoal", "dust", "dust"]));
|
||||
p2.dissolved = undefined;
|
||||
}
|
||||
}};
|
||||
elements.water.reactions.ash = undefined;
|
||||
function getItem(obj){
|
||||
let res;
|
||||
if(Array.isArray(obj)){
|
||||
res = obj[Math.round(Math.random()*obj.length)];
|
||||
while(res == null){
|
||||
res = obj[Math.round(Math.random()*obj.length)];
|
||||
}
|
||||
} else {
|
||||
res = obj;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function aqueousReaction(p1, p2){
|
||||
for(let elem in p1.elemsDissolved){
|
||||
if(elements[elem].reactions != null && p2.element != "water" && elements[elem].reactions[p2.element] != undefined){
|
||||
|
||||
let r = elements[elem].reactions[p2.element];
|
||||
if(r.tempMin && !((p1.temp >= r.tempMin) && (p2.temp >= r.tempMin))){
|
||||
return false;
|
||||
}
|
||||
if(r.tempMax && !((p1.temp <= r.tempMax) && (p2.temp <= r.tempMax))){
|
||||
return false;
|
||||
}
|
||||
if(r.charged && !(p1.charge || p2.charge)){
|
||||
return false;
|
||||
}
|
||||
let c = (r.chance != undefined) ? r.chance : 1;
|
||||
c = c*((p1.elemsDissolved[elem]/100)/elements[elem].solubility.water);
|
||||
if(Math.random() > c){
|
||||
return false;
|
||||
}
|
||||
if(r.aqFunc){
|
||||
r.aqFunc(p1, p2);
|
||||
}
|
||||
if(r.elem1 != undefined){
|
||||
let e = getItem(r.elem1);
|
||||
if(elements[e].solubility != undefined && elements[e].solubility.water != undefined){
|
||||
p1.elemsDissolved[e] = p1.elemsDissolved[elem];
|
||||
p1.elemsDissolved[elem] = undefined;
|
||||
} else {
|
||||
if(e === null){
|
||||
deletePixel(p1.x, p1.y);
|
||||
} else {
|
||||
changePixel(p1, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(r.elem2 != undefined){
|
||||
changePixel(p2, getItem(r.elem2));
|
||||
}
|
||||
if(r.charge1){
|
||||
p1.charge = r.charge1;
|
||||
}
|
||||
if(r.charge2){
|
||||
p2.charge = r.charge2;
|
||||
}
|
||||
if(r.stain1){
|
||||
stainPixel(p1,r.stain1,0.05);
|
||||
}
|
||||
if(r.stain2){
|
||||
stainPixel(p2,r.stain2,0.05);
|
||||
}
|
||||
} else if (p2.element == "water"){
|
||||
for(let e2 in p2.elemsDissolved){
|
||||
if(elements[elem].reactions != undefined && elements[elem].reactions[e2] != undefined){
|
||||
let r = elements[elem].reactions[e2];
|
||||
if(r.tempMin && !((p1.temp >= r.tempMin) && (p2.temp >= r.tempMin))){
|
||||
return false;
|
||||
}
|
||||
if(r.tempMax && !((p1.temp <= r.tempMax) && (p2.temp <= r.tempMax))){
|
||||
return false;
|
||||
}
|
||||
if(r.charged && !(p1.charge || p2.charge)){
|
||||
return false;
|
||||
}
|
||||
let c = (r.chance != undefined) ? r.chance : 1;
|
||||
c = c*((p1.elemsDissolved[elem]/100)/elements[elem].solubility.water);
|
||||
if(Math.random() > c){
|
||||
return false;
|
||||
}
|
||||
if(r.aqFunc){
|
||||
r.aqFunc(p1, p2);
|
||||
}
|
||||
if(r.elem1 != undefined){
|
||||
let e = getItem(r.elem1);
|
||||
if(elements[e].solubility != undefined && elements[e].solubility.water != undefined){
|
||||
p1.elemsDissolved[e] = p1.elemsDissolved[elem];
|
||||
p1.elemsDissolved[elem] = undefined;
|
||||
} else {
|
||||
if(e === null){
|
||||
deletePixel(p1.x, p1.y);
|
||||
} else {
|
||||
changePixel(p1, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(r.elem2 != undefined){
|
||||
let e = getItem(r.elem2);
|
||||
if(elements[e].solubility != undefined && elements[e].solubility.water != undefined){
|
||||
p2.elemsDissolved[e] = p1.elemsDissolved[elem];
|
||||
p2.elemsDissolved[elem] = undefined;
|
||||
} else {
|
||||
if(e === null){
|
||||
deletePixel(p2.x, p2.y);
|
||||
} else {
|
||||
changePixel(p2, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(r.charge1){
|
||||
p1.charge = r.charge1;
|
||||
}
|
||||
if(r.charge2){
|
||||
p2.charge = r.charge2;
|
||||
}
|
||||
if(r.stain1){
|
||||
stainPixel(p1,r.stain1,0.05);
|
||||
}
|
||||
if(r.stain2){
|
||||
stainPixel(p2,r.stain2,0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateColor(pixel){
|
||||
let c = pixel.oColor;
|
||||
for(let element in pixel.elemsDissolved){
|
||||
//if(elements[element].solubility.color != undefined){
|
||||
let color = (elements[element].solubility.color != undefined) ? getItem(elements[element].solubility.color) : getItem(elements[element].color);
|
||||
/*if(Array.isArray(elements[element].solubility.color)){
|
||||
color = elements[element].solubility.color[Math.round(Math.random()*elements[element].solubility.color.length)];
|
||||
while(color == undefined){
|
||||
color = elements[element].solubility.color[Math.round(Math.random()*elements[element].solubility.color.length)];
|
||||
}
|
||||
} else {
|
||||
color = elements[element].solubility.color;
|
||||
}*/
|
||||
if(color.startsWith("#")){
|
||||
color = hexToRGB(color);
|
||||
} else if(color.startsWith("rgb(")){
|
||||
color = getRGB(color);
|
||||
}
|
||||
c = interpolateRgb(getRGB(c), color, ((pixel.elemsDissolved[element]/100)/elements[element].solubility.water) || 0.01);
|
||||
//console.log(rgb, color, getRGB(pixel.oColor), ((pixel.elemsDissolved[elem]/100)/elements[elem].solubility.water));
|
||||
|
||||
}
|
||||
pixel.color = c;
|
||||
//}
|
||||
}
|
||||
function solventTick(pixel) {
|
||||
if(pixel.start = pixelTicks+5){
|
||||
pixel.oColor = pixel.color;
|
||||
}
|
||||
pixel.capacity = (1+((pixel.temp-20)/80))*100;
|
||||
for(let coords of adjacentCoords){
|
||||
let x = pixel.x+coords[0], y = pixel.y+coords[1];
|
||||
let p2 = getPixel(x,y);
|
||||
let total = 0;
|
||||
for(let elem in pixel.elemsDissolved){
|
||||
total += pixel.capacity*((pixel.elemsDissolved[elem]/100)/elements[elem].solubility.water);
|
||||
}
|
||||
if(p2 != null){
|
||||
aqueousReaction(pixel, p2);
|
||||
}
|
||||
if(p2 != null && total < pixel.capacity){
|
||||
if(elements[p2.element].solubility != null && elements[p2.element].solubility[pixel.element] != null){
|
||||
let solubilityObj = elements[p2.element].solubility;
|
||||
p2.dissolved = (p2.dissolved == undefined) ? elements[p2.element].solubility[pixel.element] : p2.dissolved+elements[p2.element].solubility[pixel.element];
|
||||
|
||||
if(pixel.elemsDissolved[p2.element] == undefined){
|
||||
pixel.elemsDissolved[p2.element] = elements[p2.element].solubility[pixel.element];
|
||||
} else {
|
||||
pixel.elemsDissolved[p2.element] += elements[p2.element].solubility[pixel.element];
|
||||
}
|
||||
updateColor(pixel, p2.element);
|
||||
if(solubilityObj.func != undefined){
|
||||
solubilityObj.func(pixel, p2);
|
||||
}
|
||||
if(p2.dissolved >= 100){
|
||||
deletePixel(p2.x, p2.y);
|
||||
}
|
||||
}
|
||||
} else if(total > (pixel.capacity+20) && p2 == null) {
|
||||
let solArr = [], elemArr = [];
|
||||
for(let elem in pixel.elemsDissolved){
|
||||
elemArr.push(elem);
|
||||
solArr.push(elements[elem].solubility[pixel.element]);
|
||||
}
|
||||
let index = solArr.indexOf(Math.min(...solArr));
|
||||
if(isEmpty(x,y) && !outOfBounds(x,y)){
|
||||
createPixel(elemArr[index], x, y);
|
||||
let max = (pixel.elemsDissolved[elemArr[index]] > (total-pixel.capacity)) ? total-pixel.capacity : pixel.elemsDissolved[elemArr[index]];
|
||||
pixelMap[x][y].dissolved = 100-max;
|
||||
updateColor(pixel);
|
||||
pixel.elemsDissolved[elemArr[index]] -= max;
|
||||
}
|
||||
}
|
||||
else if (p2 != null && p2.element == "water"){
|
||||
for(let elem in pixel.elemsDissolved){
|
||||
if(p2.elemsDissolved[elem] == undefined) {p2.elemsDissolved[elem] = 0;};
|
||||
if(p2.elemsDissolved[elem] > pixel.elemsDissolved[elem] && pixel.elemsDissolved[elem]/100 < elements[elem].solubility[pixel.element]){
|
||||
p2.elemsDissolved[elem]--;
|
||||
pixel.elemsDissolved[elem]++;
|
||||
updateColor(pixel);
|
||||
updateColor(p2);
|
||||
} else if (p2.elemsDissolved[elem] < pixel.elemsDissolved[elem] && p2.elemsDissolved[elem]/100 < elements[elem].solubility[pixel.element]) {
|
||||
p2.elemsDissolved[elem]++;
|
||||
pixel.elemsDissolved[elem]--;
|
||||
updateColor(pixel);
|
||||
updateColor(p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pixel.temp >= elements[pixel.element].solventTempHigh){
|
||||
let elem = null;
|
||||
let num = Math.random();
|
||||
if(elem === null){
|
||||
for(let e in pixel.elemsDissolved){
|
||||
if(num <= ((pixel.elemsDissolved[e]/100)/elements[e].solubility.water)){
|
||||
elem = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
elem = (elem == null) ? "steam" : elem;
|
||||
changePixel(pixel, elem);
|
||||
pixel.dissolvedElems = {};
|
||||
}
|
||||
}
|
||||
behaviors.SOLVENT = function(pixel){
|
||||
let visc = 0;
|
||||
for(let elem in pixel.elemsDissolved){
|
||||
if(elements[elem].solubility.visc != undefined){
|
||||
visc += ((pixel.elemsDissolved[elem]/100)/elements[elem].solubility[pixel.element])*elements[elem].solubility.visc;
|
||||
}
|
||||
}
|
||||
if(elements[pixel.element].viscosity != undefined){
|
||||
visc = visc*(elements[pixel.element].viscosity/1000);
|
||||
}
|
||||
let chance = 1-(visc/1000);
|
||||
let dir = (Math.random()<chance) ? (Math.random() < 0.5) ? 1 : -1 : 0;
|
||||
if(!tryMove(pixel, pixel.x+dir, pixel.y+1) && !tryMove(pixel, pixel.x, pixel.y+1)){
|
||||
tryMove(pixel, pixel.x+dir, pixel.y);
|
||||
}
|
||||
}
|
||||
elements.water.tick = solventTick;
|
||||
elements.water.behavior = behaviors.SOLVENT;
|
||||
elements.water.tempHigh = undefined;
|
||||
elements.water.solventTempHigh = 100;
|
||||
}, true);
|
||||
Loading…
Reference in New Issue