more antiNaN

This commit is contained in:
Laetitia (O-01-67) 2023-03-05 16:51:24 -05:00 committed by GitHub
parent 679a184121
commit 860fd733cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1,9 +1,8 @@
//console.log("doElectricity should be changed");
function doElectricity(pixel) {
if(typeof(pixel.charge) == "number" && isNaN(pixel.charge)) {
if(isNaN(pixel.charge)) {
pixel.charge = 0;
return;
};
if (pixel.charge) {
// Check each adjacent pixel, if that pixel's charge is false, set it to the same charge
@ -21,6 +20,8 @@ function doElectricity(pixel) {
newPixel.color = pixelColorPick(newPixel);
}
if(elements[newPixel.element].onCharge) {
pixel.charge ??= 0;
if(isNaN(pixel.charge)) { pixel.charge = 0 };
elements[newPixel.element].onCharge(pixel);
};
}