Update flipflop.js

This commit is contained in:
felixs-alt 2023-09-27 09:40:09 +02:00 committed by GitHub
parent 94814ba92c
commit 8eb6cc7c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 11 deletions

View File

@ -1,29 +1,33 @@
elements.flipflop = {
properties: {
powerstate: "false",
cooldown: 0,
},
name: "Flip Flop",
color: "#CF300D",
state: "solid",
category: "machines",
tick: function(pixel) {
doHeat(pixel)
doBurning(pixel)
doElectricity(pixel)
console.log(pixel.powerstate)
doHeat(pixel)
doBurning(pixel)
doElectricity(pixel)
let Output = pixelMap[pixel.x+1][pixel.y]
let Input = pixelMap[pixel.x-1][pixel.y]
if (typeof Output !== "undefined" && typeof Input !== "undefined") {
if (Inpput.charge == 0.75) {
conso le.log(Input.charge)
console.log(pixel.cooldown)
if (Input.charge == 0 && pixel.cooldown == 1) {
pixel.cooldown = 0
}
if (Input.charge > 0.5 && pixel.cooldown == 0) {
pixel.cooldown = 1
if (pixel.powerstate == "true") {
pixel.powerstate = "false"
pixel.color = "#CF300D"
Output.charge = 0
pixel.color = "#CF300D"
} else if (pixel.powerstate == "false") {
pixel.powerstate = "true"
pixel.color = "#94CF0D"
Output.charge = 1
pixel.powerstate = "true"
pixel.color = "#94CF0D"
Output.charge = 1
}
} else {
Output.charge = 0