Various things, including alchem.js

Added alchem.js and sturdier powders. Fixed some chem.js and world_gen_test.js bugs
This commit is contained in:
lllllllllwith10ls 2024-05-28 15:11:33 -05:00
parent fb0cc8072f
commit 6db289319b
4 changed files with 1121 additions and 75 deletions

368
mods/alchem.js Normal file
View File

@ -0,0 +1,368 @@
initialElements = ["water","dirt","fire","oxygen"];
function findReachable(elems) {
let redo = true;
for(let i = 0; i < elems.length; i++)
{
if(redo)
{
i = 0;
}
redo = false;
let e1 = elems[i];
if(e1 === "mushroom_gill") {
redo = redo || addElement(elems, "mushroom_cap");
}
if(e1 === "thorium" && elems.includes("neutron")) {
redo = redo || addElement(elems, "radium");
}
if(elements[e1].burnInto) {
redo = redo || addElement(elems, elements[e1].burnInto);
}
if(elements[e1].stateHigh) {
redo = redo || addElement(elems, elements[e1].stateHigh);
}
if(elements[e1].stateLow) {
redo = redo || addElement(elems, elements[e1].stateLow);
}
if(elements[e1].breakInto) {
redo = redo || addElement(elems, elements[e1].breakInto);
}
if(elements[e1].extraTempLow) {
for(let i in elements[e1].extraTempLow) {
redo = redo || addElement(elems, elements[e1].extraTempLow[i]);
}
}
if(elements[e1].behavior && elements[e1].behavior instanceof Array) {
let behavior = elements[e1].behavior;
for(let i = 0; i < behavior.length; i++)
{
for(let j = 0; j < behavior[i].length; j++)
{
let b0 = behavior[i][j].split(" AND ");
for (var k = 0; k < b0.length; k++) {
var b = b0[k];
// remove everything after %
b = b.split("%")[0];
if (b.indexOf(":") != -1) {
var arg = b.split(":")[1];
}
else { var arg = undefined }
var b = b.split(":")[0];
if (b == "CR" || b == "CH" || b == "LB" || b == "L1" || b == "L2" || b == "C2") {
if (!arg) { arg = "[???]" }
else if (arg.indexOf(">") != -1) { arg = arg.split(">")[1]; }
redo = redo || addElement(elems, arg.split(","));
}
}
}
}
}
for(let j in elements[e1].reactions)
{
if(elems.includes(j)) {
if(elements[e1].reactions[j].elem1) {
redo = redo || addElement(elems, elements[e1].reactions[j].elem1);
}
if(elements[e1].reactions[j].elem2) {
redo = redo || addElement(elems, elements[e1].reactions[j].elem2);
}
}
}
}
return elems;
}
function addElement(list, elem) {
if(elem instanceof Array)
{
let result = false;
for(let i = 0; i < elem.length; i++)
{
result = result || addElement(list,elem[i]);
}
return result;
}
if(elem && !list.includes(elem)) {
if(elem === "CR") {console.log(elem)};
list.push(elem);
return true;
}
}
let chemMod = document.querySelector("[src=\"mods/chem.js\"]");
// unhide oxygen (air), dirt (earth), fire, and water
function loadAlchem() {
if(!elements.hematite) {
elements.hematite = {
color: ["#e0472f","#bf2a2a","#913920"],
behavior: behaviors.POWDER,
category: "alchemy mod",
density: 5250,
state: "solid",
tempHigh: 1539,
hidden: true
};
elements.molten_hematite = {
reactions: {
"charcoal": { elem1: ["molten_iron","molten_iron","molten_iron","molten_iron","molten_nickel"], elem2: "carbon_dioxide"},
},
};
elements.molten_slag.ignore.push("hematite");
}
elements.molten_pyrite = {
reactions: {
"oxygen": { elem1: "iron", elem2: "sulfur_dioxide"},
},
};
elements.molten_slag.ignore.push("pyrite");
if(!elements.chalcopyrite) {
elements.chalcopyrite = {
color: ["#e8d7cb","#cdc0af","#726153","#8f775e","#bfaea0",],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 4200,
state: "solid",
tempHigh: 950,
hidden: true
};
elements.molten_chalcopyrite = {
reactions: {
"charcoal": { elem1: "molten_copper", elem2: ["molten_slag","molten_slag","sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","molten_iron"]},
},
};
elements.molten_slag.ignore.push("chalcopyrite");
}
if(!elements.sphalerite) {
elements.sphalerite = {
color: ["#7a7a7a","#5c5c5c","#3d3d3d","#363636","#e0e0e0",],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 4090,
state: "solid",
tempHigh: 1850,
hidden: true
};
elements.molten_sphalerite = {
reactions: {
"charcoal": { elem1: "molten_zinc", elem2: ["sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","gallium_gas"]},
},
};
elements.molten_slag.ignore.push("sphalerite");
}
if(!elements.cassiterite) {
elements.cassiterite = {
color: ["#5e5b5b","#705a4d","#826f6f","#333030","#e3d8d1"],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 6950,
state: "solid",
tempHigh: 1630,
hidden: true
};
elements.molten_cassiterite = {
reactions: {
"charcoal": { elem1: "molten_tin", elem2: "carbon_dioxide"},
},
};
elements.molten_slag.ignore.push("cassiterite");
}
if(!elements.galena) {
elements.galena = {
color: ["#e6e6e6","#bdbdbd","#7a7a7a","#737373"],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 7600,
state: "solid",
tempHigh: 1113,
hidden: true
};
elements.molten_galena = {
reactions: {
"charcoal": { elem1: "molten_lead", elem2: "sulfur_dioxide"},
},
};
elements.molten_slag.ignore.push("galena");
}
let ores = Array(5).fill("molten_hematite")
.concat(Array(5).fill("molten_pyrite"))
.concat(Array(5).fill("molten_chalcopyrite"))
.concat(Array(3).fill("molten_cassiterite"))
.concat(Array(5).fill("molten_sphalerite"))
.concat(Array(3).fill("molten_galena"))
.concat(Array(2).fill("molten_rutile"))
.concat(Array(5).fill("molten_bauxite"))
.concat(Array(2).fill("molten_silver"))
.concat(Array(1).fill("molten_gold"))
.concat(Array(3).fill("molten_fluorite"))
.concat(Array(3).fill("molten_uraninite"))
elements.molten_slag.ignore.push("rutile");
elements.molten_slag.ignore.push("bauxite");
elements.molten_slag.ignore.push("silver");
elements.molten_slag.ignore.push("gold");
elements.seltzer.reactions["electric"] =
{ elem1: "water", elem2:"methane"};
elements.carbon_dioxide.reactions["electric"] =
{ elem1:"methane"};
elements.magma.reactions["magma"] =
{ elem2:ores, tempMin:2500, tempMax:3000, chance:0.0001};
if (!settings.alchemyUnlocked) {
settings.alchemyUnlocked = {
"oxygen": true,
"dirt": true,
"fire": true,
"water": true,
};
}
if (settings.unlocked.alchemymod) {
for (var element in settings.unlocked) {
if (settings.unlocked[element]) {
settings.alchemyUnlocked[element] = true
}
}
}
// loop through the elements object
if (elements.explosion) {
elements.explosion.category = "tools";
}
if (elements.room_temp) {
elements.room_temp.category = "tools";
}
if (elements.cook) {
elements.cook.category = "tools";
}
if (elements.incinerate) {
elements.incinerate.category = "tools";
}
for (var element in elements) {
if (elements[element].category === "tools") {
settings.alchemyUnlocked[element] = true;
}
if (settings.alchemyUnlocked[element]) {
elements[element].hidden = false;
if (elements[element].category !== "tools") { elements[element].category = "alchemy mod"; }
}
else if (elements[element].category !== "tools") {
// give the element the hidden attribute true
elements[element].hidden = true;
// set its category to "alchemy mod"
elements[element].category = "alchemy mod";
}
}
// set the unhide setting to Unlock as Discovered (2)
settings.unhide = 2;
runAfterLoad(function(){
checkUnlock = function(element) {
if (elements[element] && elements[element].hidden && !settings.alchemyUnlocked[element]) {
settings.alchemyUnlocked[element] = true;
if (settings.unhide === 2) {
createElementButton(element)
var categoryButton = document.querySelector(".categoryButton[current='true']");
var currentCategory = categoryButton.getAttribute("category");
if (currentCategory !== elements[element].category) {
document.getElementById("categoryButton-"+elements[element].category).classList.add("notify");
}
// add notify to the elementButton of the element
document.getElementById("elementButton-"+element).classList.add("notify");
}
saveSettings();
}
}
})
runAfterAutogen(function(){
for (var element in elements) {
if (elements[element].category === "states") {
elements[element].category = "alchemy mod"
}
}
})
window.addEventListener("load",function(){
for (var element in elements) {
if (elements[element].hidden && document.getElementById("elementButton-"+element)) {
document.getElementById("elementButton-"+element).remove()
}
}
})
runAfterAutogen(function(){
let reachable = findReachable(initialElements);
console.log(reachable.join(","));
let string = "";
for(let i in elements)
{
if(!reachable.includes(i))
{
if(string === "")
{
string = i;
}
else
{
string += "," + i;
}
}
}
console.log(string);
string = "";
for(let i = 0; i < reachable.length; i++)
{
if(!settings.alchemyUnlocked[reachable[i]])
{
if(string === "")
{
string = reachable[i];
}
else
{
string += "," + reachable[i];
}
}
}
console.log(string);
string = "";
for(let i in settings.alchemyUnlocked)
{
if(!reachable.includes(i) && settings.alchemyUnlocked[i] && elements[i].category !== "tools")
{
if(string === "")
{
string = i;
}
else
{
string += "," + i;
}
}
}
console.log(string);
});
}
if(chemMod) {
chemMod.addEventListener("load",loadAlchem);
} else {
loadAlchem();
}

