From b90b6d90e535d299f96f686c90a72434af13f42e Mon Sep 17 00:00:00 2001 From: felixs-alt <114471609+felixs-alt@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:05:49 +0200 Subject: [PATCH] Update flipflop.js --- mods/flipflop.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/mods/flipflop.js b/mods/flipflop.js index 7fe25bea..1efb30d4 100644 --- a/mods/flipflop.js +++ b/mods/flipflop.js @@ -13,15 +13,18 @@ elements.flipflop = { let Powerstate = pixel.powerst 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 - } + + if (isEmpty(Output.x,Output.y) == false && isEmpty(Input.x,Input.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 + } + } } };