sandboxels/mods/flipflop.js

31 lines
771 B
JavaScript
Raw Normal View History

2023-09-26 04:32:09 -04:00
elements.flipflop = {
2023-09-26 04:38:08 -04:00
powerstate: "false",
2023-09-26 04:32:09 -04:00
name: "Flip Flop",
2023-09-26 04:38:08 -04:00
color: "#CF300D",
2023-09-26 04:32:09 -04:00
state: "solid",
2023-09-26 04:38:08 -04:00
category: "machines",
2023-09-26 04:32:09 -04:00
conduct: 1,
tick: function(pixel) {
doHeat(pixel)
doBurning(pixel)
doElectricity(pixel)
2023-09-26 04:38:08 -04:00
let Powerstate = pixel.powerst
let Output = pixelMap[pixel.x+1][pixel.y]
let Input = pixelMap[pixel.x-1][pixel.y]
2023-09-26 06:29:04 -04:00
console.log(Output)
if (typeof Output !== "null" && typeof Input !== "null"){
2023-09-26 06:05:49 -04:00
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
}
}
2023-09-26 04:32:09 -04:00
}
};