Create flipflop.js

This commit is contained in:
felixs-alt 2023-09-26 10:32:09 +02:00 committed by GitHub
parent cb80394d72
commit 826395a5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 0 deletions

26
mods/flipflop.js Normal file
View File

@ -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
}
}
};