Make an advanced powder toy lua mod that adds a pythonic solid, it's really durable and…
- User
Make an advanced powder toy lua mod that adds a pythonic solid, it's really durable and has uni-frame, and subframe regeneration. It'll have an interesting special property that'll expand inwards when a frame of itself is damaged.
Example Lua Mod, (THIS IS ONLY AN EXAMPLE. MAKE YOUR OWN LUA SCRIPT)
Reference Script (REFERENCE ONLY):
local antidest = elements.allocate("antidestruct", "anti") elements.element(antidest, elements.element(elements.DEFAULT_PT_LIFE)) elements.property(antidest, "Name", "ANCL") elements.property(antidest, "Description", "Anti-destructive self-repairing cell. Regenerates quickly and slowly populates.") elements.property(antidest, "Colour", 0x00FF00) elements.property(antidest, "MenuSection", elem.SC_LIFE) elements.property(antidest, "Properties", elem.TYPE_SOLID + elem.PROP_LIFE) local function update(i, x, y, s, nt) -- Ultra-fast self-repair sim.partProperty(i, "life", math.min(sim.partProperty(i, "life") + 5, 100)) -- Regenerates faster -- Repair damaged particles around it quickly for rx = -1, 1 do for ry = -1, 1 do local r = sim.pmap(x + rx, y + ry) if r then local rtype = sim.partProperty(r, "type") if rtype == antidest then sim.partProperty(r, "life", math.min(sim.partProperty(r, "life") + 5, 100)) -- Heal neighbors faster end end end end -- Immune to destruction and bombs: neutralize nearby destructive elements instantly for rx = -2, 2 do for ry = -2, 2 do local r = sim.pmap(x + rx, y + ry) if r then local rtype = sim.partProperty(r, "type") if rtype == elem.DEFAULT_PT_DEST or rtype == elem.DEFAULT_PT_BOMB or rtype == elem.DEFAULT_PT_FIRE or rtype == elem.DEFAULT_PT_AMTR or rtype == elem.DEFAULT_PT_THDR or rtype == elem.DEFAULT_PT_SING or rtype == elem.DEFAULT_PT_SRAD or rtype == elem.DEFAULT_PT_SMDB then sim.partKill(r) -- Completely destroy nearby harmful particles end end end end -- Slow population growth if math.random() < 0.01 then local nx, ny = x + math.random(-1, 1), y + math.random(-1, 1) if not sim.pmap(nx, ny) then sim.partCreate(-1, nx, ny, antidest) end end -- Resist pressure and temperature changes sim.pressure(x / 4, y / 4, (sim.pressure(x / 4, y / 4) + 1) / 2) sim.partProperty(i, "temp", 295.15) -- Maintain room temperature end elements.property(antidest, "Update", update)Other References:
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) - Assistant
Creating an advanced Powder Toy Lua mod for the "Pythonic Solid" involves defining a highly durable solid element with sophisticated behaviors such as uni-frame and subframe regeneration, as well as an inward-expanding mechanism when its frame is damaged. Below is a comprehensive Lua script that accomplishes these features.
Pythonic Solid (PYSL) Lua Mod
-- Pythonic Solid Lua Mod for Powder Toy -- Author: [Your Name] -- Description: Adds a highly durable solid with uni-frame and subframe regeneration. -- Expands inwards when its frame is damaged. -- Allocate a new element called "pythonic solid" with unique identifier "PYSL" local pysl = elements.allocate("pythonic_solid", "pysl") -- Initialize the element based on the default solid properties elements.element(pysl, elements.element(elements.DEFAULT_PT_SOLID)) -- Set basic properties elements.property(pysl, "Name", "Pythonic Solid") elements.property(pysl, "Description", "A highly durable solid with uni-frame and subframe regeneration. Expands inwards when its frame is damaged.") elements.property(pysl, "Colour", 0x1E90FF) -- Dodger Blue elements.property(pysl, "MenuSection", elem.SC_SOLIDS) elements.property(pysl, "State", elem.STATE_SOLID) elements.property(pysl, "Temperature", 300.15) -- Room temperature in K elements.property(pysl, "HeatConduct", 0.8) -- High thermal conductivity elements.property(pysl, "Weight", 800) -- Heavier than default solid elements.property(pysl, "RefractiveIndex", 1.5) elements.property(pysl, "Reflection", 0.3) elements.property(pysl, "SolidifyTemperature", 0) elements.property(pysl, "BoilingTemperature", 10000) elements.property(pysl, "ExplosionResistance", 1000) -- Highly resistant to explosions elements.property(pysl, "Hardness", 1000) -- Represents durability -- Define custom properties elements.property(pysl, "IsFrame", false) -- Custom flag to identify frame particles -- Helper function to check if a particle is part of the frame local function is_frame(x, y) -- Check if the particle at (x, y) is on the boundary of a cluster local neighbors = 0 for dx = -1, 1 do for dy = -1, 1 do if not (dx == 0 and dy == 0) then if sim.partMap(x + dx, y + dy) then neighbors = neighbors + 1 end end end end -- If the number of neighbors is less than 8, it's likely on the frame return neighbors < 8 end -- Update function for Pythonic Solid local function update_pysl(i, x, y, s, nt) -- Ensure the particle maintains its frame status local current_frame_status = is_frame(x, y) sim.partProperty(i, "IsFrame", current_frame_status) -- Regeneration Logic -- Check surrounding particles to regenerate frame and subframes for dx = -2, 2 do for dy = -2, 2 do local nx, ny = x + dx, y + dy local neighbor = sim.partMap(nx, ny) if neighbor and sim.partProperty(neighbor, "type") == pysl then -- Regenerate life if below maximum local life = sim.partProperty(neighbor, "life") if life < 100 then sim.partProperty(neighbor, "life", math.min(life + 5, 100)) end elseif not neighbor and (math.abs(dx) <=1 and math.abs(dy) <=1) then -- Attempt to fill in missing inner particles to expand inwards if is_frame(nx, ny) then sim.partCreate(-1, nx, ny, pysl) end end end end -- Damage Handling if sim.partProperty(i, "life") < 50 then -- If a frame particle is damaged, trigger inward expansion if sim.partProperty(i, "IsFrame") then -- Expand inwards by creating new particles adjacent to the damaged frame for dx = -1, 1 do for dy = -1, 1 do local ex, ey = x + dx, y + dy if not sim.partMap(ex, ey) then -- Create a new Pythonic Solid particle to fill the gap sim.partCreate(-1, ex, ey, pysl) end end end end end -- Maintain High Durability -- Prevent temperature changes and external damage sim.partProperty(i, "temp", 300.15) -- Maintain room temperature -- Optionally, you can add immunity to certain elements or conditions -- For example, remove fire or corrosive elements nearby for dx = -1, 1 do for dy = -1, 1 do local nx, ny = x + dx, y + dy local neighbor = sim.partMap(nx, ny) if neighbor then local ntype = sim.partProperty(neighbor, "type") if ntype == elem.DEFAULT_PT_FIRE or ntype == elem.DEFAULT_PT_ACID or ntype == elem.DEFAULT_PT_LAVA then sim.partKill(neighbor) -- Neutralize harmful elements end end end end -- Pressure Resistance -- Reduce the effect of pressure around the particle local pressure = sim.pressure(x, y) sim.pressure(x, y, pressure * 0.9) -- Absorb some pressure -- Optional: Slow Population Growth to prevent uncontrolled spreading if math.random() < 0.005 then local nx, ny = x + math.random(-1, 1), y + math.random(-1, 1) if not sim.partMap(nx, ny) then sim.partCreate(-1, nx, ny, pysl) end end end -- Assign the update function to the Pythonic Solid element elements.property(pysl, "Update", update_pysl)Explanation of the Lua Script
-
Element Allocation and Basic Properties:
- Allocation: The
pythonic_solidelement is allocated with the identifier"pysl". - Inheritance: It inherits properties from the default solid to ensure it behaves like a solid element initially.
- Basic Properties: Name, description, color, menu section, state, temperature, heat conductivity, weight, refractive index, reflection, solidify temperature, boiling temperature, explosion resistance, and hardness are set to make it a highly durable and distinct element.
- Allocation: The
-
Custom Properties:
- IsFrame: A custom property to differentiate between frame particles and subframe particles. This helps manage the regeneration and expansion mechanics.
-
Helper Function –
is_frame:- Determines if a particle is part of the frame by checking the number of neighboring particles. If a particle has fewer than 8 neighbors, it's likely on the boundary (frame).
-
Update Function –
update_pysl:- Frame Status Maintenance: Continuously checks and sets whether the particle is part of the frame.
- Regeneration Logic:
- Iterates through neighbors within a 2-cell radius to regenerate damaged particles by restoring their life.
- Attempts to fill in inner gaps by creating new particles if there's space, simulating inward expansion.
- Damage Handling:
- If a frame particle's life drops below 50, it triggers the creation of new particles in adjacent cells to repair the frame by expanding inwards.
- High Durability Maintenance:
- Maintains a constant temperature to prevent external factors from affecting it.
- Neutralizes harmful elements like fire, acid, or lava in the vicinity to protect itself.
- Pressure Resistance:
- Absorbs some of the external pressure to reduce deformation or destruction.
- Controlled Population Growth:
- Implements a slow population growth mechanism to prevent the element from spreading uncontrollably.
-
Assigning the Update Function:
- The custom update function
update_pyslis assigned to the Pythonic Solid element to ensure it executes every simulation tick.
- The custom update function
Usage Instructions
-
Installation:
- Save the above script in a
.luafile, for example,pythonic_solid.lua. - Place the file in the Powder Toy's
plugin.luadirectory or the designated scripts folder.
- Save the above script in a
-
Loading the Mod:
- Open Powder Toy.
- Navigate to the Plugins or Scripts section.
- Load the
pythonic_solid.luascript.
-
Using Pythonic Solid:
- Once loaded, you can select "Pythonic Solid" from the solids menu.
- Place it in the simulation area.
- Observe its high durability, regeneration capabilities, and inward expansion when the frame is damaged.
Customization and Enhancements
-
Adjusting Properties:
- Modify properties like
HeatConduct,Weight,ExplosionResistance, andHardnessto tweak the element's behavior and appearance.
- Modify properties like
-
Enhancing Regeneration:
- Fine-tune the regeneration rate by adjusting the increments in the
update_pyslfunction.
- Fine-tune the regeneration rate by adjusting the increments in the
-
Expanding Special Properties:
- Add more behaviors, such as interaction with other custom elements or unique reactions under specific conditions.
Conclusion
The Pythonic Solid Lua mod introduces a robust and intelligent solid element to Powder Toy, capable of self-regeneration and adaptive expansion. By following the script and explanation provided, you can integrate this advanced element into your simulations and further customize it to suit specific needs or creative ideas.
-