Update flipflop.js
This commit is contained in:
parent
94814ba92c
commit
8eb6cc7c30
|
|
@ -1,29 +1,33 @@
|
||||||
elements.flipflop = {
|
elements.flipflop = {
|
||||||
properties: {
|
properties: {
|
||||||
powerstate: "false",
|
powerstate: "false",
|
||||||
|
cooldown: 0,
|
||||||
},
|
},
|
||||||
name: "Flip Flop",
|
name: "Flip Flop",
|
||||||
color: "#CF300D",
|
color: "#CF300D",
|
||||||
state: "solid",
|
state: "solid",
|
||||||
category: "machines",
|
category: "machines",
|
||||||
tick: function(pixel) {
|
tick: function(pixel) {
|
||||||
doHeat(pixel)
|
doHeat(pixel)
|
||||||
doBurning(pixel)
|
doBurning(pixel)
|
||||||
doElectricity(pixel)
|
doElectricity(pixel)
|
||||||
console.log(pixel.powerstate)
|
|
||||||
let Output = pixelMap[pixel.x+1][pixel.y]
|
let Output = pixelMap[pixel.x+1][pixel.y]
|
||||||
let Input = pixelMap[pixel.x-1][pixel.y]
|
let Input = pixelMap[pixel.x-1][pixel.y]
|
||||||
if (typeof Output !== "undefined" && typeof Input !== "undefined") {
|
if (typeof Output !== "undefined" && typeof Input !== "undefined") {
|
||||||
if (Inpput.charge == 0.75) {
|
console.log(pixel.cooldown)
|
||||||
conso le.log(Input.charge)
|
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") {
|
if (pixel.powerstate == "true") {
|
||||||
pixel.powerstate = "false"
|
pixel.powerstate = "false"
|
||||||
pixel.color = "#CF300D"
|
pixel.color = "#CF300D"
|
||||||
Output.charge = 0
|
|
||||||
} else if (pixel.powerstate == "false") {
|
} else if (pixel.powerstate == "false") {
|
||||||
pixel.powerstate = "true"
|
pixel.powerstate = "true"
|
||||||
pixel.color = "#94CF0D"
|
pixel.color = "#94CF0D"
|
||||||
Output.charge = 1
|
Output.charge = 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Output.charge = 0
|
Output.charge = 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue