diff --git a/mods/chem.js b/mods/chem.js index b6a35ded..ed95088f 100644 --- a/mods/chem.js +++ b/mods/chem.js @@ -927,7 +927,7 @@ elements.iron_chloride = { behavior: behaviors.POWDER, reactions: { "dirty_water": { "elem1": null, "elem2":"water" }, - //"ethylene": { "elem2":"1,2_dichloroethane" }, todo: vinyl chloride + //"ethylene": { "elem2":"one_two_dichloroethane" }, todo: vinyl chloride }, category: "powders", tempHigh: 307.6, @@ -1208,8 +1208,51 @@ elements.ethylene = { density: 1.356, }; -elements.acid.ignore.push("ethylene","liquid_ethylene","chloroethane","liquid_chloroethane"); -elements.acid_gas.ignore.push("ethylene","liquid_ethylene","chloroethane","liquid_chloroethane"); + +elements.liquid_ethylene = { + tempHigh: -103.7, + stateHigh: "ethylene", + tempLow: -154.4, +}; +elements.liquid_ethane = { + tempHigh: -88.5, + stateHigh: "ethane", + tempLow: -128.2, +}; + + +elements.liquid_ethylene = { + tempHigh: -103.7, + stateHigh: "ethylene", + tempLow: -169.2, +}; +elements.liquid_ethane = { + tempHigh: -88.5, + stateHigh: "ethane", + tempLow: -182.8, +}; + +elements.liquid_chloroethane = { + tempHigh: -12.27, + stateHigh: "chloroethane", + tempLow: -138.7, +}; + +elements.liquid_propane = { + tempHigh: -42.25, + stateHigh: "propane", + tempLow: -187.7, +}; +elements.liquid_methane = { + tempHigh: -161.5, + stateHigh: "methane", + tempLow: -182.45, +}; + + + +elements.acid.ignore.push("ethylene","ethylene_ice","liquid_ethylene","chloroethane","chloroethane_ice","liquid_chloroethane"); +elements.acid_gas.ignore.push("ethylene","ethylene_ice","liquid_ethylene","chloroethane","chloroethane_ice","liquid_chloroethane"); @@ -1842,6 +1885,10 @@ runAfterAutogen(function() { elements.molten_potassium_salt.conduct = 0.7; delete elements.molten_potassium_salt.burn; delete elements.molten_potassium.burn; + + //Hall–Heroult process + elements.molten_cryolite_solution.reactions = {}; + elements.molten_cryolite_solution.reactions.charcoal = { elem1:"molten_aluminum", elem2:"carbon_dioxide" }; }); elements.niter = { @@ -2032,9 +2079,20 @@ elements.silver_bromide = { tick: function(pixel) { for (let i = -1; i <= 1; i++) { for (let j = -1; j <= 1; j++) { - if (!isEmpty(pixel.x+i,pixel.y+j,true) && pixelMap[pixel.x+i][pixel.y+j].element === "light") { - pixel.color = pixelMap[pixel.x+i][pixel.y+j].color; - deletePixel(pixel.x+i,pixel.y+j); + if (!isEmpty(pixel.x+i,pixel.y+j,true) && (pixelMap[pixel.x+i][pixel.y+j].element === "light" || pixelMap[pixel.x+i][pixel.y+j].element === "liquid_light")) { + + for (let k = -1; k <= 1; k++) { + for (let l = -1; l <= 1; l++) { + if(!isEmpty(pixel.x+k,pixel.y+l,true) && pixelMap[pixel.x+k][pixel.y+l].element === "silver_bromide") + { + pixelMap[pixel.x+k][pixel.y+l].color = pixelMap[pixel.x+i][pixel.y+j].color; + } + } + } + if(pixelMap[pixel.x+i][pixel.y+j].element === "light") + { + deletePixel(pixel.x+i,pixel.y+j); + } } } } @@ -2288,24 +2346,162 @@ elements.disinfectant = { -//elements.bauxite = { -// color: ["#915a30","#cc7533"], -// behavior: behaviors.POWDER, -// category: "land", -// density: 2420, -// state: "solid", -// tempHigh: 300 -//}; -// -//elements.sodium_aluminate = { -// color: ["#e6c9b3","#ebc8ad"], -// behavior: behaviors.POWDER, -// category: "powders", -// hidden: true, -// density: 1500, -// state: "solid", -// tempHigh: 1650 -//}; +elements.bauxite = { + color: ["#915a30","#cc7533"], + behavior: behaviors.POWDER, + category: "land", + density: 2420, + state: "solid", + tempHigh: 300 +}; + +elements.sodium_aluminate_solution = { + color: ["#bdb3e6","#b4adeb"], + behavior: behaviors.LIQUID, + category: "liquids", + hidden: true, + density: 1005, + state: "liquid", + tempHigh: 100, + stateHigh: ["sodium_aluminate","steam"], + reactions: { + //Bayer process + "carbon_dioxide": { elem1:"aluminum_hydroxide", elem2: ["sodium_carbonate_solution","spent_sodium_aluminate_solution"] }, + }, +}; + + +elements.spent_sodium_aluminate_solution = { + color: ["#696380","#7a759e"], + behavior: behaviors.LIQUID, + category: "liquids", + hidden: true, + density: 1005, + state: "liquid", + tempHigh: 100, + stateHigh: ["sodium_aluminate","sodium_aluminate","sodium_aluminate","gallium","steam","steam","steam","steam"], +}; + + +elements.sodium_aluminate = { + color: ["#e6c9b3","#ebc8ad"], + behavior: behaviors.POWDER, + category: "powders", + hidden: true, + density: 1500, + state: "solid", + tempHigh: 1650, + reactions: { + "water": { elem1: "sodium_aluminate_solution", elem2: null }, + }, +}; + +elements.sodium_carbonate_solution = { + color: ["#c5c1d6","#afacc2"], + behavior: behaviors.LIQUID, + category: "liquids", + hidden: true, + density: 1005, + state: "liquid", + tempHigh: 100, + stateHigh: ["sodium_carbonate","steam"], +}; + + +elements.sodium_carbonate = { + color: "#d8dae6", + behavior: behaviors.POWDER, + category: "powders", + hidden: false, + density: 2540, + state: "solid", + tempHigh: 851, + reactions: { + "water": { elem1: "sodium_carbonate_solution", elem2: null }, + }, +} + + +elements.aluminum_hydroxide = { + color: "#d1cbcb", + behavior: behaviors.POWDER, + category: "powders", + hidden: true, + density: 2420, + state: "solid", + tempHigh: 300, + stateHigh: ["alumina","steam"], +} + +elements.alumina = { + color: "#d1cbcb", + behavior: behaviors.SOLID, + category: "solids", + density: 3987, + state: "solid", + tempHigh: 2072, + reactions: { + "molten_cryolite_mixture": { elem1: "molten_cryolite_solution", elem2: "molten_cryolite_solution"}, + }, +} + + + +elements.cryolite = { + color: ["#9ab6d9","#dae4f0"], + behavior: behaviors.POWDER, + category: "land", + density: 2900, + state: "solid", + tempHigh: 950, + reactions: { + "aluminum_trifluoride": { elem1: "cryolite_mixture", elem2: "cryolite_mixture"}, + }, +} + + +elements.aluminum_trifluoride = { + color: ["#ebf4ff","#e3fdff"], + behavior: behaviors.POWDER, + category: "powder", + hidden: true, + density: 3100, + state: "solid", + tempHigh: 1290, +} + + +elements.molten_aluminum_trifluoride = { + tempHigh: 1290, + tempLow: 1290, +} + +elements.aluminum_trifluoride_gas = { + tempLow: 1290, +} + + + + +elements.cryolite_mixture = { + color: [blendColors("#9ab6d9","#ebf4ff"),blendColors("#dae4f0","#e3fdff")], + behavior: behaviors.POWDER, + category: "land", + hidden: true, + density: 2910, + state: "solid", + tempHigh: 950, +} + +elements.cryolite_solution = { + color: [blendColors(blendColors("#9ab6d9","#ebf4ff"),"#d1cbcb"),blendColors(blendColors("#dae4f0","#e3fdff"),"#d1cbcb")], + behavior: behaviors.POWDER, + category: "land", + hidden: true, + density: 2920, + state: "solid", + tempHigh: 950, +} function acidReact(acid,element,product1,product2) { @@ -2356,13 +2552,13 @@ acidNeutralize("potassium_hydroxide"); acidNeutralize("potassium_hydroxide_gas"); -//createAcid("red_mud",structuredClone(defaultBaseReactions),structuredClone(defaultBaseGasReactions),["#ab3d24","#cc5d2d","#a81b1b"],"hidden","hidden",1600,1600,0,Infinity,5200,3); -//acidNeutralize("red_mud"); -//acidNeutralize("red_mud_gas"); -//elements.red_mud.viscosity = 1000000; -//elements.red_mud.reactions.water = {"elem2":"dirty_water" }; -//elements.red_mud.reactions.salt_water = {"elem2":"dirty_water" }; -//elements.red_mud.reactions.sugar_water = {"elem2":"dirty_water" }; +createAcid("red_mud",structuredClone(defaultBaseReactions),structuredClone(defaultBaseGasReactions),["#ab3d24","#cc5d2d","#a81b1b"],"hidden","hidden",1600,1600,0,Infinity,5200,3); +acidNeutralize("red_mud"); +acidNeutralize("red_mud_gas"); +elements.red_mud.viscosity = 1000000; +elements.red_mud.reactions.water = {"elem2":"dirty_water" }; +elements.red_mud.reactions.salt_water = {"elem2":"dirty_water" }; +elements.red_mud.reactions.sugar_water = {"elem2":"dirty_water" }; elements.potassium_hydroxide.reactions["fertilizer"] = { elem1: "niter", elem2: "ammonia"}; @@ -2383,8 +2579,50 @@ elements.potassium_salt_water.reactions["mercury"] = { elem1:["potassium_hydroxi elements.potassium_hydroxide.ignore.push("mercury"); elements.potassium_hydroxide.ignore.push("potassium_salt_water"); -//acidReact("sodium_hydroxide","bauxite","sodium_aluminate","red_mud") -//elements.red_mud.ignore.push("bauxite","sodium_aluminate"); +acidReact("sodium_hydroxide","bauxite","sodium_aluminate_solution","red_mud"); +acidReact("sodium_hydroxide_gas","bauxite","sodium_aluminate_solution","red_mud"); +elements.red_mud.ignore.push("bauxite","sodium_aluminate_solution","sodium_aluminate_solution_ice","sodium_aluminate","molten_sodium_aluminate","sodium_carbonate_solution","spent_sodium_aluminate_solution","spent_sodium_aluminate_solution_ice","aluminum_hydroxide","alumina","molten_alumina"); +elements.red_mud_gas.ignore.push("bauxite","sodium_aluminate_solution","sodium_aluminate_solution_ice","sodium_aluminate","molten_sodium_aluminate","sodium_carbonate_solution","spent_sodium_aluminate_solution","spent_sodium_aluminate_solution_ice","aluminum_hydroxide","alumina","molten_alumina"); +elements.sodium_hydroxide.ignore.push("sodium_aluminate_solution","sodium_aluminate_solution_ice","sodium_aluminate","molten_sodium_aluminate","sodium_carbonate_solution","spent_sodium_aluminate_solution","spent_sodium_aluminate_solution_ice","aluminum_hydroxide","alumina","molten_alumina"); +elements.sodium_hydroxide_gas.ignore.push("sodium_aluminate_solution","sodium_aluminate_solution_ice","sodium_aluminate","molten_sodium_aluminate","sodium_carbonate_solution","spent_sodium_aluminate_solution","spent_sodium_aluminate_solution_ice","aluminum_hydroxide","alumina","molten_alumina"); + + + +//Cryolite +acidReact("hydrofluoric_acid","sodium_aluminate","cryolite",null); +acidReact("hydrofluoric_acid_gas","sodium_aluminate","cryolite",null); + +acidReact("hydrogen_fluoride","sodium_aluminate","cryolite",null); +acidReact("liquid_hydrogen_fluoride","sodium_aluminate","cryolite",null); + +elements.hydrofluoric_acid.ignore.push("molten_cryolite","molten_sodium_aluminate"); +elements.hydrofluoric_acid_gas.ignore.push("molten_cryolite","molten_sodium_aluminate"); +elements.hydrogen_fluoride.ignore.push("molten_cryolite","molten_sodium_aluminate"); +elements.liquid_hydrogen_fluoride.ignore.push("molten_cryolite","molten_sodium_aluminate"); + +acidReact("hexafluorosilicic_acid","sodium_aluminate","cryolite","sand"); +acidReact("hexafluorosilicic_acid_gas","sodium_aluminate","cryolite","sand"); +elements.hexafluorosilicic_acid.ignore.push("molten_cryolite","molten_sodium_aluminate"); +elements.hexafluorosilicic_acid_gas.ignore.push("molten_cryolite","molten_sodium_aluminate"); + +//Aluminum trifluoride +acidReact("hydrofluoric_acid","alumina","aluminum_trifluoride",null); +acidReact("hydrofluoric_acid_gas","alumina","aluminum_trifluoride",null); + +acidReact("hydrogen_fluoride","alumina","aluminum_trifluoride",null); +acidReact("liquid_hydrogen_fluoride","alumina","aluminum_trifluoride",null); + +elements.hydrofluoric_acid.ignore.push("molten_alumina","molten_aluminum_trifluoride"); +elements.hydrofluoric_acid_gas.ignore.push("molten_alumina","molten_aluminum_trifluoride"); +elements.hydrogen_fluoride.ignore.push("molten_alumina","molten_aluminum_trifluoride"); +elements.liquid_hydrogen_fluoride.ignore.push("molten_alumina","molten_aluminum_trifluoride"); + + +acidReact("hydrofluoric_acid","aluminum_hydroxide","aluminum_trifluoride",null); +acidReact("hydrofluoric_acid_gas","aluminum_hydroxide","aluminum_trifluoride",null); + +acidReact("hydrogen_fluoride","aluminum_hydroxide","aluminum_trifluoride",null); +acidReact("liquid_hydrogen_fluoride","aluminum_hydroxide","aluminum_trifluoride",null); elements.bless.reactions["FOOF"] = {elem2: "oxygen"}; elements.bless.reactions["solid_FOOF"] = {elem2: "oxygen"}; diff --git a/mods/doomsday.js b/mods/doomsday.js new file mode 100644 index 00000000..89095f22 --- /dev/null +++ b/mods/doomsday.js @@ -0,0 +1,56 @@ +elements.Doomsday = { + color: "#ff0000", + behavior: [ + "XX|EX:100000>plasma,plasma,plasma,plasma,fire,fire,plasma,plasma,plasma,plasma,fire,fire,fire,fire,fire,plasma,plasma,plasma,plasma,fire,fire,fire,fire,fire,fire,fire,fire,fire,fire,plasma,plasma,plasma,plasma,fire,fire,fire,fire,fire|XX", + "XX|XX|XX", + "M2|M1 AND EX:10000>plasma,plasma,plasma,plasma,fire,fire,fire,fire,fire,plasma,plasma,plasma,plasma,fire,fire,fire,fire,fire,fire,fire,fire,fire,fire,plasma,plasma,plasma,plasma,fire,fire,fire,fire,fire|M2", + ], + category: "weapons", + state: "solid", + density: 1600, + excludeRandom: true, + alias: "Say goodbye to your computer chucklenuts", + cooldown: defaultCooldown +} +elements.Plasma_cannon = { + color: "#6a00ff", + behavior: [ + "XX|EX:90>plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma|XX", + "XX|XX|XX", + "M2|M1 AND EX:90>plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma|M2", + ], + category: "weapons", + state: "solid", + density: 1600, + excludeRandom: true, + alias: "Plasma cannon :D", + cooldown: defaultCooldown +} +elements.Cluster_Nuke = { + color: "#6a00ff", + behavior: [ + "XX|EX:90>plasma,fire,nuke|XX", + "XX|XX|XX", + "M2|M1 AND EX:90>plasma,fire,fire,fire,nuke,nuke,nuke|M2", + ], + category: "weapons", + state: "solid", + density: 1600, + excludeRandom: true, + alias: "Plasma cannon :D", + cooldown: defaultCooldown +} +elements.Infinibomb = { + color: "#6a00ff", + behavior: [ + "XX|EX:20>plasma,fire|XX", + "XX|XX|XX", + "M2|M1 AND EX:20>plasma,fire,fire,fire,Infinibomb|M2", + ], + category: "weapons", + state: "solid", + density: 1600, + excludeRandom: true, + alias: "Plasma cannon :D", + cooldown: defaultCooldown +} \ No newline at end of file diff --git a/mods/gameOfLife.js b/mods/gameOfLife.js new file mode 100644 index 00000000..e3badd86 --- /dev/null +++ b/mods/gameOfLife.js @@ -0,0 +1,83 @@ +// UNFINISHED +{ +let processed = 0; +let started = false; + +const offsetX = 20; +const offsetY = 10; + +function getAliveNeighbors(x, y) { + let amount = 0; + for (const i of [-1, 0, 1]) { + for (const j of [-1, 0, 1]) { + if (i == 0 && j == 0) continue; + if (outOfBounds(x + i, y + j)) continue; + const x1 = x + i; + const y1 = y + j; + if (pixelMap[x1][y1] && pixelMap[x1][y1].element == "alive_cell") amount++; + } + } + return amount; +} + +elements.alive_cell = { + name: "Alive cell", + color: "#000000" +} + +elements.dead_cell = { + name: "Dead cell", + color: "#ffffff" +} + +setInterval(cellTick, (1000/tps)*2); + +function cellTick() { + if (started && !paused) { + const newStates = []; + for (let i = offsetX; i < width - offsetX; i++) { + for (let j = offsetY; j < height - offsetY; j++) { + if (!pixelMap[i][j]) continue; + const {element} = pixelMap[i][j]; + const neighbors = getAliveNeighbors(i, j); + if (element == "alive_cell") { + if (neighbors < 2 || neighbors > 3) { + newStates.push(["dead_cell", i, j]); + } else { + newStates.push(["alive_cell", i, j]); + } + } else if (element == "dead_cell") { + if (neighbors == 3) { + newStates.push(["alive_cell", i, j]); + } else { + newStates.push(["dead_cell", i, j]); + } + } + } + } + for (let state of newStates) { + const {element} = pixelMap[state[1]][state[2]]; + if (element != state[0]) { + deletePixel(state[1], state[2]); + createPixel(state[0], state[1], state[2]); + } + } + } +} + +window.addEventListener("keydown", (ev) => { + if (ev.key == "u") { + if (!started) { + videoFrame = 0; + + for (let i = offsetX; i < width - offsetX; i++) { + for (let j = offsetY; j < height - offsetY; j++) { + if (pixelMap[i][j]) deletePixel(i, j); + createPixel("dead_cell", i, j); + } + } + } + started = !started; + } +}) +} \ No newline at end of file diff --git a/mods/pixelResizeTool.js b/mods/pixelResizeTool.js new file mode 100644 index 00000000..5f35bb2c --- /dev/null +++ b/mods/pixelResizeTool.js @@ -0,0 +1,10 @@ +pixelResizeButton = document.createElement("button"); +pixelResizeButton.onclick = function(pixel) { + let canvas_width = document.getElementById("game").width; + let canvas_height = document.getElementById("game").height; + let pixelSizeNeeded = prompt("How big should pixels be?"); + if (!pixelSizeNeeded) { return } + resizeCanvas(canvas_height,canvas_width, parseFloat(pixelSizeNeeded), true); +}; +pixelResizeButton.textContent = "Resize"; +document.getElementById("toolControls").appendChild(pixelResizeButton);