View File

@ -1,7 +1,15 @@
function toObject(color)
{
color = color.match(/\d+/g);
return color;
return {"r":color[0],"g":color[1],"b":color[2]};
}
function RGBToHex2(rgb) {
var r = Math.min(255,parseInt(rgb.r));
var g = Math.min(255,parseInt(rgb.g));
var b = Math.min(255,parseInt(rgb.b));
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function react(elem1,elem2,product1,product2,temp)
@ -18,6 +26,10 @@ function acidReact(elem1,elem2,product1,product2,temp = 0)
{
elements[elem1].ignore.push(...product1);
}
else
{
elements[elem1].ignore.push(product1);
}
}
if(product2 !== null)
{
@ -25,6 +37,10 @@ function acidReact(elem1,elem2,product1,product2,temp = 0)
{
elements[elem1].ignore.push(...product2);
}
else
{
elements[elem1].ignore.push(product2);
}
}
elements[elem1].ignore.push(elem2);
}
@ -245,6 +261,14 @@ elements.hydrofluoric_acid_gas = {
category:"gases",
};
runAfterLoad(function() {
reactList("hydrofluoric_acid", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
reactList("hydrofluoric_acid_gas", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
delete elements.hydrofluoric_acid.reactions["dirty_water"];
delete elements.hydrofluoric_acid_gas.reactions["dirty_water"];
});
elements.hydrogen_fluoride = {
color: "#f2f28d",
behavior: behaviors.GAS,
@ -573,6 +597,12 @@ function createAcid(name,reactions, gasReactions, color, categoryhidden, categor
if(compound == "acid") {
eListAddIon("HYDROGEN", [name, name+"_gas"], compound);
}
runAfterLoad(function() {
reactList(name, eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
reactList(name+"_gas", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
delete elements[name].reactions["dirty_water"];
delete elements[name+"_gas"].reactions["dirty_water"];
});
}
function eListAddIon(listName, itemList, compoundType = "default", priority = 0)
@ -1140,6 +1170,8 @@ elements.hydrogen_sulfide = {
runAfterLoad(function() {
reactList("hydrogen_sulfide", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
delete elements.hydrogen_sulfide.reactions["dirty_water"];
delete elements.hydrogen_sulfide.reactions["iron_dichloride_solution"];
});
acidIgnore(["sulfur_dioxide","liquid_sulfur_dioxide","sulfur_dioxide_ice"]);
@ -1169,6 +1201,9 @@ elements.sulfuric_acid_gas.ignore.push("charcoal");
runAfterLoad(function() {
reactList("sulfuric_acid", eLists.WATER, { "elem2":"dirty_water"});
reactList("sulfuric_acid_gas", eLists.WATER, { "elem2":"dirty_water"});
delete elements.sulfuric_acid.reactions["dirty_water"];
delete elements.sulfuric_acid_gas.reactions["dirty_water"];
});
elements.sulfuric_acid.reactions["grape"] = { "elem1": "charcoal", "elem2": "steam", "temp2": 200};
elements.sulfuric_acid.reactions["juice"] = { "elem1": "charcoal", "elem2": "steam", "temp2": 200};
@ -1553,9 +1588,9 @@ elements.titanium_tetrachloride = {
density: 1728,
state: "liquid",
tempHigh: 136.4,
stateHigh: "titanium_tetrachloride_gas",
stateHighName: "titanium_tetrachloride_gas",
tempLow: -24,
stateLow: "solid_titanium_tetrachloride",
stateLowName: "solid_titanium_tetrachloride",
};
eListAddIon("TITANIUMIV","solid_titanium_tetrachloride");
eListAddIon("CHLORIDE","solid_titanium_tetrachloride");
@ -1727,16 +1762,18 @@ elements.molten_astatine = {
tempHigh: 336,
};
elements.astatine_gas = {
behavior: [
"M2|M1 AND CR:radiation%50|M2",
"M1 AND CR:radiation%50|CH:polonium,big_pop%0.1|M1 AND CR:radiation%50",
"M2|M1 AND CR:radiation%50|M2",
behavior: behaviors.GAS,
behavior2: [
["XX","CR:radiation%50","XX"],
["CR:radiation%50","CH:polonium,big_pop%0.1","CR:radiation%50"],
["XX","CR:radiation%50","XX"]
],
reactions: {
"quark_matter": { "elem1":"molten_stable_astatine", "elem2":"quark_matter"}
},
tick: function(pixel) {
pixel.temp += 5;
pixelTick(pixel,elements[pixel.element].behavior2);
}
}
@ -1780,7 +1817,7 @@ elements.polonium = {
elements.molten_polonium = {
color: ["#ace638","#acb838","#ac8a00"],
behavior: [
"XX|CR:fire,CR:radiation%12.5|XX",
"XX|CR:fire AND CR:radiation%12.5|XX",
"M2 AND CR:radiation%10|CH:lead%0.1|M2 AND CR:radiation%10",
"M1|M1|M1",
],
@ -1904,6 +1941,9 @@ eLists.ACIDGAS.push("hydroastatic_acid_gas");
runAfterLoad(function() {
reactList("hydroastatic_acid", eLists.WATER, {"elem2":"dirty_water"});
reactList("hydroastatic_acid_gas", eLists.WATER, {"elem2":"dirty_water"});
delete elements.hydroastatic_acid.reactions["dirty_water"];
delete elements.hydroastatic_acid_gas.reactions["dirty_water"];
});
elements.polonium_dioxide = {
@ -2323,7 +2363,9 @@ elements.silver_bromide = {
if(!isEmpty(k,l,true) && pixelMap[k][l].element === "silver_bromide")
{
if(distance <= 0) {console.log("a");}
pixelMap[k][l].color = pixelColorPick(pixelMap[k][l],blendColors(RGBToHex(toObject(pixelMap[k][l].color)),RGBToHex(toObject(pixelMap[pixel.x+i][pixel.y+j].color)),1/distance));
let rgb = hexToRGB(blendColors(RGBToHex2(toObject(pixelMap[k][l].color)),RGBToHex2(toObject(pixelMap[pixel.x+i][pixel.y+j].color)),10/(10+distance)));
pixelMap[k][l].color = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")";
//pixelMap[k][l].color = pixelColorPick(pixelMap[k][l],blendColors(RGBToHex2(toObject(pixelMap[k][l].color)),RGBToHex2(toObject(pixelMap[pixel.x+i][pixel.y+j].color)),1/distance));
}
}
if(pixelMap[pixel.x+i][pixel.y+j].element === "light" || pixelMap[pixel.x+i][pixel.y+j].element === "laser")
@ -2699,6 +2741,9 @@ eListAddIon("HYDROGEN","hydroiodic_acid_gas");
eListAddIon("IODIDE","hydroiodic_acid_gas");
runAfterLoad(function() {
reactList("hydroiodic_acid", eLists.WATER, { "elem2":"dirty_water"});
reactList("hydroiodic_acid_gas", eLists.WATER, { "elem2":"dirty_water"});
delete elements.hydroiodic_acid.reactions["dirty_water"];
delete elements.hydroiodic_acid_gas.reactions["dirty_water"];
});
@ -3053,11 +3098,10 @@ elements.liquid_boron_trichloride = {
runAfterLoad(function() {
reactList("fluoroboric_acid", eLists.WATER, { "elem2": "dirty_water" });
});
runAfterLoad(function() {
reactList("fluoroboric_acid_gas", eLists.WATER, { "elem2": "dirty_water" });
reactList("fluoroboric_acid", eLists.WATER, { "elem2":"dirty_water"});
reactList("fluoroboric_acid_gas", eLists.WATER, { "elem2":"dirty_water"});
delete elements.fluoroboric_acid.reactions["dirty_water"];
delete elements.fluoroboric_acid_gas.reactions["dirty_water"];
});
createAcid("fluoroboric_acid",{},{},["#3bffdb","#00caaf","#56c4a3"],true,true,100,100,0,1000,1020,1,"TETRAFLUOROBORATE")
@ -3175,7 +3219,7 @@ runAfterLoad(function() {
});
eLists.CAUSTIC.push("sodium_hydride");
elements.sodium_hydride.ignore = defaultAcidIgnore.concat(eLists.CAUSTICIGNORE);
elements.sodium_hydride.ignore = defaultAcidIgnore.concat(eLists.CAUSTICIGNORE).concat(["sodium","molten_sodium","hydrogen"]);
acidIgnore(["sodium_hydride"]);
elements.molten_sodium.reactions.hydrogen = { elem1: "sodium_hydride", elem2: null};
@ -3575,6 +3619,7 @@ elements.depleted_uranium = {
runAfterLoad(function() {
reactList("depleted_uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.depleted_uranium.reactions["dirty_water"];
});
@ -3617,10 +3662,12 @@ elements.enriched_uranium = {
runAfterLoad(function() {
reactList("enriched_uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.enriched_uranium.reactions["dirty_water"];
});
runAfterLoad(function() {
reactList("uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.uranium.reactions["dirty_water"];
});
@ -3677,6 +3724,7 @@ elements.stable_uranium = {
};
runAfterLoad(function() {
reactList("stable_uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.stable_uranium.reactions["dirty_water"];
});
elements.uranium.reactions["oxygen"] = { elem1:"uranium_dioxide", elem2: null, chance:0.1};
@ -3813,7 +3861,7 @@ function reduce(element, element2, result) {
"molten_magnesium": { elem1: result, elem2: "magnesium_fluoride"},
"molten_calcium": { elem1: result, elem2: "fluorite"},
"molten_sodium": { elem1: result, elem2: "sodium_fluoride"},
"molten_sodium": { elem1: result, elem2: "potassium_fluoride"},
"molten_potassium": { elem1: result, elem2: "potassium_fluoride"},
});
}
}
@ -4360,9 +4408,9 @@ elements.stable_plutonium = {
runAfterLoad(function() {
reactList("plutonium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
});
runAfterLoad(function() {
delete elements.plutonium.reactions["dirty_water"];
reactList("stable_plutonium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.stable_plutonium.reactions["dirty_water"];
});
elements.plutonium_dioxide = {
@ -5512,12 +5560,11 @@ if(!elements.caustic_soda.reactions)
{
elements.caustic_soda.reactions = {};
}
elements.caustic_soda.reactions["water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["salt_water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["sugar_water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["dirty_water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["seltzer"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["pool_water"] = { elem1:"sodium_hydroxide", elem2:null };
runAfterLoad(function() {
reactList("caustic_soda", eLists.WATER, { elem1:"sodium_hydroxide", elem2:null });
delete elements.sodium_hydroxide.reactions["sodium_aluminate_solution"];
delete elements.sodium_hydroxide_gas.reactions["sodium_aluminate_solution"];
});
elements.sodium_hydroxide_gas.tempHigh = 150;
elements.sodium_hydroxide_gas.stateHigh = ["caustic_soda","steam"];
@ -5543,13 +5590,9 @@ if(!elements.caustic_potash.reactions)
{
elements.caustic_potash.reactions = {};
}
elements.caustic_potash.reactions["water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["salt_water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["sugar_water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["dirty_water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["seltzer"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["pool_water"] = { elem1:"potassium_hydroxide", elem2:null };
runAfterLoad(function() {
reactList("caustic_potash", eLists.WATER, { elem1:"potassium_hydroxide", elem2:null });
});
elements.potassium_hydroxide_gas.tempHigh = 150;
elements.potassium_hydroxide_gas.stateHigh = ["caustic_potash","steam"];
@ -5564,6 +5607,12 @@ elements.red_mud.reactions.seltzer = {"elem2":"dirty_water" };
elements.red_mud.reactions.pool_water = {"elem2":"dirty_water" };
elements.red_mud.reactions.primordial_soup = {"elem2":"dirty_water" };
runAfterLoad(function() {
reactList("red_mud", eLists.WATER, { elem2: "dirty_water" });
delete elements.red_mud.reactions["dirty_water"];
delete elements.red_mud.reactions["sodium_aluminate_solution"];
});
acidReact("potassium_hydroxide","fertilizer","niter","ammonia",10);
acidReact("potassium_hydroxide_gas","fertilizer","niter","ammonia",10);
@ -5934,10 +5983,10 @@ eListAddIon("BICARBONATE","baking_soda","base");
eListAddIon("SODIUM","baking_soda_solution","base");
eListAddIon("BICARBONATE","baking_soda_solution","base");
elements["baking_soda"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda_solution"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda_solution"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: null};
elements["baking_soda"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: null};
elements["baking_soda_solution"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: null};
elements["baking_soda_solution"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: null};
createSalt("sodium_acetate","sodium_acetate_solution",["#f2f2f2","#e0e0e0"],"#7ea2f2",false,true,292,-2,102,3980,1028,"SODIUM","ACETATE");
@ -6035,7 +6084,6 @@ runAfterAutogen(function() {
let i = eLists.WATER[ii];
if(!elements[i])
{
console.log(i);
continue;
}
if(!elements[i].reactions)
@ -6106,11 +6154,11 @@ runAfterAutogen(function() {
if(productsA.length > 0 && productsB.length > 0)
{
acidReact(i,j,productsA,productsB,0);
console.log("precipitate");
console.log(i);
console.log(j);
console.log(productsA);
console.log(productsB);
//console.log("precipitate");
//console.log(i);
//console.log(j);
//console.log(productsA);
//console.log(productsB);
priorityA = elements[i].salt[iii].priority;
priorityB = elements[j].salt[jjj].priority;
continue;
@ -6142,10 +6190,10 @@ runAfterAutogen(function() {
if(productsA.length > 0 && productsB.length > 0)
{
elements[i].reactions[j] = { elem1:productsA, elem2:productsB, chance:0.001, oneway:true };
console.log(i);
console.log(j);
console.log(productsA);
console.log(productsB);
//console.log(i);
//console.log(j);
//console.log(productsA);
//console.log(productsB);
priorityA = elements[i].salt[iii].priority;
priorityB = elements[j].salt[jjj].priority;
}
@ -6161,7 +6209,6 @@ runAfterAutogen(function() {
let i = acids[ii];
if(!elements[i])
{
console.log(i);
continue;
}
if(!elements[i].reactions)
@ -6234,14 +6281,36 @@ runAfterAutogen(function() {
reactionTemp = 50;
}
acidReact(i,j,productsA,productsB,reactionTemp);
console.log("neutral");
console.log(i);
console.log(j);
console.log(compounds);
console.log(productsA);
console.log(productsB);
if(elements[j].reactions && elements[j].reactions[i]) {
delete elements[j].reactions[i];
}
for(let k = 0; k < productsA.length; k++)
{
if(elements[j].reactions && elements[j].reactions[productsA[k]]) {
delete elements[j].reactions[productsA[k]];
}
if(elements[i].reactions && elements[i].reactions[productsA[k]]) {
delete elements[i].reactions[productsA[k]];
}
}
for(let k = 0; k < productsB.length; k++)
{
if(elements[j].reactions && elements[j].reactions[productsB[k]]) {
delete elements[j].reactions[productsB[k]];
}
if(elements[i].reactions && elements[i].reactions[productsB[k]]) {
delete elements[i].reactions[productsB[k]];
}
}
//console.log("neutral");
//console.log(i);
//console.log(j);
//console.log(compounds);
//console.log(productsA);
//console.log(productsB);
}
}
}
delete elements["molten_iodine_ice"];
}
});

595
mods/sturdierpowders.js Normal file
View File

@ -0,0 +1,595 @@
tryMove = function(pixel,nx,ny,leaveBehind,force) {
if (pixel.drag && !force) { return true; }
var info = elements[pixel.element];
var oob = outOfBounds(nx,ny);
if (isEmpty(nx,ny,false,oob)) { // If coords is empty, move to coords
if(Math.random() > (elements[newPixel.element].friction ? elements[newPixel.element].friction : 0.02))
{
pixel.grounded = true;
}
else
{
pixel.grounded = false;
}
movePixel(pixel,nx,ny,leaveBehind);
return true;
}
else if (!oob) {
// Reactions
newPixel = pixelMap[nx][ny];
if(!pixel.grounded && Math.random() > (elements[newPixel.element].friction ? elements[newPixel.element].friction : 0.02)) {
newPixel.grounded = false;
}
if(Math.random() > (elements[newPixel.element].friction ? elements[newPixel.element].friction : 0.02))
{
pixel.grounded = true;
}
var rr1 = false;
if (info.reactions !== undefined && info.reactions[newPixel.element] !== undefined) {
rr1 = reactPixels(pixel,newPixel)
if (rr1) {
return true;
}
}
if (!rr1 && elements[newPixel.element].reactions !== undefined && elements[newPixel.element].reactions[pixel.element] !== undefined && !elements[newPixel.element].reactions[pixel.element].oneway) {
if (reactPixels(newPixel,pixel)) {
return true;
}
}
// Density
if (elements[pixel.element].id !== elements[newPixel.element].id) {
if (info.density !== undefined && elements[newPixel.element].density !== undefined) {
// if the pixel's state + ">" + newPixel's state is in validDensitySwaps, and the pixel's density is larger than the newPixel's density, swap the pixels
if (validDensitySwaps[info.state][elements[newPixel.element].state] && info.density >= elements[newPixel.element].density) {
// chance depending on the difference in density
if (Math.random() < (info.density - elements[newPixel.element].density)/(info.density + elements[newPixel.element].density)) {
swapPixels(pixel,newPixel);
return true;
}
}
}
}
// else { // same-element density swapping
// if (info.density !== undefined) {
// if (validDensitySwaps[info.state][info.state]) {
// if (Math.random() < 0.01) {
// swapPixels(pixel,newPixel);
// return true;
// }
// }
// }
// }
}
return false;
}
function pixelTick(pixel,custom=null) {
if (pixel.start === pixelTicks) {return}
if (elements[pixel.element] === undefined) {
pixel.invalidElement = pixel.element;
changePixel(pixel,"unknown");
return;
}
var info = elements[pixel.element];
if (custom) { var behavior = custom; }
else if (pixel.charge && info.behaviorOn) { var behavior = info.behaviorOn; }
else { var behavior = info.behavior; }
if (pixel.flipX) { behavior = flipBehavior(behavior,"x"); }
if (pixel.flipY) { behavior = flipBehavior(behavior,"y"); }
if (pixel.r) { behavior = rotateBehavior(behavior,pixel.r); }
var x = pixel.x;
var y = pixel.y;
var move1Spots = [];
var move2Spots = [];
var supportSpots = [];
var swapSpots = [];
var leaveBehind = null;
var leaveBehind1 = null;
var leaveBehind2 = null;
var move = true;
// Parse behavior
for (var by = 0; by < behavior.length; by++) {
var behaviorby = behavior[by];
for (var bx = 0; bx < behaviorby.length; bx++) {
var b0 = behaviorby[bx];
if (b0 === "XX") {continue}
//if (b.includes(" OR ")) {
// b = b.split(" OR ")[Math.floor(Math.random()*b.split(" OR ").length)];
//}
// Loop through b0.split(" AND ")
if (b0.indexOf(" AND ") !== -1) { var andsplit = b0.split(" AND "); }
else { var andsplit = [b0]; }
for (var i = 0; i < andsplit.length; i++) {
var b = andsplit[i];
if (b.indexOf(":") !== -1) {
var arg = b.split(":")[1].split(/[\:\%]/)[0];
if (b.indexOf("%") === -1) {
b = b.split(/[\:\%]/)[0];
}
}
else { var arg = null;}
// If b has "%" followed by a number in it, it's a chance to move
if (b.indexOf("%") !== -1) {
// Split the string at the "%" and use the second half as the chance (float)
var chance = parseFloat(b.split("%")[1]);
//console.log(b+": "+(Math.random()*100 < chance));
b = b.split(/[\:\%]/)[0];
}
else { var chance = 100; }
if (chance===100 || Math.random()*100 < chance) {
var newCoords = behaviorCoords(x,y,bx,by);
switch (b) {
default: break;
case "M1":
if (info.viscosity !== undefined) {
if (!((Math.random()*100) < 100 / Math.pow(info.viscosity, 0.25))) {
newCoords.x = x;
}
}
move1Spots.push(newCoords);
break;
case "M2":
if (pixel.grounded || info.viscosity !== undefined) {
if (!((Math.random()*100) < 100 / Math.pow(info.viscosity, 0.25))) {
newCoords.x = x;
}
}
move2Spots.push(newCoords);
break;
case "SP":
supportSpots.push({x:newCoords.x,y:newCoords.y,arg:arg});
break;
case "SA":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
move = false;
}
break;
case "DL":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
// if the pixel at newCoords is the same element as the pixel, ignore
newPixel = pixelMap[newCoords.x][newCoords.y];
// if info.ignore exists and newPixel.element is in it
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if ((!(newPixel.element == pixel.element)) || (newCoords.x == x && newCoords.y == y)) {
if (arg != null) { var args = arg.split(","); }
if (arg == null || args.indexOf(newPixel.element) !== -1) {
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness) {
deletePixel(newCoords.x,newCoords.y);
if (newCoords.x == x && newCoords.y == y) {
var deleted = true;
}
swapSpots = [];
}
}
}
}
break;
case "DB":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
// if the pixel at newCoords is the same element as the pixel, ignore
newPixel = pixelMap[newCoords.x][newCoords.y];
// if info.ignore exists and newPixel.element is in it
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (!(newPixel.element == pixel.element)) {
if (arg != null) { var args = arg.split(","); }
if (arg == null || args.indexOf(newPixel.element) !== -1) {
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness) {
deletePixel(newCoords.x,newCoords.y);
if (pixelMap[pixel.x][pixel.y] != undefined) {
deletePixel(pixel.x,pixel.y);
}
var deleted = true;
swapSpots = [];
}
}
}
}
break;
case "CH":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness || (newCoords.x == x && newCoords.y == y)) {
if (arg.indexOf(">") !== -1) {
var argfrom = arg.split(">")[0];
if (argfrom.indexOf(",") !== -1) {
if (argfrom.split(",").indexOf(newPixel.element) === -1) {
continue;
}
}
else if (argfrom !== newPixel.element) {
continue;
}
var argto = arg.split(">")[1];
}
else {
var argfrom = null;
var argto = arg;
}
if (argto.indexOf(",") !== -1) {
var argto = argto.split(",")[Math.floor(Math.random()*argto.split(",").length)];
}
if (elements[argto]) {
if (elements[newPixel.element].id !== elements[argto].id) {
changePixel(newPixel,argto);
}
}
}
}
break;
case "SW":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (arg != null) { var args = arg.split(","); }
if (arg == null || args.indexOf(newPixel.element) !== -1) {
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness) {
swapSpots.push({x:newCoords.x,y:newCoords.y});
}
}
}
break;
case "CR":
if (isEmpty(newCoords.x,newCoords.y)) {
if (arg == null) {
arg = pixel.element;
}
else if (arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (elements[arg]) {
createPixel(arg,newCoords.x,newCoords.y);
if (info.fireColor && arg==="fire") {
pixelMap[newCoords.x][newCoords.y].color = pixelColorPick(pixelMap[newCoords.x][newCoords.y],info.fireColor);
}
pixelMap[newCoords.x][newCoords.y].temp = pixel.temp
pixelTempCheck(pixelMap[newCoords.x][newCoords.y]);
}
}
break;
case "CL":
if (isEmpty(newCoords.x,newCoords.y)) {
if (arg == null || pixel.temp >= parseFloat(arg)) {
clonePixel(pixel,newCoords.x,newCoords.y);
}
}
break;
case "CF":
if (pixel.clone) {
if (isEmpty(newCoords.x,newCoords.y)) {
createPixel(pixel.clone,newCoords.x,newCoords.y);
pixelMap[newCoords.x][newCoords.y].temp = pixel.temp;
pixelTempCheck(pixelMap[newCoords.x][newCoords.y]);
}
}
else {
if (!isEmpty(newCoords.x,newCoords.y,true)) {
newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (newPixel.element != pixel.element && newPixel.element != "wire") {
pixel.clone = newPixel.element;
pixel.temp = newPixel.temp;
}
else if (newPixel.clone) {
pixel.clone = newPixel.clone;
pixel.temp = newPixel.temp;
}
}
}
break;
case "SH":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
var con = elements[newPixel.element].conduct;
if (con != undefined) {
if (Math.random() < con) { // If random number is less than conductivity
if (!newPixel.charge && !newPixel.chargeCD && (arg == null || newPixel.element == arg)) {
newPixel.charge = (parseFloat(arg) || 1);
if (elements[newPixel.element].colorOn) {
newPixel.color = pixelColorPick(newPixel);
}
}
}
}
}
break;
case "ST": //Stick
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (newPixel.element != pixel.element && (arg == null || newPixel.element == arg)) {
var sticking = true
}
}
break;
case "LB":
case "L1":
case "L2":
if (arg != null && arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (elements[arg]) {
if (b=="LB") {leaveBehind = arg;}
else if (b=="L1") {leaveBehind1 = arg;}
else if (b=="L2") {leaveBehind2 = arg;}
}
break;
case "CC":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (arg == null) {arg = newPixel.colorObject}
else {
if (arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (!arg.startsWith("#")) {
arg = "#" + arg;
}
}
newPixel.color = pixelColorPick(newPixel,arg);
}
break;
case "HT":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
// if the element isn't the same or the coords ARE the same
if (!(newPixel.element == pixel.element) || (newCoords.x == pixel.x && newCoords.y == pixel.y)) {
if (arg != null) {arg = parseFloat(arg)}
else {arg = 1}
if (isNaN(arg)) {arg = 1}
newPixel.temp += arg;
pixelTempCheck(newPixel);
}
}
break;
case "CO":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (!(newPixel.element == pixel.element) || (newCoords.x == pixel.x && newCoords.y == pixel.y)) {
if (arg != null) {arg = parseFloat(arg)}
else {arg = 1}
if (isNaN(arg)) {arg = 1}
newPixel.temp -= arg;
pixelTempCheck(newPixel);
}
}
break;
case "FX":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (elements[newPixel.element].flippableX) {
if (arg === "0") { newPixel.flipX = false; }
else if (arg === "1") { newPixel.flipX = true; }
newPixel.flipX = !newPixel.flipX;
}
}
break;
case "FY":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (elements[newPixel.element].flippableY) {
if (arg === "0") { newPixel.flipY = false; }
else if (arg === "1") { newPixel.flipY = true; }
else { newPixel.flipY = !newPixel.flipY; }
}
}
break;
case "RT":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
// If arg isn't null, set arg to a random choice from arg.split(",")
if (arg != null && arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (elements[newPixel.element].rotatable) {
newPixel.r = ((newPixel.r||0) + (parseInt(arg)||1)) % 4;
}
}
break;
case "BO":
if (!isEmpty(newCoords.x,newCoords.y) && (outOfBounds(newCoords.x,newCoords.y) || elements[pixelMap[newCoords.x][newCoords.y].element].id === elements[pixel.element].id || elements[pixelMap[newCoords.x][newCoords.y].element].state === "solid")) {
if (info.flippableX) {
pixel.flipX = !pixel.flipX;
}
if (info.flippableY) {
pixel.flipY = !pixel.flipY;
}
if (info.rotatable) {
// If arg isn't null, set arg to a random choice from arg.split(",")
if (arg != null && arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (pixel.r !== undefined) {
pixel.r = (pixel.r + (parseInt(arg)||2)) % 4;
}
else { pixel.r = (parseInt(arg)||2); }
}
}
break;
case "C2":
if (arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
var C2 = arg;
break;
case "EX":
if (!isEmpty(newCoords.x,newCoords.y)) {
if (outOfBounds(newCoords.x,newCoords.y) || (newCoords.x == x && newCoords.y == y) || (pixel.element !== pixelMap[newCoords.x][newCoords.y].element && elements[pixelMap[newCoords.x][newCoords.y].element].state !== "gas")) {
// if arg contains ">", var fire = everything after it, arg = everything before it
if (arg.indexOf(">") !== -1) {
var fire = arg.split(">")[1];
arg = arg.split(">")[0];
}
else { var fire = "fire" }
// arg = a number
if (arg != null) {
arg = parseInt(arg);
if (isNaN(arg)) {arg = 3}
}
else {arg = 3}
explodeAt(x,y,arg,fire);
if (!pixel.del && info.hardness !== 1) {
deletePixel(x,y);
var deleted = true;
}
swapSpots = [];
}
}
break;
}
}
}
}
}
if (typeof deleted !== "undefined") {return;}
if (supportSpots.length > 0) {
var supportCount = 0;
var allEmpty = true;
for (var i = 0; i < supportSpots.length; i++) {
var bx = supportSpots[i].x;
var by = supportSpots[i].y;
var arg = supportSpots[i].arg;
if (!isEmpty(bx,by,true)) {
if (info.ignore && info.ignore.indexOf(pixelMap[bx][by].element) !== -1) {continue;}
if ((arg == null && !validDensitySwaps[info.state][elements[pixelMap[bx][by].element].state]) || pixelMap[bx][by].element == arg) {
supportCount++;
}
}
}
if (supportCount == supportSpots.length) {
move = false;
}
}
var moved = false;
if (swapSpots.length > 0) {
var coords = swapSpots[Math.floor(Math.random()*swapSpots.length)];
if (pixelMap[coords.x][coords.y] != undefined) {
swapPixels(pixel,pixelMap[coords.x][coords.y]);
move = false;
moved = true;
}
}
if (typeof sticking !== "undefined") {
move = false;
}
// Move First Priority
if (move) {
if (move1Spots.length > 0) {
// While move1Spots is not empty
while (move1Spots.length > 0) {
// coords = random item of move1Spots
var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)];
var nx = coords.x;
var ny = coords.y;
moved = tryMove(pixel,nx,ny,leaveBehind1 || leaveBehind);
if (moved) {
break;
}
else {
// remove coords from move1Spots
move1Spots.splice(move1Spots.indexOf(coords),1);
}
}
}
// Move Second Priority
if (!moved && move2Spots.length > 0) {
// While move2Spots is not empty
while (move2Spots.length > 0) {
// coords = random item of move2Spots
var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)];
var nx = coords.x;
var ny = coords.y;
moved = tryMove(pixel,nx,ny,leaveBehind2 || leaveBehind);
if (moved) {
if (typeof C2 !== "undefined" && elements[C2]) {
changePixel(pixel,C2);
}
break;
}
else {
// remove coords from move2Spots
move2Spots.splice(move2Spots.indexOf(coords),1);
}
}
}
}
doAirDensity(pixel);
// Change tempearture if needed (unused)
/*if (info.tempChange != undefined) {
pixel.temp += info.tempChange;
pixelTempCheck(pixel);
}*/
// Burning
doBurning(pixel);
// Heat Transfer
if (info.insulate !== true) {
doHeat(pixel);
}
// Electricity Transfer
doElectricity(pixel);
// Staining
if (info.stain) {
doStaining(pixel);
}
}
behaviors.POWDER2 = function(pixel) {
if (pixel.start === pixelTicks) {return}
if (pixel.charge && elements[pixel.element].behaviorOn) {
pixelTick(pixel)
}
console.log(pixel.grounded);
if (!pixel.grounded) {
if(!tryMove(pixel, pixel.x, pixel.y+1)) {
if (Math.random() < 0.5) {
if (!tryMove(pixel, pixel.x+1, pixel.y+1)) {
tryMove(pixel, pixel.x-1, pixel.y+1);
}
} else {
if (!tryMove(pixel, pixel.x-1, pixel.y+1)) {
tryMove(pixel, pixel.x+1, pixel.y+1);
}
}
}
}
else
{
tryMove(pixel, pixel.x, pixel.y+1);
}
doDefaults(pixel);
}
runAfterLoad(function() {
for(let i in elements) {
if(elements[i].behavior === behaviors.POWDER) {
elements[i].behavior = behaviors.POWDER2;
}
}
});

View File

@ -50,7 +50,7 @@ var Simple1DNoise = function() {
};
};
function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, scale1, scale2) {
function newHeightMap(pixelType, pixelType2, offset, amplitudes, scales) {
return {
color: "#000000",
behavior: behaviors.WALL,
@ -61,22 +61,23 @@ function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, sca
pixelType: pixelType,
pixelType2: pixelType2,
offset: offset,
amplitude1: amplitude1,
amplitude2: amplitude2,
scale1: scale1,
scale2: scale2,
generator: new Simple1DNoise(),
generator2: new Simple1DNoise(),
amplitudes: amplitudes,
scales: scales,
generator: Array.from({length: amplitudes.length}, () => new Simple1DNoise()),
excludeRandom: true,
heightMap: true,
tick: function(pixel) {
generator = this.generator;
generator2 = this.generator2;
generator.setAmplitude(this.amplitude1);
generator.setScale(this.scale1);
generator2.setAmplitude(this.amplitude2);
generator2.setScale(this.scale2);
let value = generator.getVal(pixel.x/width) + generator2.getVal(pixel.x/width);
if(value + this.offset < pixel.y/height) {
let generator = this.generator;
for(let i = 0; i < generator.length; i++)
{
generator[i].setAmplitude(this.amplitudes[i]);
generator[i].setScale(this.scales[i]);
}
let value = generator.reduce((accumulator, val) => {
return accumulator + val.getVal(pixel.x/width);
console.log(accumulator);
},0);
if(value + this.offset + generateTerrainHeights() < pixel.y/height) {
let element = this.pixelType;
if(Array.isArray(element))
{
@ -87,6 +88,10 @@ function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, sca
deletePixel(pixel.x,pixel.y);
} else {
changePixel(pixel,element);
if(elements[element].heightMap)
{
elements[element].tick(pixel);
}
}
} else {
let element = this.pixelType2;
@ -99,15 +104,24 @@ function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, sca
deletePixel(pixel.x,pixel.y);
} else {
changePixel(pixel,element);
if(elements[element].heightMap)
{
elements[element].tick(pixel);
}
}
}
}
};
}
elements.dunes_height_map = newHeightMap("sand", null, 0, 0.75, 0.05, 2.5, 20);
elements.oasis_height_map = newHeightMap("sand", "water_height", 0.25, 0.75, 0.05, 2.5, 20);
elements.water_height = newHeightMap("water", null, 0.5, 0, 0, 1, 1);
elements.dunes_height_map = newHeightMap("sand", null, 0.25, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.oasis = newHeightMap("water_height", "oasis_height_map", 0.5, [0.02], [200]);
elements.oasis_height_map = newHeightMap("sand", null, 0.25, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.oasis_height_map2 = newHeightMap("sand", "packed_sand", 0.28, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.oasis_height_map2.generator = elements.oasis_height_map.generator;
elements.water_height = newHeightMap("oasis_height_map2", "water", 0.25, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.water_height.generator = elements.oasis_height_map.generator;
worldgentypes.dunes = {
fill: [
[0, "dunes_height_map"]
@ -115,21 +129,21 @@ worldgentypes.dunes = {
};
worldgentypes.oasis = {
fill: [
[0, "oasis_height_map"]
[0, "oasis"]
]
};
if (enabledMods.includes("mods/chem.js")) {
elements.ptfe_height_map = newHeightMap("polytetrafluoroethylene", "foof_height", 0.25, 0.75, 0.05, 2.5, 20);
elements.foof_height = newHeightMap("FOOF", Array(100).fill(null).concat(["oxygen","fluorine"]), 0.5, 0, 0, 1, 1);
elements.ptfe_height_map = newHeightMap("polytetrafluoroethylene", "foof_height", 0.5, [0.5, 0.05, 0.02], [2.5, 20, 200]);
elements.foof_height = newHeightMap("foof", Array(100).fill(null).concat(["oxygen","fluorine"]), 0.5, [], []);
worldgentypes.FOOF_sea = {
fill: [
[0, "ptfe_height_map"]
],
temperature: -120
};
elements.francium_height_map = newHeightMap("tungsten", "francium_height", 0.125, 1, 0.2, 2.5, 20);
elements.francium_height = newHeightMap("molten_francium", Array(100).fill(null).concat(["radon","radiation","radiation","radiation"]), 0.5, 0, 0, 1, 1);
elements.francium_height_map = newHeightMap("tungsten", "francium_height", 0.375, [1, 0.2, 0.02], [2.5, 20, 200]);
elements.francium_height = newHeightMap("molten_francium", Array(100).fill(null).concat(["radon","radiation","radiation","radiation"]), 0.5, [], []);
worldgentypes.francium_lake = {
fill: [
[0, "francium_height_map"]