From 11156ecf9fe444930b40edce57e76af2824eb304 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:17:36 -0400 Subject: [PATCH 1/4] d --- mods/nousersthings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 7af6436b..59fa76cb 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -3104,6 +3104,7 @@ elements.piston_ray_emitter = { var lx = lcoord[0]; var ly = lcoord[1]; if (!isEmpty(lx, ly, true)){ + if (pixelMap[lx][ly].element == "insulator"){break;} tryMove(pixelMap[lx][ly], pCoord[0], pCoord[1], null, true) } pCoord[0] = lx; From 4a77eb6552fa00a4fab882dbf7a108e8ea397f11 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:20:02 -0400 Subject: [PATCH 2/4] g --- mods/10kelements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/10kelements.js b/mods/10kelements.js index f22387d6..a7c371e7 100644 --- a/mods/10kelements.js +++ b/mods/10kelements.js @@ -11,7 +11,7 @@ elements.change_count = { if (!cans) { return } if (cans == "skin"){settings.randomcount = 10000; settings.skineasteregg = true; settings.sandeasteregg = false; saveSettings(); alert("skin"); return} if (cans == "sand"){settings.randomcount = 10000; settings.skineasteregg = false; settings.sandeasteregg = true; saveSettings(); alert("sand"); return} - if (cans > 2000000){alert("You have put too big of a number! This would surely crash your browser or eat up all your RAM! Element count will remain unchanged."); return} + if (cans > 100000){alert("You have put too big of a number! This would surely crash your browser or eat up all your RAM! Element count will remain unchanged."); return} if (cans < 1 && (parseInt(cans) > -1) ){alert("You have either put a decimal or zero. Why? Element count will remain unchanged."); return} if (isNaN(parseInt(cans))){alert("Apparently your input isnt even a number. Try again. Element count will remain unchanged."); return} settings.randomcount = parseInt(cans) @@ -24,7 +24,7 @@ elements.change_count = { var choosebehaviors = behaviors delete choosebehaviors.KILLPIXEL2 delete choosebehaviors.KILLPIXEL1 -if (!settings.randomcount || settings.randomcount > 50000){settings.randomcount = 10000; saveSettings()} +if (!settings.randomcount || settings.randomcount > 100000){settings.randomcount = 10000; saveSettings()} var color = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e","f"] var states = ["solid", "liquid", "gas"] var essentialelements = ["molten_gallium", "gallium", "gallium_gas", "change_count"] From 93f8e452bc8a2e24c8205327c4b1a4cc57f8c340 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Thu, 26 Dec 2024 23:01:27 -0500 Subject: [PATCH 3/4] f --- mod-list.html | 1 + mods/fractals.js | 156 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 mods/fractals.js diff --git a/mod-list.html b/mod-list.html index 65ecc76e..a2b74b4d 100644 --- a/mod-list.html +++ b/mod-list.html @@ -342,6 +342,7 @@ Visual Effects acid_and_shapes.jsWeird visual effects. Enable in SettingsAlice customBackground.jsSet your background to an image linkJayd +fractals.jsAdds an element and tools to render fractals in gamenousernamefound heatglow.jsRed glowing effect for hot metalsnousernamefound invisible_dye.jsAdds elements like Dye and Spray Paint that take the color of the backgroundAlice invisible_wall.jsAdds an element like Wall that takes the color of the backgroundAlice diff --git a/mods/fractals.js b/mods/fractals.js new file mode 100644 index 00000000..b2b7279f --- /dev/null +++ b/mods/fractals.js @@ -0,0 +1,156 @@ +let jmax = 2 +let jmin = -2 +let offsetx = 0 +let offsety = 0 +let mode = `mandelbrot` +preCalculatedGrid = [] +runEveryTick(function(){ + preCalculatedGrid = [] + for (let x = 0; x < pixelMap.length; x++){ + preCalculatedGrid.push([]) + for (let y = 0; y < pixelMap[x].length; y++){ + preCalculatedGrid[x].push({ + x: x, + y: y, + iteration: 100, + }) + } + } + for (let ix = 0; ix < preCalculatedGrid.length; ix++){ + for (let iy = 0; iy < preCalculatedGrid[ix].length; iy++){ + const range = jmax - jmin; + const scale = range / Math.min(width, height); + let x = (ix - width / 2) * scale + offsetx; + let y = (iy - height / 2) * scale + offsety; + let iteration = 0; + if (mode == `mandelbrot`){ + let zx = 0; + let zy = 0; + let c = {x: x, y: y}; + while (zx * zx + zy * zy < 4 && iteration < 100) { + let xtemp = zx * zx - zy * zy + c.x; + zy = 2 * zx * zy + c.y; + zx = xtemp; + iteration++; + }} + else { // burning ship + let zx = 0; + let zy = 0; + let c = {x: x, y: y}; + while (zx * zx + zy * zy < 4 && iteration < 100) { + let xtemp = zx * zx - zy * zy + c.x; + zy = Math.abs(2 * zx * zy) + c.y; + zx = Math.abs(xtemp); + iteration++; + } + } + preCalculatedGrid[ix][iy].iteration = iteration + } + } +}) +elements.mandelbrot = { + color: "#000000", + behavior: behaviors.WALL, + category: "mandelbrot tools", + onSelect: function(){ + jmax = parseFloat(prompt("How far would you like it to extend in each direction?"))||2 + jmin = -jmax + offsetx = parseFloat(prompt("How far would you like it to be offset in the x direction?"))||0 + offsety = parseFloat(prompt("How far would you like it to be offset in the y direction?"))||0 + mode = prompt("Mandelbrot or burning ship?") + }, + tick: function(pixel){ + // first, map canvas coord to a range of -2 to 2, but dont scale it, using width, height, and pixel.x and pixel.y + /* + const range = jmax - jmin; + const scale = range / Math.min(width, height); + const x = (pixel.x - width / 2) * scale + offsetx; + const y = -(pixel.y - height / 2) * scale + offsety; + let iteration = 0; + if (mode == `mandelbrot`){ + let zx = 0; + let zy = 0; + let c = {x: x, y: y}; + while (zx * zx + zy * zy < 4 && iteration < 100) { + let xtemp = zx * zx - zy * zy + c.x; + zy = 2 * zx * zy + c.y; + zx = xtemp; + iteration++; + }} + else { // burning ship + let zx = 0; + let zy = 0; + let c = {x: x, y: y}; + while (zx * zx + zy * zy < 4 && iteration < 100) { + let xtemp = zx * zx - zy * zy + c.x; + zy = Math.abs(2 * zx * zy) + c.y; + zx = Math.abs(xtemp); + iteration++; + } + } + */ + iteration = gridWeightedAverage(pixel.x, pixel.y) + if (iteration >= 99.5) { + pixel.color = "rgb(255, 255, 255)" + } else { + pixel.color = `rgb(0, ${67.3684*Math.pow(1.01578, iteration)-67.3684}, ${67.3684*Math.pow(1.01578, iteration)-67.3684})` + //console.log(iteration) + } + } +} +elements.mandelbrot_zoom_in = { + color: elements.heater.color, + category: "mandelbrot tools", + canPlace: false, + tool: function(){}, + onSelect: function(){ + jmax *= 0.95 + jmin = -jmax + } +} +elements.mandelbrot_zoom_out = { + color: elements.cooler.color, + category: "mandelbrot tools", + canPlace: false, + tool: function(){}, + onSelect: function(){ + jmax *= 1.05 + jmin = -jmax + } +} +elements.mandelbrot_move_left = { + color: elements.grape.color, + category: "mandelbrot tools", + canPlace: false, + tool: function(){}, + onSelect: function(){ + offsetx -= 0.05*jmax + } +} +elements.mandelbrot_move_right = { + color: elements.tomato.color, + category: "mandelbrot tools", + canPlace: false, + tool: function(){}, + onSelect: function(){ + offsetx += 0.05*jmax + } +} +elements.mandelbrot_move_up = { + color: elements.mix.color, + category: "mandelbrot tools", + canPlace: false, + tool: function(){}, + onSelect: function(){ + offsety += 0.05*jmax + } +} +elements.mandelbrot_move_down = { + color: elements.drag.color, + category: "mandelbrot tools", + canPlace: false, + tool: function(){}, + onSelect: function(){ + offsety -= 0.05*jmax + } +} \ No newline at end of file From 10adc9968232dfe621aad7ba11887189eb07f244 Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Sat, 28 Dec 2024 22:39:50 -0500 Subject: [PATCH 4/4] the funny pipe portals --- mods/nousersthings.js | 96 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 59fa76cb..5a94537c 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -358,14 +358,14 @@ elements.destroyable_pipe = { var y = pixel.y+coord[1]; if (!isEmpty(x,y,true)) { var newPixel = pixelMap[x][y]; - if (newPixel.element === "destroyable_pipe" || newPixel.element === "bridge_pipe") { + if (newPixel.element === "destroyable_pipe" || newPixel.element === "bridge_pipe" || newPixel.element === "pipe_transmitter") { var nextStage; switch (pixel.stage) { case 2: nextStage = 4; break; //green case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter")) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -669,14 +669,14 @@ elements.e_pipe = { var y = pixel.y+coord[1]; if (!isEmpty(x,y,true)) { var newPixel = pixelMap[x][y]; - if (newPixel.element === "e_pipe" || newPixel.element === "bridge_pipe") { + if (newPixel.element === "e_pipe" || newPixel.element === "bridge_pipe" || newPixel.element === "pipe_transmitter") { var nextStage; switch (pixel.stage) { case 2: nextStage = 4; break; //green case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage && (pixel.charge || pixel.chargeCD)) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter") && (pixel.charge || pixel.chargeCD)) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -787,14 +787,14 @@ elements.destroyable_e_pipe = { var y = pixel.y+coord[1]; if (!isEmpty(x,y,true)) { var newPixel = pixelMap[x][y]; - if (newPixel.element === "destroyable_e_pipe" || newPixel.element === "bridge_pipe") { + if (newPixel.element === "destroyable_e_pipe" || newPixel.element === "bridge_pipe" || newPixel.element === "pipe_transmitter") { var nextStage; switch (pixel.stage) { case 2: nextStage = 4; break; //green case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage && (pixel.charge || pixel.chargeCD)) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter") && (pixel.charge || pixel.chargeCD)) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -914,14 +914,14 @@ elements.channel_pipe = { var y = pixel.y+coord[1]; if (!isEmpty(x,y,true)) { var newPixel = pixelMap[x][y]; - if ((newPixel.element === "channel_pipe" && pixelMap[x][y].channel == pixel.channel || newPixel.element === "bridge_pipe")) { + if ((newPixel.element === "channel_pipe" && pixelMap[x][y].channel == pixel.channel || newPixel.element === "bridge_pipe" || (newPixel.element === "pipe_transmitter" && pixelMap[x][y].channel == pixel.channel))) { var nextStage; switch (pixel.stage) { case 2: nextStage = 4; break; //green case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter")) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -1037,14 +1037,14 @@ elements.destroyable_channel_pipe = { var y = pixel.y+coord[1]; if (!isEmpty(x,y,true)) { var newPixel = pixelMap[x][y]; - if ((newPixel.element === "destroyable_channel_pipe" && pixelMap[x][y].channel == pixel.channel) || newPixel.element === "bridge_pipe") { + if ((newPixel.element === "destroyable_channel_pipe" && pixelMap[x][y].channel == pixel.channel) || newPixel.element === "bridge_pipe" || (newPixel.element === "pipe_transmitter" && pixelMap[x][y].channel == pixel.channel)) { var nextStage; switch (pixel.stage) { case 2: nextStage = 4; break; //green case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter")) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -1097,7 +1097,7 @@ elements.destroyable_channel_pipe = { movable: false, canContain: true, }, -listPipes = ["pipe", "destroyable_pipe", "destroyable_e_pipe","channel_pipe","destroyable_channel_pipe","bridge_pipe","e_pipe"]; +listPipes = ["pipe", "destroyable_pipe", "destroyable_e_pipe","channel_pipe","destroyable_channel_pipe","bridge_pipe","e_pipe","pipe_transmitter"]; elements.bridge_pipe = { color: "#414c4f", onSelect: function() { @@ -1161,7 +1161,7 @@ elements.bridge_pipe = { case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter")) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -1266,14 +1266,14 @@ elements.pipe.tick = function(pixel) { var y = pixel.y+coord[1]; if (!isEmpty(x,y,true)) { var newPixel = pixelMap[x][y]; - if (newPixel.element === "pipe" || newPixel.element === "bridge_pipe") { + if (newPixel.element === "pipe" || newPixel.element === "bridge_pipe" || newPixel.element === "pipe_transmitter") { var nextStage; switch (pixel.stage) { case 2: nextStage = 4; break; //green case 3: nextStage = 2; break; //red case 4: nextStage = 3; break; //blue } - if (pixel.con && !newPixel.con && newPixel.stage === nextStage) { //transfer to adjacent pipe + if (pixel.con && !newPixel.con && (newPixel.stage === nextStage || newPixel.element === "pipe_transmitter")) { //transfer to adjacent pipe newPixel.con = pixel.con; newPixel.con.x = newPixel.x; newPixel.con.y = newPixel.y; @@ -3759,4 +3759,72 @@ elements.hotter_sensor = { } } } +} +let pipe_transmitter_channelVar = 0; +elements.pipe_transmitter = { + color: "#6e6250", + category: "machines", + movable: false, + canContain: true, + insulate: true, + onSelect: () => { + let newChannel = prompt("Enter the channel of this pipe transmitter. It will not work if you do multiple while paused.", pipe_transmitter_channelVar); + pipe_transmitter_channelVar = newChannel; + }, + tick: (pixel) => { + if (!pixel.channel){ + pixel.channel = pipe_transmitter_channelVar; + } + if (pixel.channel && pixel.con){ + for (x in pixelMap){ + for (y in pixelMap[x]){ + if (!isEmpty(x, y, true)){ + if (pixelMap[x][y].element == "pipe_receiver" && pixelMap[x][y].channel == pixel.channel){ + pixelMap[x][y].con = pixel.con; + delete pixel.con; + } + } + } + } + } + } +} +let pipe_receiver_channelVar = 0; +elements.pipe_receiver = { + color: "#4d4b63", + category: "machines", + movable: false, + canContain: true, + insulate: true, + onSelect: () => { + let newChannel = prompt("Enter the channel of this pipe receiver. It will not work if you do multiple while paused.", pipe_receiver_channelVar); + pipe_receiver_channelVar = newChannel; + }, + tick: (pixel) => { + if (!pixel.channel){ + pixel.channel = pipe_receiver_channelVar; + } + if (pixel.channel && pixel.con){ + // just scan neighbors for elements on the pipe list; transfer con to them. if its a type of channel pipe, also check if channel matches + for (i = 0; i < squareCoords.length; i++){ + let x = squareCoords[i][0] + pixel.x; + let y = squareCoords[i][1] + pixel.y; + if (!isEmpty(x, y, true)){ + if (listPipes.includes(pixelMap[x][y].element)){ + if (["channel_pipe", "destroyable_channel_pipe"].includes(pixelMap[x][y].element)){ + if (pixelMap[x][y].channel == pixel.channel){ + pixelMap[x][y].con = pixel.con; + delete pixel.con; + } + } else { + pixel.con.x = x; + pixel.con.y = y; + pixelMap[x][y].con = pixel.con; + delete pixel.con; + } + } + } + } + } + } } \ No newline at end of file