From 826395a5ac631dba515f74d998d40f471449bbe6 Mon Sep 17 00:00:00 2001 From: felixs-alt <114471609+felixs-alt@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:32:09 +0200 Subject: [PATCH] Create flipflop.js --- mods/flipflop.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 mods/flipflop.js diff --git a/mods/flipflop.js b/mods/flipflop.js new file mode 100644 index 00000000..c60957e7 --- /dev/null +++ b/mods/flipflop.js @@ -0,0 +1,26 @@ +elements.flipflop = { + name: "Flip Flop", + color: "#CF300D", + state: "solid", + category: "machines", + conduct: 1, + tick: function(pixel) { + doHeat(pixel) + doBurning(pixel) + doElectricity(pixel) + + let Powerstate + let Output = pixelMap[pixel.x+1][pixel.y] + let Input = pixelMap[pixel.x-1][pixel.y] + Output.charge = 0 + if (Powerstate == true && Input.charge > 0.9) { + Powerstate == false + pixel.color = "#CF300D" + Output.charge = 0 + } else if (Powerstate == false && Input.charge < 0.9) { + Powerstate == true + pixel.color = "#94CF0D" + Output.charge = 5 + } + } +};