From 10f3ba326b2499005b23bbe5326396319daccf9c Mon Sep 17 00:00:00 2001 From: guzzo86 <126430018+guzzo86@users.noreply.github.com> Date: Sun, 5 May 2024 19:31:58 -0400 Subject: [PATCH] Create colored_lightbulbs.js --- mods/colored_lightbulbs.js | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 mods/colored_lightbulbs.js diff --git a/mods/colored_lightbulbs.js b/mods/colored_lightbulbs.js new file mode 100644 index 00000000..84f8ad85 --- /dev/null +++ b/mods/colored_lightbulbs.js @@ -0,0 +1,44 @@ +elements.colored_light_bulb = { + color: "#666666", + colorOn: "#ffffff", + behavior: behaviors.WALL, + category: "machines", + tempHigh: 1500, + stateHigh: ["molten_glass","molten_glass","molten_copper"], + conduct: 1, + breakInto: "glass_shard", + tick: function(pixel) { + if (pixel.start == pixelTicks) { + pixel.normalColor = pixel.color; + pixel.chargeColor = `rgb(${pixel.color.replace(/[rgb\(\)]/g, "").split(",").map(a => parseInt(a.trim()) + 150).join(", ")})`; + } + if (pixel.color != pixel.normalColor && !pixel.charge && !pixel.chargeCD) { + pixel.normalColor = pixel.color; + pixel.chargeColor = `rgb(${pixel.color.replace(/[rgb\(\)]/g, "").split(",").map(a => parseInt(a.trim()) + 150).join(", ")})`; + } + if (pixel.charge) { + pixel.color = pixel.chargeColor; + } else { + pixel.color = pixel.normalColor; + } + if (pixel.charge > 0) { + for (let i = 0; i < adjacentCoords.length; i++){ + let coord = adjacentCoords[i] + let x = coord[0]+pixel.x + let y = coord[1]+pixel.y + if (isEmpty(x, y)){ + //do crap to the pixel + createPixel("light", x, y,), + pixelMap[x][y].color = pixel.chargeColor + } + } + }} +} +pixelColorPick = (function() { + const oldPixelColorPick = pixelColorPick; + + return function(pixel, customColor = null) { + if (pixel.element == "colored_light_bulb" && pixel.color && !customColor) return pixel.color; + return oldPixelColorPick.apply(this, arguments); + } +})()