From 39f62a1e5a59bb4a469d4b8bf6d00ac6f089b60e Mon Sep 17 00:00:00 2001 From: pennylicker6 Date: Mon, 4 Aug 2025 13:38:34 -0800 Subject: [PATCH] Create fission_physics.js this is not my mod tho. it is senseiollies. he asked me to upload the file to GitHub cause safari hates GitHub. --- mods/fission_physics.js | 96 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 mods/fission_physics.js diff --git a/mods/fission_physics.js b/mods/fission_physics.js new file mode 100644 index 00000000..4347561c --- /dev/null +++ b/mods/fission_physics.js @@ -0,0 +1,96 @@ +// Basic Fission Mod for Sandboxels +// Simulates simplified nuclear fission with uranium-235, neutrons, and boron control rods. + +// Uranium-235: emits 2-3 neutrons when hit by a neutron, heats up, no byproducts. +elements.uranium235 = { + color: "#4a7023", // dark green (uranium oxide green) + behavior: behaviors.SOLID, + category: "Energy", + state: "solid", + density: 19050, + conduct: 0.05, + reactions: { + "neutron": { + chance: 1, + func: function(pixel, otherPixel) { + // Remove incoming neutron + deletePixel(otherPixel.x, otherPixel.y); + + // Increase heat + pixel.temp += 200 + Math.random() * 100; + + // Emit 2-3 new neutrons nearby + let count = Math.floor(Math.random() * 2) + 2; + for(let i = 0; i < count; i++) { + let x = pixel.x + Math.floor(Math.random() * 3) - 1; + let y = pixel.y + Math.floor(Math.random() * 3) - 1; + if(!isEmpty(x, y)) continue; + createPixel("neutron", x, y); + } + } + } + } +}; + +// Neutron particle: moves around and disappears after 500 ticks. +elements.neutron = { + color: "#dcdcdc", // light gray / off-white + behavior: [ + "M2|M1|M2", + "M1|DL|M1", + "M2|M1|M2" + ], + category: "Energy", + state: "gas", + density: 0.001, + temp: 20, + tick: function(pixel) { + pixel._neutronLife = (pixel._neutronLife || 0) + 1; + if(pixel._neutronLife > 500) { + deletePixel(pixel.x, pixel.y); + } + } +}; + +// Boron: solid that absorbs neutrons and heats up slightly. +elements.boron = { + color: "#f5f0a1", // pale yellow + behavior: behaviors.SOLID, + category: "Solids", + state: "solid", + density: 2460, + reactions: { + "neutron": { + chance: 1, + func: function(pixel, otherPixel) { + deletePixel(otherPixel.x, otherPixel.y); + pixel.temp += 5; + } + } + } +}; + +// Slow neutrons and some particles passing through water by 20%. +const slowThroughWater = ["neutron", "proton", "photon"]; +for(let elem of slowThroughWater) { + if(elements[elem]) { + elements[elem].customTick = function(pixel) { + let waterNearby = false; + let dirs = [[0,1],[0,-1],[1,0],[-1,0]]; + for(let dir of dirs) { + let x = pixel.x + dir[0]; + let y = pixel.y + dir[1]; + let other = pixelMap[x]?.[y]; + if(other && other.element === "water") { + waterNearby = true; + break; + } + } + if(waterNearby && Math.random() < 0.2) { + // Skip tick to slow particle + return; + } + } + } +} +