From 6721d9a6a1a1efaf42e7b0e0abf143d053a9916d Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Fri, 26 Apr 2024 19:53:00 -0700 Subject: [PATCH 01/25] Update Batteries.js --- mods/Batteries.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index 424a79a7..8f4584d6 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -22,7 +22,7 @@ elements.low_battery= { ], behaviorOn: [ "XX|SH%10|XX", // shocks (adds charge) - "SH%10|CH:charged_battery%0.05|SH%10", + "SH%10|CH:charged_battery%0.045|SH%10", "XX|SH%10|XX", ], colorOn: "#4fb613", @@ -41,7 +41,7 @@ elements.dead_battery= { ], behaviorOn: [ "XX|XX|XX", - "XX|CH:low_battery%0.05|XX", + "XX|CH:low_battery%0.045|XX", "XX|XX|XX", ], colorOn: "#699e19", @@ -93,6 +93,7 @@ elements.radio_wave= { } }, category: "energy", + reactions: {electric: {elem1: null, elem2: null, chance: 0.5}}, density: 1, //charge: 0.5, conduct: 0.01 From d924b15fefb1ce1ce26fe74669b1298270a8828b Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Thu, 9 May 2024 13:56:36 -0700 Subject: [PATCH 02/25] Update Thread.js --- mods/Thread.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/mods/Thread.js b/mods/Thread.js index 03c22ff4..4b68bd85 100644 --- a/mods/Thread.js +++ b/mods/Thread.js @@ -145,3 +145,34 @@ elements.lamb = { density: 1450, conduct: 0.2 }; +elements.loom = { + color: "#296127", + behavior: behaviors.WALL, + category: "machines", + tick: function(pixel) { + if (pixel.start === pixelTicks){ + pixel.contype = converter2Var; + pixel.specialturn = converter1Var; + } + for (var i = 0; i < squareCoords.length; i++) { + var coord = squareCoords[i]; + var x = pixel.x+coord[0]; + var y = pixel.y+coord[1]; + if (!isEmpty(x,y, true)) { + var otherPixel = pixelMap[x][y]; + if ((otherPixel.element == pixel.specialturn || pixel.specialturn == "all") && !elements.converter.ignore.includes(otherPixel.element)){ + changePixel(otherPixel, pixel.contype) + } + } + } + }, + onSelect: function() { + var answer5 = prompt("Please input what type of element should be converted. Write \"all\" to include everything.",(converter1Var||undefined)); + if (!answer5) { return } + converter1Var = answer5; + var answer6 = prompt("Please input what it should turn into.",(converter2Var||undefined)); + if (!answer6) { return } + converter2Var = answer6; + }, + movable: false, +}, From b8267c08e6de647542773f5902f0de70621ee4c4 Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Thu, 9 May 2024 14:04:06 -0700 Subject: [PATCH 03/25] Update Thread.js --- mods/Thread.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/Thread.js b/mods/Thread.js index 4b68bd85..7ba6cc8a 100644 --- a/mods/Thread.js +++ b/mods/Thread.js @@ -145,6 +145,8 @@ elements.lamb = { density: 1450, conduct: 0.2 }; +converter1Var = 0; +converter2Var = 0; elements.loom = { color: "#296127", behavior: behaviors.WALL, From 80597b23a2509d0db50cc3f5bc262a4524916291 Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Thu, 9 May 2024 14:23:53 -0700 Subject: [PATCH 04/25] Update Batteries.js --- mods/Batteries.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mods/Batteries.js b/mods/Batteries.js index 8f4584d6..a5c5bfc4 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -98,3 +98,21 @@ elements.radio_wave= { //charge: 0.5, conduct: 0.01 }; +elements.e_nuke = { + desc: "Works like the nuke but needs power to explode", + color: ["#534636"], + hardness: elements.nuke.hardness, + state: "solid", + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "M2|M1|M2", + ], + conduct: 1, + category: "machines", + behaviorOn:[ + "XX|XX|XX", + "XX|XX|XX", + "M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2", + ], +}; From 95a1f99c6dc4b3398ab9f9b3c566a2826d8cf73a Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Thu, 9 May 2024 14:30:55 -0700 Subject: [PATCH 05/25] Update Batteries.js --- mods/Batteries.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index a5c5bfc4..9c934e11 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -99,18 +99,18 @@ elements.radio_wave= { conduct: 0.01 }; elements.e_nuke = { - desc: "Works like the nuke but needs power to explode", + desc: "Works like the nuke but needs power to explode", color: ["#534636"], - hardness: elements.nuke.hardness, - state: "solid", - behavior: [ + hardness: elements.nuke.hardness, + state: "solid", + behavior: [ "XX|XX|XX", "XX|XX|XX", "M2|M1|M2", ], - conduct: 1, - category: "machines", - behaviorOn:[ + conduct: 1, + category: "machines", + behaviorOn:[ "XX|XX|XX", "XX|XX|XX", "M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2", From b5308d2d2010a8b3e047c72017eff307d1e20bfb Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Thu, 9 May 2024 14:31:37 -0700 Subject: [PATCH 06/25] Update Batteries.js --- mods/Batteries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index 9c934e11..2a756051 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -100,7 +100,7 @@ elements.radio_wave= { }; elements.e_nuke = { desc: "Works like the nuke but needs power to explode", - color: ["#534636"], + color: "#534636", hardness: elements.nuke.hardness, state: "solid", behavior: [ From 8e855b3ab64a148aad6414a66dfaac8eac33f6d9 Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Fri, 10 May 2024 11:59:46 -0700 Subject: [PATCH 07/25] Update Batteries.js --- mods/Batteries.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index 2a756051..74d8e194 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -109,10 +109,65 @@ elements.e_nuke = { "M2|M1|M2", ], conduct: 1, - category: "machines", + category: "weapons", behaviorOn:[ "XX|XX|XX", "XX|XX|XX", "M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2", ], }; +elements.10_timer= { + color: ["#000000"], + behavior: behaviors.WALL, + colorOn: "#000000", + tick: elements.gasoline_engine = { + color: "#6d5f5d", + behavior: behaviors.WALL, + state: "solid", + density: 1000, + category: "testing", + properties: { + time: 10 + }, + tick: function(pixel){ + if (pixel.timer <= 40){ + if(!pixel.timer){pixel.timer = 0} + pixel.timer -= 10 + } + else if (otherPixel.element == "gasoline_engine"){ + var otherPixel = pixelMap[x][y] + var otherShock = otherPixel.timer || 0 + var currentShock = pixel.timer || 0 + if (otherShock == currentShock){break;} + if (otherShock > currentShock){ + otherPixel.timer -- + pixel.timer ++ + } else { + otherPixel.timer ++ + pixel.timer -- + } + } + } + }} + if (!pixel.charge && !pixel.chargeCD && pixel.timer){ + for (var i = 0; i < adjacentCoords.length; i++){ + var coord = adjacentCoords[i] + var x = pixel.x + coord[0] + var y = pixel.y + coord[1] + if (!isEmpty(x, y, true)){ + if (elements[pixelMap[x][y]].conduct > 0){ + pixel.charge = 1 + pixel.timer -- + break; + } + } + } + } + } +} + category: "energy", + reactions: {electric: {elem1: null, elem2: null, chance: 0.5}}, + density: 1, + //charge: 0.5, + conduct: 0 +}; From cdd71834ba1cd2efd4ab31ebae0cc3728101aec7 Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Tue, 14 May 2024 16:11:23 -0700 Subject: [PATCH 08/25] Update Batteries.js --- mods/Batteries.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index 74d8e194..dccd1e4b 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -120,7 +120,8 @@ elements.10_timer= { color: ["#000000"], behavior: behaviors.WALL, colorOn: "#000000", - tick: elements.gasoline_engine = { + tick: , +elements.gasoline_engine = { color: "#6d5f5d", behavior: behaviors.WALL, state: "solid", From 693ea4c6f57eb5f9faf0dbc7c4dd784f5209e043 Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Tue, 14 May 2024 16:47:55 -0700 Subject: [PATCH 09/25] Update Batteries.js --- mods/Batteries.js | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index dccd1e4b..5c51c78c 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -120,7 +120,44 @@ elements.10_timer= { color: ["#000000"], behavior: behaviors.WALL, colorOn: "#000000", - tick: , + conduct: 0, + category: "machines", + properties: { + wait: 15, + waitReduce: false, + }, + tick: function(pixel){ + if (pixel.waitReduce){pixel.wait -= 1} + if (pixel.wait == 0){ + pixel.elementsSeen = {} + } + for (var i = 0; i < adjacentCoords.length; i++) { + var coord = adjacentCoords[i]; + var x = pixel.x+coord[0]; + var y = pixel.y+coord[1]; + if (!isEmpty(x,y, true)){ + if (!pixel.waitReduce){ + pixel.waitReduce = true + }, + if (pixel.wait == 0){ + if (!pixel.elementsSeen[pixelMap[x][y].element] && pixelMap[x][y].element != "healing_serum"){ + pixel.elementsSeen[pixelMap[x][y].element] = 1 + } else if (pixelMap[x][y].element != "healing_serum") { + pixel.elementsSeen[pixelMap[x][y].element] += 1 + } + } + } + if (pixel.wait == 0){ + if (Object.keys(pixel.elementsSeen).length == 0){ + deletePixel(pixel.x, pixel.y) + return; + } else{ + changePixel(pixel, Object.keys(pixel.elementsSeen).reduce((a, b) => pixel.elementsSeen[a] > pixel.elementsSeen[b] ? a : b)) + } + } + } + } +} elements.gasoline_engine = { color: "#6d5f5d", behavior: behaviors.WALL, @@ -128,7 +165,7 @@ elements.gasoline_engine = { density: 1000, category: "testing", properties: { - time: 10 + timer: 10 }, tick: function(pixel){ if (pixel.timer <= 40){ From 26b1afa509d48984f7ab6d69e4c95df2d9f1d4cf Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Tue, 14 May 2024 16:54:35 -0700 Subject: [PATCH 10/25] Create IreThings --- mods/IreThings | 169 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 mods/IreThings diff --git a/mods/IreThings b/mods/IreThings new file mode 100644 index 00000000..bb754dc3 --- /dev/null +++ b/mods/IreThings @@ -0,0 +1,169 @@ + +elements.charged_battery= { + color: "#9c6c25", + behavior: [ + "XX|SH%50|XX", // shocks (adds charge) + "SH%50|CH:low_battery%0.05|SH%50", + "XX|SH%50|XX", + ], + colorOn: "#00ff00", + category: "machines", + tempHigh: 1455.5, + stateHigh: ["molten_steel","explosion","acid_gas"], + charge: 0.5, + conduct: 1, +}; +elements.low_battery= { + color: "#9c6c25", + behavior: [ + "XX|SH%10|XX", // shocks (adds charge) + "SH%10|CH:dead_battery%0.05|SH%10", + "XX|SH%10|XX", + ], + behaviorOn: [ + "XX|SH%10|XX", // shocks (adds charge) + "SH%10|CH:charged_battery%0.045|SH%10", + "XX|SH%10|XX", + ], + colorOn: "#4fb613", + category: "machines", + tempHigh: 1455.5, + stateHigh: ["molten_steel","explosion","acid_gas"], + charge: 0.5, + conduct: 0.75, +}; +elements.dead_battery= { + color: "#9c6c25", + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + behaviorOn: [ + "XX|XX|XX", + "XX|CH:low_battery%0.045|XX", + "XX|XX|XX", + ], + colorOn: "#699e19", + category: "machines", + tempHigh: 1455.5, + stateHigh: ["molten_steel","explosion","acid_gas"], + charge: 0.5, + conduct: 0.5, +}; +elements.radio_broadcaster= { + color: "#78784c", + behavior: behaviors.WALL, + behaviorOn: [ + "XX|SH AND CR:radio_wave AND CR:radio_wave|XX", + "SH AND CR:radio_wave AND CR:radio_wave|XX|SH AND CR:radio_wave AND CR:radio_wave", + "XX|SH AND CR:radio_wave AND CR:radio_wave|XX", + ], + colorOn: "#ffff59", + category: "machines", + tempHigh: 1455.5, + stateHigh: ["molten_steel","explosion","acid_gas"], + conduct: 1 +}; +elements.radio_receiver= { + color: "#78784c", + behavior: behaviors.WALL, + reactions: {radio_wave: {elem2: "electric", chance: 0.75}}, + colorOn: "#ffff59", + category: "machines", + tempHigh: 1455.5, + stateHigh: ["molten_steel","explosion","acid_gas"], + conduct: 1 +}; +elements.radio_wave= { + color: ["#000000"], + behavior: behaviors.BOUNCY, + behaviorOn: [ + ["XX","CL","XX"], + ["CL","DL%5","CL"], + ["XX","CL","XX"] + ] + , + colorOn: "#000000", + tick: function(pixel){ + if (currentElement == "radio_wave"){ + pixel.color = "rgb(15, 15, 15)"; + } else { + pixel.color = "rgba(0, 0, 0, -1)"; + } + }, + category: "energy", + reactions: {electric: {elem1: null, elem2: null, chance: 0.5}}, + density: 1, + //charge: 0.5, + conduct: 0.01 +}; +elements.e_nuke = { + desc: "Works like the nuke but needs power to explode", + color: "#534636", + hardness: elements.nuke.hardness, + state: "solid", + behavior: [ + "XX|XX|XX", + "XX|XX|XX", + "M2|M1|M2", + ], + conduct: 1, + category: "weapons", + behaviorOn:[ + "XX|XX|XX", + "XX|XX|XX", + "M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2", + ], +}; +elements.10_timer= { + color: ["#000000"], + behavior: behaviors.WALL, + colorOn: "#000000", + conduct: 0, + category: "machines", + properties: { + wait: 15, + waitReduce: false, + }, + tick: function(pixel){ + if (pixel.waitReduce){pixel.wait -= 1} + if (pixel.wait == 0){ + pixel.elementsSeen = {} + } + for (var i = 0; i < adjacentCoords.length; i++) { + var coord = adjacentCoords[i]; + var x = pixel.x+coord[0]; + var y = pixel.y+coord[1]; + if (!isEmpty(x,y, true)){ + if (!pixel.waitReduce){ + pixel.waitReduce = true + }, + if (pixel.wait == 0){ + if (!pixel.elementsSeen[pixelMap[x][y].element] && pixelMap[x][y].element != "healing_serum"){ + pixel.elementsSeen[pixelMap[x][y].element] = 1 + } else if (pixelMap[x][y].element != "healing_serum") { + pixel.elementsSeen[pixelMap[x][y].element] += 1 + } + } + } + if (pixel.wait == 0){ + if (Object.keys(pixel.elementsSeen).length == 0){ + deletePixel(pixel.x, pixel.y) + return; + } else{ + changePixel(pixel, Object.keys(pixel.elementsSeen).reduce((a, b) => pixel.elementsSeen[a] > pixel.elementsSeen[b] ? a : b)) + } + } + } + } +} +elements.gasoline_engine = { + color: "#6d5f5d", + behavior: behaviors.WALL, + state: "solid", + density: 1000, + category: "testing", + properties: { + timer: 10 + }, From 7b8d9f05210080cb46d2d908bd61fb5818955f75 Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Tue, 14 May 2024 16:54:57 -0700 Subject: [PATCH 11/25] Rename IreThings to IreThings.js --- mods/{IreThings => IreThings.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename mods/{IreThings => IreThings.js} (100%) diff --git a/mods/IreThings b/mods/IreThings.js similarity index 100% rename from mods/IreThings rename to mods/IreThings.js From 6db289319b2ab30604812b5ace1abea10ed5c645 Mon Sep 17 00:00:00 2001 From: lllllllllwith10ls Date: Tue, 28 May 2024 15:11:33 -0500 Subject: [PATCH 12/25] Various things, including alchem.js Added alchem.js and sturdier powders. Fixed some chem.js and world_gen_test.js bugs --- mods/alchem.js | 368 +++++++++++++++++++++++++ mods/chem.js | 173 ++++++++---- mods/sturdierpowders.js | 595 ++++++++++++++++++++++++++++++++++++++++ mods/world_gen_test.js | 60 ++-- 4 files changed, 1121 insertions(+), 75 deletions(-) create mode 100644 mods/alchem.js create mode 100644 mods/sturdierpowders.js diff --git a/mods/alchem.js b/mods/alchem.js new file mode 100644 index 00000000..169a9aab --- /dev/null +++ b/mods/alchem.js @@ -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(); +} \ No newline at end of file diff --git a/mods/chem.js b/mods/chem.js index 73438729..5e7a36cc 100644 --- a/mods/chem.js +++ b/mods/chem.js @@ -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"]; } }); \ No newline at end of file diff --git a/mods/sturdierpowders.js b/mods/sturdierpowders.js new file mode 100644 index 00000000..981f73bc --- /dev/null +++ b/mods/sturdierpowders.js @@ -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; + } + } +}); \ No newline at end of file diff --git a/mods/world_gen_test.js b/mods/world_gen_test.js index dc214aba..d097d3e3 100644 --- a/mods/world_gen_test.js +++ b/mods/world_gen_test.js @@ -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"] From 43bc564c0068ffeccfb3cbeb42b4a5f1b3d410a6 Mon Sep 17 00:00:00 2001 From: lllllllllwith10ls Date: Tue, 28 May 2024 15:18:26 -0500 Subject: [PATCH 13/25] Commented out debug console.logs --- mods/alchem.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/alchem.js b/mods/alchem.js index 169a9aab..b6e2e8b9 100644 --- a/mods/alchem.js +++ b/mods/alchem.js @@ -91,7 +91,6 @@ function addElement(list, elem) { return result; } if(elem && !list.includes(elem)) { - if(elem === "CR") {console.log(elem)}; list.push(elem); return true; } @@ -308,7 +307,7 @@ window.addEventListener("load",function(){ } }) - runAfterAutogen(function(){ + /*runAfterAutogen(function(){ let reachable = findReachable(initialElements); console.log(reachable.join(",")); let string = ""; @@ -359,7 +358,7 @@ window.addEventListener("load",function(){ } } console.log(string); - }); + });*/ } if(chemMod) { chemMod.addEventListener("load",loadAlchem); From 3a7b7362cf25de427707d6077140262a5c5c0979 Mon Sep 17 00:00:00 2001 From: Jayd-Rubies <155784127+Jayd-Rubies@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:04:36 -0400 Subject: [PATCH 14/25] Add files via upload --- mods/controllable_pixel.js | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 mods/controllable_pixel.js diff --git a/mods/controllable_pixel.js b/mods/controllable_pixel.js new file mode 100644 index 00000000..aa4bd0ac --- /dev/null +++ b/mods/controllable_pixel.js @@ -0,0 +1,75 @@ +document.onkeydown = function(ki)/*keyboard_input*/ { + //a + if (ki.keyCode == 65) { + KA = true; + //vX ++; + } + //d + if (ki.keyCode == 68) { + KD = true; + //vX ++; + } + //w + if (ki.keyCode == 87) { + KW = true; + //vY ++; + } + //s + if (ki.keyCode == 83) { + KS = true; + //vY ++; + } +} +document.onkeyup = function(i2)/*keyboard_input*/ { + //a + if (i2.keyCode == 65) { + KA = false; + //vX --; + } + //d + if (i2.keyCode == 68) { + KD = false; + //vX --; + } + //w + if (i2.keyCode == 87) { + KW = false; + //vY = 0; + } + //s + if (i2.keyCode == 83) { + KS = false; + //vY = 0; + } +} +var KA = false; +var KD = false; +var KW = false; +var KS = false; +var vX = 1; +var vY = 1; +elements.c_pixel = { + tick: function(pixel) { + /*if (vX === 3) { + vX --; + } + if (vY === 3) { + vY --; + }*/ + if (KA === true) { + tryMove (pixel,pixel.x-vX,pixel.y) + } + if (KD === true) { + tryMove (pixel,pixel.x+vX,pixel.y) + } + if (KW === true) { + tryMove (pixel,pixel.x,pixel.y-vY) + } + if (KS === true) { + tryMove (pixel,pixel.x,pixel.y+vY) + } + }, + category: "special", + states:"solid", + color:"#FFFFFF", +} \ No newline at end of file From 221b817b5fe95d8b74e7fd2ad4961dcf069aab78 Mon Sep 17 00:00:00 2001 From: Jayd-Rubies <155784127+Jayd-Rubies@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:08:48 -0400 Subject: [PATCH 15/25] Update mod-list.html --- mod-list.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mod-list.html b/mod-list.html index ccb88dd9..2b4bd4bc 100644 --- a/mod-list.html +++ b/mod-list.html @@ -126,6 +126,7 @@ buildingreplicator.jsScans and replicates builds anywhere on the screen, along with some preset submitted buildsnousernamefound change.jsAdds a tool that only replaces existing pixelsAlice color_tools.jsAdds tools that manipulate colorsAlice +controllable_pixel.jsAdds A pixel controlled using wasd (keyboard only)Jayd controllable_pixel_test.jsAdds a pixel that can be controlled with the keyboard keys. Read the commit description for more info. [PC ONLY]Alice cpt_alt.jsAdds a more destructive variant of the controllable pixelAlice debugRework.jsRevamps the Debug toolFioushemastor From 7165302b3636e6c281e8749e34a531a703a11dc2 Mon Sep 17 00:00:00 2001 From: Jayd-Rubies <155784127+Jayd-Rubies@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:09:47 -0400 Subject: [PATCH 16/25] Update mod-list.html --- mod-list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod-list.html b/mod-list.html index 2b4bd4bc..410055e9 100644 --- a/mod-list.html +++ b/mod-list.html @@ -126,7 +126,7 @@ buildingreplicator.jsScans and replicates builds anywhere on the screen, along with some preset submitted buildsnousernamefound change.jsAdds a tool that only replaces existing pixelsAlice color_tools.jsAdds tools that manipulate colorsAlice -controllable_pixel.jsAdds A pixel controlled using wasd (keyboard only)Jayd +controllable_pixel.jsAdds A pixel controlled using wasd (keyboard required)Jayd controllable_pixel_test.jsAdds a pixel that can be controlled with the keyboard keys. Read the commit description for more info. [PC ONLY]Alice cpt_alt.jsAdds a more destructive variant of the controllable pixelAlice debugRework.jsRevamps the Debug toolFioushemastor From 349cea3e7a379760824455c440e221d91fa2a405 Mon Sep 17 00:00:00 2001 From: Jayd-Rubies <155784127+Jayd-Rubies@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:55:06 -0400 Subject: [PATCH 17/25] FIGHTER JET LET'S GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO --- mods/c_fighter_jet.js | 449 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 449 insertions(+) create mode 100644 mods/c_fighter_jet.js diff --git a/mods/c_fighter_jet.js b/mods/c_fighter_jet.js new file mode 100644 index 00000000..8ba67c73 --- /dev/null +++ b/mods/c_fighter_jet.js @@ -0,0 +1,449 @@ +document.onkeydown = function(ki)/*keyboard_input*/ { + //a + if (ki.keyCode == 65) { + KA = true; + } + //d + if (ki.keyCode == 68) { + KD = true; + } + //w + if (ki.keyCode == 87) { + KW = true; + } + //s + if (ki.keyCode == 83) { + KS = true; + } + if (ki.keyCode == 86) { + KJ = true; + } + if (ki.keyCode == 78) { + KL = true; + } + if (ki.keyCode == 71) { + KI = true; + } + if (ki.keyCode == 66) { + KK = true; + } + if (ki.keyCode == 81) { + KQ = true; + } + if (ki.keyCode == 90) { + ammo = 300; + missile = 20; + } +} +document.onkeyup = function(i2)/*input 2*/ { + //a + if (i2.keyCode == 65) { + KA = false; + ul = false; + dl = false; + } + //d + if (i2.keyCode == 68) { + KD = false; + ur = false; + dr = false; + } + //w + if (i2.keyCode == 87) { + KW = false; + ul = false; + ur = false; + } + //s + if (i2.keyCode == 83) { + KS = false; + dl = false; + dr = false; + } + if (i2.keyCode == 86) { + KJ = false; + } + if (i2.keyCode == 78) { + KL = false; + } + if (i2.keyCode == 71) { + KI = false; + } + if (i2.keyCode == 66) { + KK = false; + } + if (i2.keyCode == 81) { + KQ = false; + } +} +var KA = false; +var KD = false; +var KW = false; +var KS = false; +var KJ = false; +var KL = false; +var KI = false; +var KK = false; +var KQ = false; +var vX = 2; +var vY = 2; +var ul = false; +var ur = false; +var dl = false; +var dr = false; +var ammo = 300; +var missile = 20; +elements.cfj = { + name: "c_fighter_jet", + tick: function(pixel) { + logMessage("|"); + logMessage("|[Callsign: Box 1]"); + logMessage("|[Codename: 'Player]'"); + logMessage("|"); + logMessage("|[Operation: 'Sandbox']"); + logMessage("|['Box Squadron']"); + logMessage("|"); + logMessage("|[Ammo:" + ammo +"]"); + logMessage("|[Missiles:" + missile +"]"); + logMessage("|"); + if (KA === true) { + tryMove (pixel,pixel.x-vX,pixel.y) + } + if (KD === true) { + tryMove (pixel,pixel.x+vX,pixel.y) + } + if (KW === true) { + tryMove (pixel,pixel.x,pixel.y-vY) + } + if (KS === true) { + tryMove (pixel,pixel.x,pixel.y+vY) + } + if (KJ === true && missile > 0) { + createPixel("cfj_missile_left",pixel.x-1,pixel.y); + missile--; + } + if (KL === true && missile > 0) { + createPixel("cfj_missile_right",pixel.x+1,pixel.y); + missile--; + } + if (KI === true && missile > 0) { + createPixel("cfj_missile_up",pixel.x,pixel.y-1); + missile--; + } + if (KK === true && missile > 0) { + createPixel("cfj_missile_down",pixel.x,pixel.y+1); + missile--; + } + if (KQ === true) { + if (KA === true && dl === false && ul === false && ammo > 0) { + createPixel("cfj_b_l",pixel.x-4,pixel.y); + ammo--; + } + if (KD === true && dr === false && ur === false && ammo > 0) { + createPixel("cfj_b_r",pixel.x+4,pixel.y); + ammo--; + } + if (KW === true && ul === false && ur === false && ammo > 0) { + createPixel("cfj_b_u",pixel.x,pixel.y-4); + ammo--; + } + if (KS === true && dl === false && dr === false && ammo > 0) { + createPixel("cfj_b_d",pixel.x,pixel.y+4); + ammo--; + } + if (KA === true && KW === true && ammo > 0) { + createPixel("cfj_b_ul",pixel.x-4,pixel.y-4); + ul = true; + ammo--; + } + if (KD === true && KW === true && ammo > 0) { + createPixel("cfj_b_ur",pixel.x+4,pixel.y-4); + ur = true; + ammo--; + } + if (KA === true && KS === true && ammo > 0) { + createPixel("cfj_b_dl",pixel.x-4,pixel.y-4); + dl = true; + ammo--; + } + if (KD === true && KS === true && ammo > 0) { + createPixel("cfj_b_dr",pixel.x+4,pixel.y+4); + dr = true; + ammo--; + } + } + }, + category: "cfj", + states:"solid", + color:"#FFFFFF", +}, +elements.cfj_missile_left = { + color: "#524c41", + category: "cfj", + state: "solid", + behavior: [ + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|M1|XX|EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x-1, pixel.y)) { + if (!isEmpty(pixel.x-1, pixel.y,true)) { + } + } + } + }, + density: 1300, + excludeRandom: true, + cooldown: defaultCooldown, + ignore: "cfj", +}, +elements.cfj_missile_right = { + color: "#524c41", + category: "cfj", + state: "solid", + behavior: [ + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX|M1|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x+1, pixel.y)) { + if (!isEmpty(pixel.x+1, pixel.y,true)) { + } + } + } + }, + density: 1300, + excludeRandom: true, + cooldown: defaultCooldown, + ignore: "cfj", +}, +elements.cfj_missile_up = { + color: "#524c41", + category: "cfj", + state: "solid", + behavior: [ + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|M1 AND EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x, pixel.y-1)) { + if (!isEmpty(pixel.x, pixel.y-1,true)) { + } + } + } + }, + density: 1300, + excludeRandom: true, + cooldown: defaultCooldown, + ignore: "cfj", +}, +elements.cfj_missile_down = { + color: "#524c41", + category: "cfj", + state: "solid", + behavior: [ + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX||EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|M1 AND EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel", + "XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x, pixel.y+1)) { + if (!isEmpty(pixel.x, pixel.y+1,true)) { + } + } + } + }, + density: 1300, + excludeRandom: true, + cooldown: defaultCooldown, + ignore: "cfj", +}, +elements.missile_shrapnel = { + color: "#71797E", + behavior: [ + "XX|XX|XX", + "XX|EX:5 %20|XX", + "M2%20|M1%20|M2%20", + ], + burn: 90, + burnTime: 100, + density: 2000, + conduct: 1, + state: "solid", + category: "ammunition" +}, +elements.cfj_b_l = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x-3, pixel.y)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_r = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], +tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x+3, pixel.y)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_u = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x, pixel.y-3)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_d = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x, pixel.y+3)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_ul = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], +tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x-3, pixel.y-3)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_dl = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x-3, pixel.y+3)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_ur = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x+3, pixel.y-3)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +}, +elements.cfj_b_dr = { + color: "#4c4e42", + behavior: [ + "DB|DB|DB", + "DB|XX|DB", + "DB|DB|DB", + ], + tick: function(pixel) { + for (var i=0; i<3; i++) { + if (!tryMove(pixel, pixel.x+3, pixel.y+3)) { + deletePixel(pixel.x,pixel.y) + } + } + }, + category: "cfj", + state: "solid", + insulate: true, + ignore: "cfj", +} \ No newline at end of file From e9d32f3b151724b94ef4a62396bfa14b2c6749d9 Mon Sep 17 00:00:00 2001 From: Jayd-Rubies <155784127+Jayd-Rubies@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:59:44 -0400 Subject: [PATCH 18/25] Update mod-list.html --- mod-list.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mod-list.html b/mod-list.html index 410055e9..67696557 100644 --- a/mod-list.html +++ b/mod-list.html @@ -220,6 +220,7 @@ Weapons aircrafts.jsAdds aircraft and aircraft part pixelsJayd +c_aircraft.jsAdds a controllable fighter jet, wasd to move, q+wasd to shoot, gvbn for missiles.Jayd icb.jsAdds various levels of nested cluster bombsAlice life_eater.jsAdds Warhammer 40,000’s Life-Eater Virus and Virus BombsAlice liquid_void.jsAdds a liquid variant of VoidAlice From 3e77871163b5064c9846498692fa42824174cd23 Mon Sep 17 00:00:00 2001 From: slweeb <91897291+slweeb@users.noreply.github.com> Date: Thu, 6 Jun 2024 22:08:47 -0400 Subject: [PATCH 19/25] Update mod-list.html --- mod-list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod-list.html b/mod-list.html index 67696557..95c93260 100644 --- a/mod-list.html +++ b/mod-list.html @@ -126,7 +126,7 @@ buildingreplicator.jsScans and replicates builds anywhere on the screen, along with some preset submitted buildsnousernamefound change.jsAdds a tool that only replaces existing pixelsAlice color_tools.jsAdds tools that manipulate colorsAlice -controllable_pixel.jsAdds A pixel controlled using wasd (keyboard required)Jayd +controllable_pixel.jsAdds a pixel controlled using WASD (keyboard required)Jayd controllable_pixel_test.jsAdds a pixel that can be controlled with the keyboard keys. Read the commit description for more info. [PC ONLY]Alice cpt_alt.jsAdds a more destructive variant of the controllable pixelAlice debugRework.jsRevamps the Debug toolFioushemastor From 35b5475e5a3f9160e82e94dff1bfb7387c30fe9c Mon Sep 17 00:00:00 2001 From: redbirdly <155550833+redbirdly@users.noreply.github.com> Date: Sat, 8 Jun 2024 08:56:42 +0800 Subject: [PATCH 20/25] Update fast_lightmap.js --- mods/fast_lightmap.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mods/fast_lightmap.js b/mods/fast_lightmap.js index 58cd9553..f572cb1d 100644 --- a/mods/fast_lightmap.js +++ b/mods/fast_lightmap.js @@ -266,8 +266,19 @@ elements.plasma.tick = function(pixel) { }; // Wait for loading -// if it loads too soon then width will be undefined -setTimeout(() => { initializeLightmap(width, height); }, 700); +let i = 0; +let interval = setInterval(() => { + if (typeof width !== 'undefined') { + clearInterval(interval); + initializeLightmap(width, height); + } + i += 1; + // if width is not defined for 3 seconds or longer, it's probably broken, so it will just try run the function anyways to see the error + if (i >= 30) { + clearInterval(interval); + initializeLightmap(width, height); + } +}, 100); // Add code to functions instead of replacing them let originalTick = tick; From 8c4817caf1cf980ca06660ae367dae3266cda328 Mon Sep 17 00:00:00 2001 From: redbirdly <155550833+redbirdly@users.noreply.github.com> Date: Sat, 8 Jun 2024 08:57:13 +0800 Subject: [PATCH 21/25] Update lightmap.js From 0c728c30f928b11e3734d21ee461e6e86a52eb6a Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:33:45 -0700 Subject: [PATCH 22/25] Update Batteries.js --- mods/Batteries.js | 275 +++++++++++++++++++++++++++++----------------- 1 file changed, 176 insertions(+), 99 deletions(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index 5c51c78c..e0d668c1 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -96,116 +96,193 @@ elements.radio_wave= { reactions: {electric: {elem1: null, elem2: null, chance: 0.5}}, density: 1, //charge: 0.5, - conduct: 0.01 + conduct: 0.01, + ignore: ["radio_wave"], }; + elements.e_nuke = { - desc: "Works like the nuke but needs power to explode", - color: "#534636", - hardness: elements.nuke.hardness, + desc: "Works like a nuke but needs power to explode", + color: elements.nuke.color, + hardness: 0.5, state: "solid", - behavior: [ - "XX|XX|XX", - "XX|XX|XX", - "M2|M1|M2", - ], + behavior: behaviors.POWDER, conduct: 1, category: "weapons", - behaviorOn:[ + behaviorOn: [ "XX|XX|XX", "XX|XX|XX", "M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2", ], + name: "E-Nuke", }; -elements.10_timer= { - color: ["#000000"], - behavior: behaviors.WALL, - colorOn: "#000000", - conduct: 0, - category: "machines", - properties: { - wait: 15, - waitReduce: false, - }, - tick: function(pixel){ - if (pixel.waitReduce){pixel.wait -= 1} - if (pixel.wait == 0){ - pixel.elementsSeen = {} - } - for (var i = 0; i < adjacentCoords.length; i++) { - var coord = adjacentCoords[i]; - var x = pixel.x+coord[0]; - var y = pixel.y+coord[1]; - if (!isEmpty(x,y, true)){ - if (!pixel.waitReduce){ - pixel.waitReduce = true - }, - if (pixel.wait == 0){ - if (!pixel.elementsSeen[pixelMap[x][y].element] && pixelMap[x][y].element != "healing_serum"){ - pixel.elementsSeen[pixelMap[x][y].element] = 1 - } else if (pixelMap[x][y].element != "healing_serum") { - pixel.elementsSeen[pixelMap[x][y].element] += 1 +elements.drill = { + color: ["#a7ab81","#a3a685", "#9ba252"], + tick: function(pixel) { + for (var i = 0; i < 3; i++) { + var skip = false; + if (!isEmpty(pixel.x,pixel.y+1,true)) { + var p = pixelMap[pixel.x][pixel.y+1]; + if (p.element === "drill") { skip = true; } + if (Math.random() < 0.9 && elements[p.element].hardness !== 1) { + deletePixel(p.x,p.y); + } + } + if (!tryMove(pixel,pixel.x,pixel.y+1,["flash","smoke"]) && !skip) { + explodeAt(pixel.x,pixel.y,5,"flash"); + var coords = circleCoords(pixel.x,pixel.y,2); + coords.forEach(function(coord){ + var x = coord.x; + var y = coord.y; + if (!isEmpty(x,y,true)) { + pixelMap[x][y].temp += 55; + pixelTempCheck(pixelMap[x][y]); } - } - } - if (pixel.wait == 0){ - if (Object.keys(pixel.elementsSeen).length == 0){ - deletePixel(pixel.x, pixel.y) - return; - } else{ - changePixel(pixel, Object.keys(pixel.elementsSeen).reduce((a, b) => pixel.elementsSeen[a] > pixel.elementsSeen[b] ? a : b)) - } + }) + deletePixel(pixel.x,pixel.y); + return; } } - } -} -elements.gasoline_engine = { - color: "#6d5f5d", - behavior: behaviors.WALL, - state: "solid", - density: 1000, - category: "testing", - properties: { - timer: 10 - }, - tick: function(pixel){ - if (pixel.timer <= 40){ - if(!pixel.timer){pixel.timer = 0} - pixel.timer -= 10 - } - else if (otherPixel.element == "gasoline_engine"){ - var otherPixel = pixelMap[x][y] - var otherShock = otherPixel.timer || 0 - var currentShock = pixel.timer || 0 - if (otherShock == currentShock){break;} - if (otherShock > currentShock){ - otherPixel.timer -- - pixel.timer ++ - } else { - otherPixel.timer ++ - pixel.timer -- - } - } - } - }} - if (!pixel.charge && !pixel.chargeCD && pixel.timer){ - for (var i = 0; i < adjacentCoords.length; i++){ - var coord = adjacentCoords[i] - var x = pixel.x + coord[0] - var y = pixel.y + coord[1] - if (!isEmpty(x, y, true)){ - if (elements[pixelMap[x][y]].conduct > 0){ - pixel.charge = 1 - pixel.timer -- - break; - } - } - } - } - } -} - category: "energy", - reactions: {electric: {elem1: null, elem2: null, chance: 0.5}}, - density: 1, - //charge: 0.5, - conduct: 0 + }, + category: "weapons", + state: "solid", + density: 100000000, + temp: 55, + hardness: 1, + maxSize: 3, + cooldown: defaultCooldown, + excludeRandom: true, }; +elements.holy_hand_grenade = { + color: elements.gold.color, + behavior: [ + "XX|EX:6>god_ray,bless,bless,bless%1|XX", + "XX|XX|XX", + "M2|M1 AND EX:6>god_ray,bless,bless,bless%1|M2", + ], + behaviorOn: [ + "XX|XX|XX", + "XX|EX:6>god_ray,bless,bless,bless%1|XX", + "XX|XX|XX", + ], + category: "weapons", + state: "solid", + density: 1300, + tempHigh: 1455.5, + stateHigh: ["molten_steel", "god_ray"], + excludeRandom: true, + conduct: 1, + cooldown: defaultCooldown, +}; +//Fioushemastor (Aparently needlessly complicated. IDK) +elements.timer_input = { + color: "#4d0a03", + behavior: behaviors.WALL, + category: "machines", + insulate: true, + conduct: 1, + noMix: true + } + + let TimerDelay = 100 + elements.Timer = { + color: "#838cc2", + behavior: behaviors.WALL, + tick: function(pixel){ + if (pixelTicks == pixel.start) { + pixel.delay = TimerDelay + } + //ceck all surroundings + for (let offset of adjacentCoords) { + if (isEmpty(pixel.x+offset[0], pixel.y+offset[1])) continue; + if (pixelMap[pixel.x+offset[0]][pixel.y+offset[1]].charge && pixelMap[pixel.x+offset[0]][pixel.y+offset[1]].element == "timer_input") { + let oppositeCoords = {x: pixel.x-offset[0], y: pixel.y-offset[1]} + pixel.timers.push({start: pixelTicks, coords: oppositeCoords, delay: pixel.delay}) + } + } + //go through all timers + for (let index in pixel.timers) { + let timer = pixel.timers[index] + if (timer.start == pixelTicks-pixel.delay) { + if (isEmpty(timer.coords.x, timer.coords.y, true)) continue; + pixelMap[timer.coords.x][timer.coords.y].charge = 1 + pixel.timers.splice(index, 1) + } + } + + }, + onSelect: () => { + TimerDelay = prompt("what shall the delay be? (in ticks)", 100) + }, + colorOn: "#ffff59", + category: "machines", + tempHigh: 1455.5, + stateHigh: "molten_steel", + conduct: 0, + properties: { + timers: [], + delay: 100 + } + }; + +//ExtraMachines +elements.titanium = { + desc: "Another metal that does not erode nor conduct electricity", + conduct: 0, + color: ["#a1ada5","#ebf5ee","#bac2bc","#848a86","#505251"], + tempHigh:3000, + stateHigh: "molten_titanium", + category: "solids", + state: "soild", + hardness: 1, + density: 792, + behavior: behaviors.WALL, +}; + +elements.molten_titanium = { + desc: "Melted version of titanium", + temp : 3000, + conduct: 0, + color: ["#d16e04","#FFCC99","#FF6600","#FF7F50","#DC143C","#800020"], + tempLow:2999, + stateLow: "titanium", + category: "states", + state: "soild", + density: 792, + behavior: behaviors.MOLTEN, +}; +textures.Reniforced_Titanuim = { + REINFORCEDTITANIUM: [ + "GiGgggGiGGg", + "gggGGGGgggg", + "iiiiiiiiiii", + "GgGGggggGGg", + "GggGGgggGGg", + "igGGGgggggi", + "GggggggGGGG", + "GggGGgggggg", + "Ggggggggggg", + "ggggggGGggg", + "Ggggggggggg", + "iiiiiiiiiii",], + + +}; + +elements.Reniforced_Titanuim = { + color: "#787878", + colorPattern: textures.Reniforced_Titanuim.REINFORCEDTITANIUM, + colorKey: { + "g": "#787878", + "G": "#606060", + "i": "#332f2f"}, + behavior: behaviors.WALL, + + tempHigh: 4000, + stateHigh : "molten_titanium", + category: "solids", + state: "solid", + density: 5000, + hardness:1, + noMix: true +}; + From a8e005993dde55af5313f31b7e1a204896d06cb1 Mon Sep 17 00:00:00 2001 From: Jayd-Rubies <155784127+Jayd-Rubies@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:30:42 -0400 Subject: [PATCH 23/25] Update mod-list.html --- mod-list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod-list.html b/mod-list.html index 95c93260..e1b5416e 100644 --- a/mod-list.html +++ b/mod-list.html @@ -220,7 +220,7 @@ Weapons aircrafts.jsAdds aircraft and aircraft part pixelsJayd -c_aircraft.jsAdds a controllable fighter jet, wasd to move, q+wasd to shoot, gvbn for missiles.Jayd +c_fighter_jet.jsAdds a controllable fighter jet, wasd to move, q+wasd to shoot, gvbn for missiles.Jayd icb.jsAdds various levels of nested cluster bombsAlice life_eater.jsAdds Warhammer 40,000’s Life-Eater Virus and Virus BombsAlice liquid_void.jsAdds a liquid variant of VoidAlice From cf17a674a358c6c29cae386d7ee042a8d1646a84 Mon Sep 17 00:00:00 2001 From: slweeb <91897291+slweeb@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:28:37 -0400 Subject: [PATCH 24/25] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 2c19fb06..3bc14fa8 100644 --- a/index.html +++ b/index.html @@ -16754,7 +16754,7 @@ Cancer, Landmine, Grenade, Smoke Grenade">?

Business inquiries? Education stories? Help needed? Email us at contact@R74n.com!

More links: HelpTipsModsMobileOfflinePrivacy

-

Thanks to: Serioustar, ggod, Midi_png, personman, fnl4y, PitsPower, swagg boi, kaeud, WeiChei, Trent, u2ce

+

Thanks to: Serioustar, ggod, Midi_png, personman, fnl4y, PitsPower, swagg boi, moss, kaeud, WeiChei, Trent, u2ce

Sandboxels is developed by R74n. Check out !