From fae0f0dd5e3c98808f3b49ef383e7111b42fedc5 Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Sun, 29 Jan 2023 17:10:38 -0500 Subject: [PATCH] Specify elements not conducting to specific elements noConduct: If an element has this property, it will not conduct electricity to the specified elements. --- mods/noConduct.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 mods/noConduct.js diff --git a/mods/noConduct.js b/mods/noConduct.js new file mode 100644 index 00000000..5c6535bb --- /dev/null +++ b/mods/noConduct.js @@ -0,0 +1,43 @@ +function doElectricity(pixel) { + var info = elements[pixel.element]; + if (pixel.charge) { + // Check each adjacent pixel, if that pixel's charge is false, set it to the same charge + for (var i = 0; i < adjacentCoords.length; i++) { + var x = pixel.x+adjacentCoords[i][0]; + var y = pixel.y+adjacentCoords[i][1]; + if (!isEmpty(x,y,true)) { + var newPixel = pixelMap[x][y]; + var con = elements[newPixel.element].conduct; + if (con == undefined) {continue} + if (info.noConduct?.length && info.noConduct.includes(newPixel.element)) {continue}; + if (Math.random() < con) { // If random number is less than conductivity + if (!newPixel.charge && !newPixel.chargeCD) { + newPixel.charge = 1; + if (elements[newPixel.element].colorOn) { + newPixel.color = pixelColorPick(newPixel); + } + } + } + else if (elements[newPixel.element].insulate != true) { // Otherwise heat the pixel (Resistance simulation) + newPixel.temp += pixel.charge/4; + pixelTempCheck(newPixel); + } + } + } + pixel.charge -= 0.25; + if (pixel.charge <= 0) { + delete pixel.charge; + pixel.chargeCD = 4; + } + } + // Lower charge cooldown + else if (pixel.chargeCD) { + pixel.chargeCD -= 1; + if (pixel.chargeCD <= 0) { + delete pixel.chargeCD; + if (info.colorOn) { + pixel.color = pixelColorPick(pixel); + } + } + } +}