From 753b5e899b5921df8123951a76b1c998804fea80 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Sat, 11 May 2024 16:49:18 -0400 Subject: [PATCH 1/2] ray emitter --- mods/nousersthings.js | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 524b532e..2f312c02 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -2696,4 +2696,85 @@ elements.healing_serum = { } } } +} +var rayElement = "pointer" +var rayStoppedByWalls = false +elements.ray_emitter = { + color: "#ff9c07", + behavior: behaviors.WALL, + category: "machines", + movable: false, + onSelect: function(pixel){ + var rayans = prompt("Please input the desired element of this ray emitter",(rayElement||undefined)); + if (!rayans) { return } + rayElement = mostSimilarElement(rayans); + var rayans2 = prompt("Should the ray stop by walls? Write true or false.",(rayStoppedByWalls||false)); + if (!rayans2 || rayans2 !== "true" || rayans2 !== "false") { return } + }, + hoverStat: function(pixel){ + return pixel.rayElement.toUpperCase() || "unset" + }, + tick: function(pixel){ + if (pixelTicks == pixel.start){ + pixel.rayElement = rayElement + pixel.rayStoppedByWalls = rayStoppedByWalls + } + for (var i = 0; i < squareCoords.length; i++) { + var coord = squareCoords[i]; + var x = pixel.x+coord[0]; + var y = pixel.y+coord[1]; + if (!isEmpty(x,y, true)){ + if (pixelMap[x][y].charge && pixelMap[x][y].element == "wire"){ + var dir = [0-squareCoords[i][0], 0-squareCoords[i][1]] + var startx = pixel.x+dir[0] + var starty = pixel.y+dir[1] + var magnitude = 0 + if (width > height){magnitude = width} else {magnitude = height} + var endx = startx+(magnitude*dir[0]) + var endy = starty+(magnitude*dir[1]) + // console.log("Direction seems to be " + dir) + var jcoords = lineCoords(startx, starty, endx, endy, 1) + // console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords) + for (var j = 0; j < jcoords.length; j++) { + var lcoord = jcoords[j]; + var lx = lcoord[0]; + var ly = lcoord[1]; + // console.log(lcoord) + if (isEmpty(lx,ly)){ + createPixel(pixel.rayElement, lx, ly) + pixelMap[lx][ly].temp = pixelMap[x][y].temp + } else if (!isEmpty(lx, ly, true)){ + if (pixelMap[lx][ly].element != pixel.rayElement && pixel.rayStoppedByWalls){ + break; + } + } + } + } + } + } + }, + insulate: true, +} +elements.indestructible_battery = { + color: elements.battery.color, + behavior: elements.battery.behavior, + category: elements.battery.category +} +elements.ray = { + color: "#ffffff", + behavior: behaviors.WALL, + category: "special", + hoverStat: function(pixel){ + return pixel.life || "unset" + }, + properties: { + life: 30 + }, + tick: function(pixel){ + pixel.life -= 1 + pixel.color = "rgba(255,255,255,"+(pixel.life/30)+")" + if (pixel.life <= 0){ + deletePixel(pixel.x, pixel.y) + } + } } \ No newline at end of file From a62b38f8383849a85670d465d685cfe52995bdf7 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Sat, 11 May 2024 16:50:26 -0400 Subject: [PATCH 2/2] f --- mods/nousersthings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 2f312c02..4c21a709 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -2697,7 +2697,7 @@ elements.healing_serum = { } } } -var rayElement = "pointer" +var rayElement = "ray" var rayStoppedByWalls = false elements.ray_emitter = { color: "#ff9c07",