Make an advanced powder toy mod in lua that adds a super strong glass material, which is…
- User
Make an advanced powder toy mod in lua that adds a super strong glass material, which is a;
Concept: Nanofused Graphene-Glass Composite
Key Components:
-
Ultra-high Strength Borosilicate Base:
- The foundation of this glass would be borosilicate glass, known for its exceptional durability, heat resistance, and chemical stability (like Pyrex). Borosilicate glass already has a high breaking strength compared to standard glass, but this concept would elevate it further.
-
Graphene Nano-Infusion:
- The glass structure would incorporate graphene layers embedded at the nanoscale level within the borosilicate matrix. Graphene is one of the strongest materials on Earth, with an immense tensile strength (130 GPa). By incorporating graphene sheets between layers of glass, the material would have extraordinary resistance to cracking and flexing.
- These graphene layers act like a nano-reinforcement network, redistributing stress forces that would typically cause glass to shatter.
-
Amorphous Metal Interweaving:
- To enhance resilience against sudden impacts or sharp blows, the material could be infused with amorphous metallic alloys at a microstructural level. This would prevent the propagation of cracks by absorbing and redistributing energy from impacts. Amorphous metals (also known as metallic glasses) are known for their strength and flexibility, which could lend more flexibility to the rigid glass structure.
-
Hierarchical Microstructure:
- The internal structure of the glass would be designed using a hierarchical pattern, inspired by tough biological materials like seashells or nacre (mother of pearl). These natural structures create an internal layered arrangement of materials that effectively resist cracks and breaks. When force is applied, the crack would be forced to navigate through a tortuous path, preventing sudden failure.
-
Self-Healing Properties:
- The material could incorporate self-healing polymers at micro-crack locations. When a small crack forms, the polymers would flow and bond, sealing the crack before it expands into a full break. This would increase the lifespan of the glass, though it would not make it unbreakable.
-
Adaptive Toughness with Embedded Sensors:
- This glass could have embedded piezoelectric sensors that detect stress points and adjust the molecular bonds in real time. By distributing stresses dynamically (similar to how the human bone responds to loads), the glass would resist shattering even under extreme conditions. However, beyond a certain threshold, it would break—ensuring it retains a non-unbreakable nature.
Properties and Applications:
- Tensile Strength: The glass would have 20x the tensile strength of traditional glass, thanks to graphene infusion.
- Fracture Resistance: Capable of absorbing impacts 10x greater than conventional glass due to the amorphous metal interweaving.
- Heat and Chemical Resistance: Similar or better than borosilicate glass, allowing use in extreme environments (heat, corrosive chemicals, etc.).
- Transparency: The material would maintain high optical clarity, ideal for applications where visual clarity is essential, such as in smartphone screens, vehicle windshields, and architectural glass.
- Breakage Behavior: Upon breaking, the glass would fragment into large, controlled pieces (like tempered glass), minimizing sharp dangerous shards.
Example Lua Mod, (THIS IS ONLY AN EXAMPLE. MAKE YOUR OWN LUA SCRIPT):
local smfb = elements.allocate("smallfubomb", "smfb") elements.element(smfb, elements.element(elements.DEFAULT_PT_DEST)) elements.property(smfb, "Name", "SMFB") elements.property(smfb, "Description", "Small Mother F***ing bomb. VERY DESTRUCTIVE") elements.property(smfb, "Temperature", 273.15) elements.property(smfb, "HeatConduct", 255) elements.property(smfb, "Weight", 500) local function explosion(i,x,y,s,nt) for r in sim.neighbors(x,y,1,1) do if sim.partProperty(r, "type") ~= smfb then sim.partProperty(r, "temp", 10000) sim.pressure(x/4, y/4, sim.pressure(x/4, y/4) + 10) if sim.partProperty(i, "life") == 0 then sim.partProperty(i, "life", 301) end if math.random(0, math.random(1, 25)) == 0 then sim.partChangeType(r, elem.DEFAULT_PT_HYGN) end if math.random(0, 50) == 0 then sim.partProperty(r, "life", 0) sim.partChangeType(r, smfb) end if math.random(0, 100) == 0 then sim.partChangeType(r, elem.DEFAULT_PT_DEST) end if math.random(0, 50) == 0 then sim.partChangeType(r, elem.DEFAULT_PT_GBMB) end if math.random(0, 50) == 0 then sim.partProperty(r, "tmp2", 10000) sim.partProperty(r, "life", 1000) sim.partChangeType(r,elem.DEFAULT_PT_WARP) end local ix = math.random(sim.partProperty(r, "x") - 1, sim.partProperty(r, "x") + 1) local iy = math.random(sim.partProperty(r, "y") - 1, sim.partProperty(r, "y") + 1) sim.partProperty(i, "x", ix) sim.partProperty(i, "y", iy) end if sim.partProperty(i, "life") < 61 and sim.partProperty(i, "life") ~= 0 then sim.partChangeType(r, elem.DEFAULT_PT_BOMB) end sim.partProperty(i, "vx", math.random(sim.partProperty(i, "vx") - 5, sim.partProperty(i, "vx") + 5)) sim.partProperty(i, "vy", math.random(sim.partProperty(i, "vy") - 5, sim.partProperty(i, "vy") + 5)) end end elements.property(smfb, "Update", explosion)These reference links are reference files for the mod:
https://github.com/The-Powder-Toy/The-Powder-Toy/raw/refs/heads/master/src/lua/TPTSTypes.cpp https://raw.githubusercontent.com/The-Powder-Toy/The-Powder-Toy/refs/heads/master/src/simulation/CoordStack.h https://github.com/The-Powder-Toy/The-Powder-Toy/raw/refs/heads/master/src/simulation/elements/BCLN.cpp
-
- Assistant
Here is a Lua script for The Powder Toy that adds a new element called Nanofused Graphene-Glass Composite (NGLS). This material has enhanced properties like high tensile strength, fracture resistance, self-healing capabilities, and maintains transparency. The script includes comments explaining each part of the code.
-- Allocate a new element for the Nanofused Graphene-Glass Composite local NGLS = elements.allocate("user", "ngls") elements.element(NGLS, elements.element(elements.DEFAULT_PT_GLAS)) -- Base it off of Glass -- Set basic properties elements.property(NGLS, "Name", "NGLS") elements.property(NGLS, "Description", "Nanofused Graphene-Glass Composite. Super strong glass with exceptional properties.") elements.property(NGLS, "Colour", 0xAAAAFF) -- Light blueish color to represent the material elements.property(NGLS, "MenuSection", elem.SC_SOLIDS) elements.property(NGLS, "Gravity", 0) elements.property(NGLS, "Flammable", 0) elements.property(NGLS, "Explosive", 0) elements.property(NGLS, "Meltable", 1) elements.property(NGLS, "Hardness", 250) -- Highly resistant to pressure and impact elements.property(NGLS, "HeatConduct", 50) -- Moderate thermal conductivity elements.property(NGLS, "HighTemperature", 2000) -- High melting point elements.property(NGLS, "TempHigh", 2000) elements.property(NGLS, "Density", 2700) -- Similar to glass elements.property(NGLS, "State", elem.ST_SOLID) elements.property(NGLS, "Weight", 100) elements.property(NGLS, "Advection", 0) elements.property(NGLS, "AirDrag", 0) elements.property(NGLS, "AirLoss", 0) elements.property(NGLS, "Loss", 0) elements.property(NGLS, "Collision", elem.PMAP_SOLID) elements.property(NGLS, "Properties", elem.TYPE_SOLID + elem.PROP_LIFE_DEC + elem.PROP_NEUTPEN) elements.property(NGLS, "Flood", 0) elements.property(NGLS, "Diffusion", 0) elements.property(NGLS, "Brightness", 0) elements.property(NGLS, "State", elem.ST_SOLID) elements.property(NGLS, "Damage", 0) elements.property(NGLS, "Explosion", 0) -- Custom update function to implement self-healing and fracture resistance local function ngls_update(i, x, y, s, n) -- i: particle index -- x, y: coordinates -- s: simulation frame -- n: none (unused) -- Get the temperature of the particle local temp = sim.partProperty(i, "temp") -- If the temperature exceeds the melting point, convert to molten glass if temp >= elements.property(NGLS, "TempHigh") then sim.partChangeType(i, elem.DEFAULT_PT_LAVA) -- Melt into lava-like state return end -- Self-healing properties -- Check surrounding particles for empty spaces to 'heal' for dx = -1, 1 do for dy = -1, 1 do if not (dx == 0 and dy == 0) then local nx, ny = x + dx, y + dy local neighbor_id = sim.partID(nx, ny) if neighbor_id == -1 then -- Found an empty space; create a new NGLS particle to heal it sim.partCreate(-1, nx, ny, NGLS) -- Simulate energy cost for self-healing by slightly reducing the particle's temperature sim.partProperty(i, "temp", temp - 0.5) end end end end -- Fracture resistance -- Reduce pressure in the area by absorbing it, simulating how the material redistributes stress local pressure = sim.pressure(x, y) if pressure > 0 then sim.pressure(x, y, pressure * 0.9) -- Absorb 10% of the pressure end -- Adjust color based on stress (visual feedback) if pressure > 5 then -- Change display color to a reddish tint under high pressure sim.partProperty(i, "dcolour", 0xFFAAAA) else -- Reset to original color when not under stress sim.partProperty(i, "dcolour", elements.property(NGLS, "Colour")) end end elements.property(NGLS, "Update", ngls_update) -- Function to handle what happens when the material breaks local function ngls_break(i, x, y, surround_space) -- Replace broken NGLS particles with large, controlled fragments sim.partCreate(-1, x, y, elem.DEFAULT_PT_BRMT) -- 'BRMT' represents broken metal; you can define a custom shard element return false -- Allow the particle to be destroyed end elements.property(NGLS, "Break", ngls_break)Explanation of the Code:
-
Element Allocation and Initialization:
- We allocate a new element
NGLSand base it on the default glass element for similar properties. - Set the name, description, and color to identify it in the game.
- We allocate a new element
-
Physical Properties:
- Hardness: Increased to make it resistant to impacts and pressure.
- Melting Point: Set high to reflect the material's heat resistance.
- Heat Conductivity: Adjusted to a moderate value.
- Density: Similar to glass for realism.
-
Self-Healing Mechanism:
- In the
ngls_updatefunction, the script checks for empty neighboring spaces. - If an empty space is found, a new
NGLSparticle is created to fill it, simulating self-healing. - The particle's temperature slightly decreases to represent the energy used in self-healing.
- In the
-
Fracture Resistance:
- The material absorbs some of the environmental pressure to prevent cracks from propagating.
- Pressure at the particle's location is reduced by 10% each frame.
-
Visual Feedback:
- The color changes when under stress (high pressure), turning to a reddish tint.
- This provides a visual indication of the material's stress levels.
-
Breakage Behavior:
- When the material breaks (due to extreme conditions beyond its limits), it transforms into
BRMT(broken metal or shards). - This simulates the material fragmenting into large, controlled pieces.
- When the material breaks (due to extreme conditions beyond its limits), it transforms into
How to Use the Mod:
-
Install the Script:
- Copy the Lua script into a file with a
.luaextension. - Place the file in the
Luafolder of The Powder Toy directory.
- Copy the Lua script into a file with a
-
Load the Script in The Powder Toy:
- Open The Powder Toy.
- Go to the console by pressing the backquote key (`).
- Type
dofile("filename.lua")replacingfilename.luawith the name of your script.
-
Select and Use NGLS:
- The new element
NGLSwill appear in the Solids category. - Use it like any other material in the game.
- The new element
Notes:
- The self-healing feature works best when the material is in a bulk form to allow particles to heal adjacent empty spaces.
- The fracture resistance and self-healing may have performance impacts if used excessively due to the calculations involved.
- Adjust the properties like
Hardness,HeatConduct, andTempHighto fine-tune the material according to your preferences.
References for Further Modding:
By using this script, you can experiment with the Nanofused Graphene-Glass Composite in The Powder Toy, observing its advanced properties and behavior under different conditions.
-