Merge pull request #1072 from JustAGenericUsername/main

variable signs
This commit is contained in:
slweeb 2025-03-31 13:36:03 -04:00 committed by GitHub
commit 66ff575f94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 37 additions and 3 deletions

View File

@ -3939,12 +3939,26 @@ renderPostPixel(function(ctx){
if ((pixel.element == "sign") && pixel.sign){
ctx.font = `12pt Arial`
ctx.fillStyle = pixel.color;
ctx.fillText(pixel.sign, canvasCoord(pixel.x), canvasCoord(pixel.y))
ctx.fillText(pixel.sign = pixel.sign.replace(/\$\{([\w.\[\]]+)\}/g, (_, path) => {
try {
const value = new Function('return globalThis.' + path)();
return typeof value === 'object' ? JSON.stringify(value) : value ?? '';
} catch {
return '';
}
}), canvasCoord(pixel.x), canvasCoord(pixel.y))
} else if (pixel.element == "e_sign" && pixel.sign){
if (pixel.charge || pixel.chargeCD){
ctx.font = `12pt Arial`
ctx.fillStyle = pixel.color;
ctx.fillText(pixel.sign, canvasCoord(pixel.x), canvasCoord(pixel.y))
ctx.fillText(pixel.sign = pixel.sign.replace(/\$\{([\w.\[\]]+)\}/g, (_, path) => {
try {
const value = new Function('return globalThis.' + path)();
return typeof value === 'object' ? JSON.stringify(value) : value ?? '';
} catch {
return '';
}
}), canvasCoord(pixel.x), canvasCoord(pixel.y))
} else {
drawSquare(ctx, pixel.color, pixel.x, pixel.y)
}
@ -3974,4 +3988,24 @@ elements.mod_dectector = {
}
}
}
}
}
smoothColor = function(color1, color2, amount){
let rgb1 = getPixelColor({color: color1})
let rgb2 = getPixelColor({color: color2})
return {r:((1-amount)*rgb1.r)+(amount*rgb2.r),g:((1-amount)*rgb1.g)+(amount*rgb2.g),b:((1-amount)*rgb1.b)+(amount*rgb2.b)}
}
/*
elements.delay = {
color: ["#df3b3b","#200909"],
behavior: behaviors.WALL,
category: "machines",
movable: false,
insulate: true,
onSelect: () => {
logMessage("Will delay incoming signals by its temperature in Kelvin. -273C for 0 delay.")
},
tick: function(pixel){
}
}
*/