Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TPT Lua Script - Content Mod
- -- ReallyJustDont's Radiation and Technology Mod v1.0
- -- 2025
- local radon = elements.allocate("ARAD", "RDON")
- local radium = elements.allocate("ARAD", "RDIM")
- elements.element(radon, elements.element(elements.DEFAULT_PT_NBLE))
- elements.property(radon, "Name", "RDON")
- elements.property(radon, "Description", "Radon. Heavy, translucent gas. Absorbs protons, but may turn into radium or other heavy metals.")
- elements.property(radon, "Color", 0x007766)
- elements.property(radon, "MenuVisible", 1)
- elements.property(radon, "MenuSection", elements.SC_NUCLEAR)
- elements.property(radon, "Gravity", 0.02)
- elements.property(radon, "Diffusion", 0.5)
- elements.property(radon, "HotAir", 0)
- elements.property(radon, "Properties", elements.TYPE_GAS + elements.PROP_PHOTPASS + elements.PROP_NEUTPASS + elements.PROP_DEADLY)
- local function radonUpdate(i, x, y, s, nt)
- local protons = 0
- for part in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_PROT) do
- protons = protons + 1
- if (math.random(1, 4) == 1) then
- sim.partKill(part)
- sim.partProperty(i, "life", sim.partProperty(i, "life") + 4)
- end -- if
- end -- for
- if (protons == 0) and (math.random(1, 8) == 1) and (sim.partProperty(i, "life") > 0) then
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 1)
- end -- if
- if (sim.partProperty(i, "life") >= 20) then
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 0.2)
- if (math.random(1, 2) == 1) then
- if (math.random(1, 4) == 1) then
- sim.partProperty(i, "type", elements.DEFAULT_PT_PLUT)
- else
- sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
- end
- else
- sim.partProperty(i, "type", radium)
- end
- return -1
- end -- if
- end -- function
- local function radonGraphics(i, colr, colg, colb)
- local rMode = ren.DECO_FIRE + ren.FIRE_BLEND
- if (sim.partProperty(i, "life") >= 2) then
- rMode = rMode + ren.PMODE_FLARE
- end
- return 0, rMode, 150, colr, colg, colb, 150, colr / 2, colg / 2, colb / 2
- end -- function
- elements.property(radon, "Update", radonUpdate)
- elements.property(radon, "Graphics", radonGraphics)
- elements.element(radium, elements.element(elements.DEFAULT_PT_GOLD))
- elements.property(radium, "Name", "RDIM")
- elements.property(radium, "Description", "Radium. Solid, reactive, and sometimes emits hot neutrons. Decays under pressure, and can also melt.")
- elements.property(radium, "Color", 0x00cc33)
- elements.property(radium, "MenuVisible", 1)
- elements.property(radium, "MenuSection", elements.SC_NUCLEAR)
- elements.property(radium, "Hardness", 4)
- elements.property(radium, "Properties", elements.TYPE_SOLID + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE)
- elements.property(radium, "HighTemperature", 700 + 273) -- 700 celsius converted to kelvin
- elements.property(radium, "PhotonReflectWavelengths", 0x1fe00)
- local function radiumUpdate(i, x, y, s, nt)
- local water = 0
- if (math.random(1, 4) == 1) then
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_WATR) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_DSTW) then
- water = water + 3
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_CBNW) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_O2) then
- water = water + 2
- end
- end
- end -- if
- if (math.random(1, 100) < water) or (sim.partProperty(i, "life") >= 100) then
- for part in sim.neighbors(x, y, 2, 2, radium) do
- sim.partProperty(part, "life", 100)
- end
- sim.partProperty(i, "life", 0)
- sim.partProperty(i, "tmp", 50)
- sim.partProperty(i, "type", elements.DEFAULT_PT_SING)
- for count = 1, 8, 1 do
- sim.partCreate(-2, math.random(x - 3, x + 3), math.random(y - 3, y + 3), elements.DEFAULT_PT_PLSM)
- end
- return -1
- end
- if (sim.pressure(x / 4, y / 4) >= 2) then
- if (math.random(1, 100) < sim.pressure(x / 4, y / 4)) then
- sim.partProperty(i, "life", sim.partProperty(i, "life") + 1)
- end
- end
- local neutFactor = 6000
- if (s >= 2) then -- if 2 or more empty spaces near this particle
- neutFactor = 4500
- end
- if (sim.partProperty(i, "life") >= 50) or (sim.partProperty(i, "temp") >= (400 + 273)) then
- neutFactor = neutFactor - 1000
- end
- if (math.random(1, neutFactor) == 1) then
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", 400 + 273 + (sim.partProperty(i, "temp") / 5))
- end
- end
- end
- local function radiumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
- if (sim.partProperty(i, "temp") >= (400 + 273)) then -- start glowing at 400C
- local tempDiff = (sim.partProperty(i, "temp") - 673) / 2
- if (tempDiff > 150) then
- tempDiff = 150
- end
- rRed = rRed + tempDiff
- rGreen = rGreen - (tempDiff * 0.8)
- end
- if (sim.partProperty(i, "life") >= 0) and (sim.partProperty(i, "life") <= 200) then
- rRed = rRed + (sim.partProperty(i, "life") / 4)
- rBlue = rBlue + (sim.partProperty(i, "life") / 5)
- if (sim.partProperty(i, "life") >= 50) then
- rMode = rMode + ren.FIRE_ADD
- end
- else
- rRed = rRed + 20
- rBlue = rBlue + 20
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
- end -- function
- elements.property(radium, "Update", radiumUpdate)
- elements.property(radium, "Graphics", radiumGraphics)
- local tritium = elements.allocate("ARAD", "TRIT")
- elements.element(tritium, elements.element(elements.DEFAULT_PT_GEL))
- elements.property(tritium, "Name", "TRIT")
- elements.property(tritium, "Description", "Liquid tritium. Specialized for fast proton reactions; reverts to DEUT when electrified.")
- elements.property(tritium, "Color", 0x9966ff)
- elements.property(tritium, "MenuVisible", 1)
- elements.property(tritium, "MenuSection", elements.SC_NUCLEAR)
- elements.property(tritium, "Gravity", 0.11)
- elements.property(tritium, "Weight", 33)
- elements.property(tritium, "HeatConduct", 190)
- elements.property(tritium, "Properties", elements.TYPE_LIQUID + elements.PROP_SPARKSETTLE)
- local function tritiumUpdate(i, x, y, s, nt)
- if (nt >= 2) or (math.random(1, 100) == 1) then
- local protVal = 0
- local elecVal = 0
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_PROT) then
- protVal = protVal + 2
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_ELEC) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_LIGH) then
- elecVal = elecVal + 2
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_EMBR) then
- elecVal = elecVal + 1
- end
- end
- if (elecVal > protVal) then
- if (math.random(1, 4) <= elecVal) then
- sim.partProperty(i, "life", 30 + (2 * elecVal))
- sim.partProperty(i, "ctype", 0)
- sim.partProperty(i, "type", elements.DEFAULT_PT_DEUT)
- return -1
- end
- end
- if (protVal > elecVal) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_PROT)
- if (math.random(1, 4) <= protVal) then
- sim.partProperty(i, "life", sim.partProperty(i, "life") + 10)
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PROT)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", 1200 + 273 + (sim.partProperty(i, "temp") * 0.8))
- end
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) - 0.4)
- end
- if (sim.partProperty(i, "life") >= 60) then
- sim.partKill(i)
- return -1
- end
- end
- end
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PROT) and (sim.partProperty(i, "life") >= 1) then
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 1)
- if (sim.partProperty(i, "life")) <= 1 then
- sim.partProperty(i, "ctype", 0)
- end
- end
- end
- local function tritiumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT + ren.PMODE_BLUR
- if (math.random(1, 100) == 1) then
- rMode = rMode + ren.PMODE_FLARE
- rRed = rRed + 10
- rGreen = rGreen + 8
- rBlue = rBlue + 10
- end
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PROT) then
- rRed = rRed + 30
- rGreen = rGreen - 10
- rBlue = rBlue - 10
- if (math.random(1, 100) == 1) then
- rMode = rMode + ren.PMODE_LFLARE
- end
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
- end -- function
- elements.property(tritium, "Update", tritiumUpdate)
- elements.property(tritium, "Graphics", tritiumGraphics)
- local neutronium = elements.allocate("ARAD", "NTRM")
- elements.element(neutronium, elements.element(elements.DEFAULT_PT_GOO))
- elements.property(neutronium, "Name", "NTRM")
- elements.property(neutronium, "Description", "Neutronium. Loses power over time, can be charged with neutrons. Vulnerable to pressure if unpowered.")
- elements.property(neutronium, "Color", 0x0099ff)
- elements.property(neutronium, "MenuVisible", 1)
- elements.property(neutronium, "MenuSection", elements.SC_NUCLEAR)
- elements.property(neutronium, "HeatConduct", 120)
- elements.property(neutronium, "Hardness", 0)
- elements.property(neutronium, "Loss", 0)
- elements.property(neutronium, "Properties", elements.TYPE_SOLID + elements.PROP_SPARKSETTLE + elements.PROP_LIFE_DEC)
- elements.property(neutronium, "PhotonReflectWavelengths", 0xff80)
- local function neutroniumCreate(i, x, y, t, v)
- sim.partProperty(i, "life", 3000)
- end
- local function neutroniumUpdate(i, x, y, s, nt)
- if (nt >= 1) then
- for part in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_NEUT) do
- local lifeAdd = 1200 + sim.partProperty(part, "life")
- sim.partKill(part)
- if (sim.partProperty(i, "life") <= 3000) then
- lifeAdd = lifeAdd + 1800
- end
- sim.partProperty(i, "life", sim.partProperty(i, "life") + lifeAdd)
- end
- end
- if (math.random(1, 4) == 1) then
- for part in sim.neighbors(x, y, 1, 1, neutronium) do
- if (sim.partProperty(part, "life") < (sim.partProperty(i, "life") - 10)) then
- local lSum = sim.partProperty(i, "life") + sim.partProperty(part, "life")
- if (sim.partProperty(i, "life") > (lSum * 0.6)) then
- sim.partProperty(i, "life", lSum * 0.6)
- sim.partProperty(part, "life", lSum * 0.5)
- else
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 8)
- sim.partProperty(part, "life", sim.partProperty(part, "life") + 8)
- end
- end
- end
- end
- if (math.random(1, 20) == 1) and (sim.partProperty(i, "life") == 0) then
- if (sim.pressure(x / 4, y / 4) >= 4) then
- sim.partProperty(i, "life", 60)
- sim.partProperty(i, "type", elements.DEFAULT_PT_BRAY)
- return -1
- end
- end
- end
- local function neutroniumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- if (sim.partProperty(i, "life") > 0) then
- rMode = rMode + ren.PMODE_GLOW
- local lightAdd = sim.partProperty(i, "life") / 20
- if (lightAdd >= 90) then
- lightAdd = 90
- end
- rRed = rRed + lightAdd
- rGreen = rGreen + lightAdd
- if (sim.partProperty(i, "life") >= 3600) and (math.random(1, 60) == 1) then
- rMode = rMode + ren.PMODE_FLARE
- end
- else
- rBlue = rBlue - math.random(20, 40)
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
- end
- elements.property(neutronium, "Create", neutroniumCreate)
- elements.property(neutronium, "Update", neutroniumUpdate)
- elements.property(neutronium, "Graphics", neutroniumGraphics)
- local actinium = elements.allocate("ARAD", "ACTN")
- local curium = elements.allocate("ARAD", "CURI")
- local zeroAlloy = elements.allocate("ARAD", "ZRAL")
- elements.element(actinium, elements.element(elements.DEFAULT_PT_GOO))
- elements.property(actinium, "Name", "ACTN")
- elements.property(actinium, "Description", "Actinium. Solid, can oxidize. Absorbs protons and neutrons, but may turn into heavier metals. Decays under pressure.")
- elements.property(actinium, "Color", 0x0066ff)
- elements.property(actinium, "MenuVisible", 1)
- elements.property(actinium, "MenuSection", elements.SC_NUCLEAR)
- elements.property(actinium, "HeatConduct", 160)
- elements.property(actinium, "Hardness", 4)
- elements.property(actinium, "Loss", 0)
- elements.property(actinium, "Properties", elements.TYPE_SOLID + elements.PROP_SPARKSETTLE + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE + elements.PROP_LIFE_DEC)
- elements.property(actinium, "PhotonReflectWavelengths", 0x1fff8)
- local function actiniumUpdate(i, x, y, s, nt)
- if (nt >= 2) then
- local oxiFactor = 0
- for part in sim.neighbors(x, y, 1, 1) do
- local oxiPart = false
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_O2) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_CO2) then
- oxiFactor = oxiFactor + 3
- oxiPart = true
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_FOG) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_WTRV) then
- oxiFactor = oxiFactor + 2
- oxiPart = true
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_BOYL) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_GAS) then
- oxiFactor = oxiFactor + 1
- oxiPart = true
- end
- if (sim.partProperty(i, "ctype") ~= elements.DEFAULT_PT_O2) and (oxiFactor >= 3) and (math.random(1, 20) == 1) and (oxiPart) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_O2)
- sim.partProperty(part, "type", elements.DEFAULT_PT_EMBR)
- sim.partProperty(part, "life", math.random(90, 120))
- end
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_NEUT) then
- if (math.random(1, 4) == 1) then
- sim.partKill(part)
- sim.partProperty(i, "life", sim.partProperty(i, "life") + 20)
- end
- end
- end
- else
- local partHere = sim.photons(x, y)
- if (partHere ~= nil) and (math.random(1, 2) == 1) then
- if (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_NEUT) then
- sim.partKill(partHere)
- sim.partProperty(i, "life", sim.partProperty(i, "life") + 20)
- end
- end
- end
- if (sim.partProperty(i, "life") >= 80) then
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 0.4)
- sim.partProperty(i, "life", 0)
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 5)
- sim.partProperty(i, "ctype", 0)
- if (math.random(1, 2) == 1) then
- if (math.random(1, 2) == 1) then
- sim.partProperty(i, "type", elements.DEFAULT_PT_PLUT)
- else
- sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
- end
- else
- sim.partProperty(i, "type", curium)
- end
- return -1
- end
- local pThreshold = 8
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_O2) then
- pThreshold = 4
- end
- if (sim.pressure(x / 4, y / 4) >= pThreshold) and (math.random(1, 120) <= sim.pressure(x / 4, y / 4)) then
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", 50 + sim.partProperty(i, "temp"))
- end
- sim.partProperty(i, "life", 0)
- sim.partProperty(i, "ctype", 0)
- if (math.random(1, 2) == 1) then
- if (math.random(1, 2) == 1) then
- sim.partProperty(i, "type", elements.DEFAULT_PT_STNE)
- else
- sim.partProperty(i, "type", elements.DEFAULT_PT_SAND)
- end
- else
- sim.partProperty(i, "type", radon)
- end
- return -1
- end
- end
- local function actiniumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_O2) then
- rRed = rRed + 50
- rGreen = rGreen + 50
- end
- if (math.random(1, 60) < sim.partProperty(i, "life")) then
- rRed = rRed + 20
- rGreen = rGreen + 20
- rMode = rMode + ren.PMODE_FLARE
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(actinium, "Update", actiniumUpdate)
- elements.property(actinium, "Graphics", actiniumGraphics)
- elements.element(curium, elements.element(elements.DEFAULT_PT_GOO))
- elements.property(curium, "Name", "CURI")
- elements.property(curium, "Description", "Curium. Solid, undergoes beta decay. Can be accelerated by electrons or low pressure.")
- elements.property(curium, "Color", 0xff3366)
- elements.property(curium, "MenuVisible", 1)
- elements.property(curium, "MenuSection", elements.SC_NUCLEAR)
- elements.property(curium, "HeatConduct", 160)
- elements.property(curium, "Hardness", 6)
- elements.property(curium, "Loss", 0)
- elements.property(curium, "Properties", elements.TYPE_SOLID + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE)
- elements.property(curium, "PhotonReflectWavelengths", 0x3c00000f)
- local function curiumUpdate(i, x, y, s, nt)
- if (nt >= 2) then
- local elecFactor = 1200
- local isozFactor = 0
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_ELEC) and (elecFactor >= 600) then
- elecFactor = elecFactor - 120
- end
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_ISOZ) then
- isozFactor = isozFactor + 1
- end
- end
- if (isozFactor >= 1) then
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == curium) and (isozFactor >= 2) then
- isozFactor = isozFactor - 1
- sim.partProperty(part, "type", zeroAlloy)
- end
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_ISOZ) then
- sim.partKill(part)
- end
- end
- sim.partProperty(i, "type", zeroAlloy)
- return -1
- end
- if (sim.pressure(x / 4, y / 4) <= -2) then
- elecFactor = elecFactor - 150
- if (sim.pressure(x / 4, y / 4) <= -10) then
- elecFactor = elecFactor - 150
- end
- end
- if (math.random(1, elecFactor) == 1) then
- local newPart = sim.partCreate(-2, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_ELEC)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", 300 + (sim.partProperty(i, "temp") * 0.9))
- sim.partProperty(i, "life", sim.partProperty(i, "life") + 1)
- end
- end
- if (sim.partProperty(i, "life") >= 6) then
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) - 0.4)
- sim.partProperty(i, "life", 0)
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 5)
- sim.partProperty(i, "ctype", 0)
- if (math.random(1, 2) == 1) then
- if (math.random(1, 2) == 1) then
- sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
- else
- sim.partProperty(i, "type", radon)
- end
- else
- sim.partProperty(i, "type", radium)
- end
- return -1
- end
- end
- end
- local function curiumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
- if (sim.partProperty(i, "life") >= 3) then
- rGreen = rGreen + 50
- rBlue = rBlue + 60
- if (sim.partProperty(i, "life") >= 5) and (math.random(1, 2) == 1)then
- rMode = rMode + ren.PMODE_LFLARE
- end
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(curium, "Update", curiumUpdate)
- elements.property(curium, "Graphics", curiumGraphics)
- elements.element(zeroAlloy, elements.element(elements.DEFAULT_PT_TTAN))
- elements.property(zeroAlloy, "Name", "ZRAL")
- elements.property(zeroAlloy, "Description", "Zero Alloy. Created by infusing Curium with Isotope-Z. Cools itself and emits photons. Melts into ISOZ with extreme heat.")
- elements.property(zeroAlloy, "Color", 0x3300ff)
- elements.property(zeroAlloy, "MenuVisible", 1)
- elements.property(zeroAlloy, "MenuSection", elements.SC_NUCLEAR)
- elements.property(zeroAlloy, "Hardness", 2)
- elements.property(zeroAlloy, "Properties", elements.TYPE_SOLID + elements.PROP_PHOTPASS + elements.PROP_RADIOACTIVE)
- elements.property(zeroAlloy, "HighTemperature", 3333 + 273) -- 3,333 celsius converted to kelvin
- elements.property(zeroAlloy, "HighTemperatureTransition", elements.DEFAULT_PT_ISOZ)
- local function zeroAlloyUpdate(i, x, y, s, nt)
- local photFactor = 3000
- if (sim.pressure(x / 4, y / 4) <= -2) then
- photFactor = 2700
- if (sim.pressure(x / 4, y / 4) <= -4) then
- photFactor = photFactor + (sim.pressure(x / 4, y / 4) * 2)
- end
- end
- if (sim.partProperty(i, "temp") >= 273) then
- photFactor = photFactor - (sim.partProperty(i, "temp") / 10)
- end
- if (math.random(1, photFactor) == 1) then
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PHOT)
- if (newPart >= 0) then
- local newTemp = sim.partProperty(i, "temp") * 0.9
- if (sim.partProperty(i, "temp") >= 173) then
- newTemp = newTemp - 2
- end
- sim.partProperty(newPart, "temp", newTemp)
- sim.partProperty(newPart, "vx", math.random(-3, 3))
- sim.partProperty(newPart, "vy", math.random(-3, 3))
- sim.partProperty(i, "life", 45)
- end
- elseif (sim.partProperty(i, "life") > 0) then
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 1)
- end
- end
- local function zeroAlloyGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
- if (sim.partProperty(i, "temp") >= (1333 + 273)) then
- local tempDiff = sim.partProperty(i, "temp") - 1333 - 273
- rRed = rRed + (tempDiff / 20) + 5
- if (rRed > 150) then
- rRed = 150
- end
- end
- if (sim.partProperty(i, "life") >= 5) and (sim.partProperty(i, "life") <= 50) then
- rRed = rRed + sim.partProperty(i, "life")
- rGreen = rGreen + sim.partProperty(i, "life")
- if (math.random(1, 60) <= sim.partProperty(i, "life")) then
- rMode = rMode + ren.PMODE_FLARE
- end
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
- end
- elements.property(zeroAlloy, "Update", zeroAlloyUpdate)
- elements.property(zeroAlloy, "Graphics", zeroAlloyGraphics)
- local oganesson = elements.allocate("ARAD", "OGAN")
- elements.element(oganesson, elements.element(elements.DEFAULT_PT_STNE))
- elements.property(oganesson, "Name", "OGAN")
- elements.property(oganesson, "Description", "Oganesson. Very heavy particles that quickly decay and release energy. High destructive potential.")
- elements.property(oganesson, "Color", 0x9999cc)
- elements.property(oganesson, "MenuVisible", 1)
- elements.property(oganesson, "MenuSection", elements.SC_NUCLEAR)
- elements.property(oganesson, "Gravity", 0.5)
- elements.property(oganesson, "Advection", 0.2)
- elements.property(oganesson, "Temperature", 1273.15)
- elements.property(oganesson, "Properties", elements.TYPE_PART + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE)
- elements.property(oganesson, "HighTemperature", sim.ITH)
- elements.property(oganesson, "HighTemperatureTransition", sim.NT)
- local function oganessonUpdate(i, x, y, s, nt)
- if (nt >= 2) then
- local lifeAdd = 0
- if (math.random(1, 10) == 1) then
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", sim.partProperty(i, "temp") + 200)
- lifeAdd = lifeAdd + 4
- end
- elseif (math.random(1, 10) == 1) then
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PROT)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", sim.partProperty(i, "temp") + 200)
- lifeAdd = lifeAdd + 5
- end
- end
- if (math.random(1, 15) == 1) then
- local newPart = sim.partCreate(-2, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PLSM)
- if (newPart >= 0) then
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 1)
- lifeAdd = lifeAdd + 2
- end
- end
- if (math.random(1, 30) == 1) then
- local newPart = sim.partCreate(-2, math.random(x - 1, x + 1), math.random(y - 1, y + 1), radon)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", sim.partProperty(i, "temp") + 100)
- lifeAdd = lifeAdd + 10
- end
- end
- sim.partProperty(i, "life", sim.partProperty(i, "life") + lifeAdd)
- if (sim.partProperty(i, "life") >= 30) then
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 1)
- sim.partProperty(i, "life", 0)
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 300)
- sim.partProperty(i, "ctype", 0)
- if (math.random(1, 2) == 1) then
- if (math.random(1, 2) == 1) then
- sim.partProperty(i, "type", elements.DEFAULT_PT_SING)
- sim.partProperty(i, "tmp", 50)
- else
- sim.partProperty(i, "type", elements.DEFAULT_PT_PLUT)
- end
- else
- sim.partProperty(i, "type", radium)
- end
- return -1
- end
- end
- end
- elements.property(oganesson, "Update", oganessonUpdate)
- local radAmoeba = elements.allocate("ARAD", "RMOE")
- elements.element(radAmoeba, elements.element(elements.DEFAULT_PT_GEL))
- elements.property(radAmoeba, "Name", "RMOE")
- elements.property(radAmoeba, "Description", "Radioactive Amoeba. Particles self-assign roles. Eats metal and radiation, dies when cold. Uses Newtonian gravity.")
- elements.property(radAmoeba, "Color", 0x119900)
- elements.property(radAmoeba, "MenuVisible", 1)
- elements.property(radAmoeba, "MenuSection", elements.SC_NUCLEAR)
- elements.property(radAmoeba, "Gravity", 0.11)
- elements.property(radAmoeba, "Weight", 42)
- elements.property(radAmoeba, "HeatConduct", 190)
- elements.property(radAmoeba, "Properties", elements.TYPE_LIQUID + elements.PROP_RADIOACTIVE + elements.PROP_NEUTPASS)
- local function radAmoebaUpdate(i, x, y, s, nt)
- if (sim.partProperty(i, "ctype") == 0) and (math.random(1, 2) == 1) then -- self-assign role if it doesn't have one
- local wallCount = 0
- local nucleusCount = 0
- local eaterCount = 0
- local massCount = 0
- for part in sim.neighbors(x, y, 3, 3, radAmoeba) do
- if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_INSL) then
- wallCount = wallCount + 1
- elseif (sim.partProperty(part, "ctype") == radAmoeba) then
- nucleusCount = nucleusCount + 1
- elseif (sim.partProperty(part, "ctype") == radium) then
- eaterCount = eaterCount + 1
- elseif (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_URAN) then
- massCount = massCount + 1
- end
- end
- if (nucleusCount == 0) and (math.random(1, 2) == 1) then
- sim.partProperty(i, "ctype", radAmoeba)
- elseif (wallCount <= 3) and (massCount <= 9) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_INSL)
- elseif (eaterCount <= 1) and (massCount >= 3) then
- sim.partProperty(i, "ctype", radium)
- else
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
- end
- elseif (sim.partProperty(i, "ctype") == radAmoeba) then -- nucleus
- if (sim.pressure(x / 4, y / 4) >= -2) then
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) - 0.4)
- end
- sim.gravityMass(x / 4, y / 4, 0.1)
- local wallCount = 0
- local eaterCount = 0
- local nucleusCount = 0
- local xDist = 0
- local yDist = 0
- for part in sim.neighbors(x, y, 3, 3, radAmoeba) do
- if (sim.partProperty(part, "x") > sim.partProperty(i, "x")) then
- xDist = xDist + 1
- end
- if (sim.partProperty(part, "x") < sim.partProperty(i, "x")) then
- xDist = xDist - 1
- end
- if (sim.partProperty(part, "y") > sim.partProperty(i, "y")) then
- yDist = yDist + 1
- end
- if (sim.partProperty(part, "y") < sim.partProperty(i, "y")) then
- yDist = yDist + 1
- end
- if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_INSL) then
- wallCount = wallCount + 1
- elseif (sim.partProperty(part, "ctype") == radium) then
- eaterCount = eaterCount + 1
- elseif (sim.partProperty(part, "ctype") == radAmoeba) then
- nucleusCount = nucleusCount + 1
- end
- end
- if (nucleusCount >= 2) then
- if (math.random(1, 4) == 1) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
- elseif (math.random(1, 4) == 1) then
- sim.partProperty(i, "ctype", radium)
- end
- end
- if (xDist >= 3) and (sim.partProperty(i, "vx") <= 3) then
- sim.partProperty(i, "vx", sim.partProperty(i, "vx") + 1)
- end
- if (xDist <= -3) and (sim.partProperty(i, "vx") >= -3) then
- sim.partProperty(i, "vx", sim.partProperty(i, "vx") - 1)
- end
- if (yDist >= 3) and (sim.partProperty(i, "vy") <= 3) then
- sim.partProperty(i, "vy", sim.partProperty(i, "vy") + 1)
- end
- if (yDist <= -3) and (sim.partProperty(i, "vy") >= -3) then
- sim.partProperty(i, "vy", sim.partProperty(i, "vy") - 1)
- end
- elseif (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_INSL) then -- wall
- if (math.abs(sim.partProperty(i, "vx")) >= 1) then
- sim.partProperty(i, "vx", sim.partProperty(i, "vx") * 0.8)
- end
- if (math.abs(sim.partProperty(i, "vy")) >= 1) then
- sim.partProperty(i, "vy", sim.partProperty(i, "vy") * 0.8)
- end
- local spaceCount = 0
- local wallCount = 0
- local otherCount = 0
- for xOffset = -1, 1, 1 do
- for yOffset = -1, 1, 1 do
- local currX = x + xOffset
- local currY = y + yOffset
- local currPart = sim.pmap(currX, currY)
- if (currPart == nil) then
- spaceCount = spaceCount + 1
- elseif (sim.partProperty(currPart, "type") ~= radAmoeba) then
- spaceCount = spaceCount + 1
- elseif (sim.partProperty(currPart, "ctype") == elements.DEFAULT_PT_INSL) then
- wallCount = wallCount + 1
- else
- otherCount = otherCount + 1
- end
- end
- end
- if (wallCount >= 4) and (spaceCount <= 1) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
- elseif (spaceCount == 0) then
- local wallTransfer = 1
- local eaterCount = 0
- for part in sim.neighbors(x, y, 1, 1, radAmoeba) do
- if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_URAN) then
- local spaceCount = 0
- for xOffset = -1, 1, 1 do
- for yOffset = -1, 1, 1 do
- local currX = sim.partProperty(part, "x") + xOffset
- local currY = sim.partProperty(part, "y") + yOffset
- local currPart = sim.pmap(currX, currY)
- if (currPart == nil) then
- spaceCount = spaceCount + 1
- elseif (sim.partProperty(currPart, "ctype") == radium) then
- eaterCount = eaterCount + 1
- end
- end
- end
- if (spaceCount >= 2) and (wallTransfer == 1) then
- sim.partProperty(part, "ctype", elements.DEFAULT_PT_INSL)
- wallTransfer = 0
- end
- end
- end
- if (eaterCount >= 3) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
- else
- sim.partProperty(i, "ctype", radium)
- end
- elseif (spaceCount >= 4) and (math.random(1, 300) == 1) then
- local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", 10 + sim.partProperty(i, "temp"))
- end
- sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 0.5)
- end
- elseif (sim.partProperty(i, "ctype") == radium) then -- eater
- if (math.random(1, 10) == 1) then -- only run eating behavior some of the time, to reduce lag and reduce chance of consumption of its own neutrons
- local metals = {elements.DEFAULT_PT_IRON, elements.DEFAULT_PT_METL, elements.DEFAULT_PT_BMTL, elements.DEFAULT_PT_BRMT, elements.DEFAULT_PT_SLCN,
- elements.DEFAULT_PT_BREC, elements.DEFAULT_PT_URAN, elements.DEFAULT_PT_PLUT, elements.DEFAULT_PT_POLO, radium, actinium, curium}
- for part in sim.neighbors(x, y, 1, 1) do
- local match = false
- for k, v in pairs(metals) do
- if (sim.partProperty(part, "type") == v) then
- match = true
- end
- end
- if not (match) then
- if (bit.band(elements.property(sim.partProperty(part, "type"), "Properties"), elements.TYPE_ENERGY) > 0) then -- check if particle is energy
- match = true
- end
- end
- if (match) then
- sim.partProperty(part, "ctype", 0)
- sim.partProperty(part, "type", radAmoeba)
- end
- end
- elseif (s >= 4) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_INSL)
- end
- elseif (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_URAN) then -- mass
- if (s >= 3) then -- empty spaces nearby
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_INSL)
- elseif (math.random(1, 120) == 1) then
- sim.partProperty(i, "ctype", 0) -- auto-reassign if needed (e.g. regions with no nuclei)
- end
- end
- local tempThreshold = 273 - 50 -- most particles will start to die at -50 C
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_INSL) then
- tempThreshold = 273 - 75 -- walls are more resilient and can handle down to -75 C
- end
- if (sim.partProperty(i, "temp") <= tempThreshold) then
- if (sim.partProperty(i, "temp") <= 5) or (math.random(1, sim.partProperty(i, "temp")) == 1) then
- if (math.random(1, 2) == 1) then
- sim.partProperty(i, "ctype", 0)
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 2)
- if (math.random(1, 2) == 1) then
- sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
- else
- sim.partProperty(i, "type", radon)
- end
- else
- sim.partKill(i)
- end
- return -1
- end
- end
- end
- local function radAmoebaGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_URAN) then -- mass
- rRed = rRed + math.random(1, 50)
- rGreen = rGreen + math.random(1, 50)
- elseif (sim.partProperty(i, "ctype") == radium) then -- eater
- rMode = rMode + ren.PMODE_GLOW
- elseif (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_INSL) then -- wall
- rMode = rMode + ren.PMODE_BLUR
- if (math.random(1, 4) == 1) then
- rMode = rMode + ren.PMODE_GLOW
- end
- rRed = 150
- rGreen = rGreen + 50
- rBlue = 130
- elseif (sim.partProperty(i, "ctype") == radAmoeba) then -- nucleus
- rRed = rGreen + 20
- rMode = rMode + ren.PMODE_GLOW
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(radAmoeba, "Update", radAmoebaUpdate)
- elements.property(radAmoeba, "Graphics", radAmoebaGraphics)
- local lead = elements.allocate("ARAD", "LEAD")
- elements.element(lead, elements.element(elements.DEFAULT_PT_TTAN))
- elements.property(lead, "Name", "LEAD")
- elements.property(lead, "Description", "Lead. Absorbs radiation efficiently, but heats up in the process. Low melting point. Can also oxidize.")
- elements.property(lead, "Color", 0x6677cc)
- elements.property(lead, "MenuVisible", 1)
- elements.property(lead, "MenuSection", elements.SC_SOLIDS)
- elements.property(lead, "HighTemperature", 273 + 327) -- 327 C, the melting point of lead
- elements.property(lead, "HeatConduct", 200)
- elements.property(lead, "Properties", elements.TYPE_SOLID + elements.PROP_CONDUCTS + elements.PROP_LIFE_DEC + elements.PROP_NEUTPASS)
- elements.property(lead, "PhotonReflectWavelengths", 0x0)
- local function leadUpdate(i, x, y, s, nt)
- if (nt >= 2) then
- local oxiFactor = 0
- for part in sim.neighbors(x, y, 1, 1) do
- local oxiPart = false
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_O2) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_CO2) then
- oxiFactor = oxiFactor + 3
- oxiPart = true
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_FOG) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_WTRV) then
- oxiFactor = oxiFactor + 2
- oxiPart = true
- elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_BOYL) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_GAS) then
- oxiFactor = oxiFactor + 1
- oxiPart = true
- end
- if (sim.partProperty(i, "tmp") < 1) and (oxiFactor >= 3) and (math.random(1, 4) == 1) and (oxiPart) then
- sim.partProperty(i, "tmp", 1)
- sim.partProperty(part, "type", elements.DEFAULT_PT_EMBR)
- sim.partProperty(part, "life", math.random(90, 120))
- end
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_NEUT) then
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + (sim.partProperty(part, "temp") / 5) - 5)
- sim.partKill(part)
- end
- end
- else
- local partHere = sim.photons(x, y)
- if (partHere ~= nil) and (math.random(1, 2) == 1) then
- if (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_NEUT) then
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + (sim.partProperty(partHere, "temp") / 5) - 5)
- sim.partKill(partHere)
- end
- end
- if (sim.partProperty(i, "life") == 1) then
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 1)
- end
- end
- end
- local function leadGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- if (sim.partProperty(i, "tmp") == 1) then
- rRed = rRed / 2
- rGreen = rGreen / 2
- rBlue = (rBlue / 2) - 10
- end
- if (sim.partProperty(i, "temp") >= (273 + 227)) then
- local tempDiff = sim.partProperty(i, "temp") - 273 - 227
- rRed = rRed + tempDiff
- rBlue = rBlue - tempDiff
- if (rBlue < 10) then
- rBlue = 10
- end
- if (tempDiff >= 50) and (math.random(1, 4) == 1) then
- rMode = rMode + ren.FIRE_ADD
- rBlue = (rBlue * 0.8)
- end
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(lead, "Update", leadUpdate)
- elements.property(lead, "Graphics", leadGraphics)
- local chromium = elements.allocate("ARAD", "CHRM")
- local liquidChromium = elements.allocate("ARAD", "LCHR")
- local steel = elements.allocate("ARAD", "SSTL")
- elements.element(chromium, elements.element(elements.DEFAULT_PT_TTAN))
- elements.property(chromium, "Name", "CHRM")
- elements.property(chromium, "Description", "Chromium. Shiny and conductive metal with a high melting point.")
- elements.property(chromium, "Color", 0xddddee)
- elements.property(chromium, "Hardness", 1)
- elements.property(chromium, "MenuVisible", 1)
- elements.property(chromium, "MenuSection", elements.SC_SOLIDS)
- elements.property(chromium, "Properties", elements.TYPE_SOLID + elements.PROP_CONDUCTS + elements.PROP_LIFE_DEC)
- elements.property(chromium, "HighTemperature", 1907 + 273)
- elements.property(chromium, "HighTemperatureTransition", liquidChromium)
- local function chromiumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- local partTemp = sim.partProperty(i, "temp")
- if (partTemp >= (1407 + 273)) then
- local tempDiff = partTemp - 1407 - 273
- rRed = rRed + (tempDiff / 20)
- if (rRed > 250) then
- rRed = 250
- end
- rGreen = rGreen - (tempDiff / 10)
- if (rGreen < 150) then
- rGreen = 150
- end
- rBlue = rBlue - (tempDiff / 4) - 5
- if (rBlue < 100) then
- rBlue = 100
- end
- if (math.random(1, 4) == 1) then
- rMode = rMode + ren.FIRE_ADD
- end
- end
- local partLife = sim.partProperty(i, "life")
- if (partLife >= 2) and (math.random(1, 6) <= partLife) then
- rGreen = rGreen + 10
- rBlue = rBlue + 10
- rMode = rMode + ren.PMODE_FLARE
- else
- rGreen = rGreen + math.random(1, 10)
- rBlue = rBlue + math.random(1, 10)
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(chromium, "Graphics", chromiumGraphics)
- elements.element(liquidChromium, elements.element(elements.DEFAULT_PT_GEL))
- elements.property(liquidChromium, "Name", "LCHR")
- elements.property(liquidChromium, "Description", "Liquid chromium. Very hot. Can be combined with molten METL or IRON to make stainless steel.")
- elements.property(liquidChromium, "Color", 0xffcc66)
- elements.property(liquidChromium, "MenuVisible", 1)
- elements.property(liquidChromium, "MenuSection", elements.SC_LIQUID)
- elements.property(liquidChromium, "Properties", elements.TYPE_LIQUID + elements.PROP_DEADLY + elements.PROP_LIFE_DEC)
- elements.property(liquidChromium, "Temperature", 2100 + 273.15)
- elements.property(liquidChromium, "LowTemperature", 1906 + 273)
- elements.property(liquidChromium, "LowTemperatureTransition", chromium)
- local function liquidChromiumUpdate(i, x, y, s, nt)
- if (nt >= 1) then
- for part in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_LAVA) do
- if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_IRON) or (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_METL) then
- if (sim.partProperty(i, "ctype") ~= steel) then
- sim.partProperty(i, "ctype", steel)
- sim.partProperty(i, "life", 60)
- sim.partKill(part)
- end
- end
- end
- end
- if (sim.partProperty(i, "ctype") == steel) and (sim.partProperty(i, "life") == 0) then
- sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 5)
- sim.partProperty(i, "type", elements.DEFAULT_PT_LAVA)
- return -1
- end
- end
- local function liquidChromiumGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT + ren.PMODE_BLUR
- if (math.random(1, 120) <= sim.partProperty(i, "life")) then
- rGreen = rGreen + 5
- rBlue = rBlue + 5
- rMode = rMode + ren.PMODE_LFLARE
- elseif (math.random(1, 4) == 1) then
- rGreen = rGreen + 6
- rBlue = rBlue + 12
- rMode = rMode + ren.FIRE_ADD
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(liquidChromium, "Update", liquidChromiumUpdate)
- elements.property(liquidChromium, "Graphics", liquidChromiumGraphics)
- elements.element(steel, elements.element(elements.DEFAULT_PT_TTAN))
- elements.property(steel, "Name", "SSTL")
- elements.property(steel, "Description", "Stainless steel. Highly durable metal, can even defend against VIRS.")
- elements.property(steel, "Color", 0xcccccc)
- elements.property(steel, "Hardness", 0)
- elements.property(steel, "MenuVisible", 1)
- elements.property(steel, "MenuSection", elements.SC_SOLIDS)
- elements.property(steel, "Properties", elements.TYPE_SOLID + elements.PROP_CONDUCTS + elements.PROP_LIFE_DEC + elements.PROP_HOT_GLOW + elements.PROP_SPARKSETTLE)
- elements.property(steel, "HighTemperature", 1550 + 273)
- local function steelUpdate(i, x, y, s, nt)
- if (nt >= 1) then
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_VIRS) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_VRSS) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_VRSG) then
- sim.partProperty(part, "type", elements.DEFAULT_PT_EMBR)
- sim.partProperty(part, "ctype", 0xee33ff)
- sim.partProperty(part, "life", math.random(30, 120))
- end
- end
- end
- end
- elements.property(steel, "Update", steelUpdate)
- local nanite = elements.allocate("ARAD", "NBOT")
- elements.element(nanite, elements.element(elements.DEFAULT_PT_GEL))
- elements.property(nanite, "Name", "NBOT")
- elements.property(nanite, "Description", "Nanobots. Can alter their behavior. Spark with PSCN to harden, NSCN to liquefy, or CHRM to assimilate.")
- elements.property(nanite, "Color", 0x9999aa)
- elements.property(nanite, "Weight", 46)
- elements.property(nanite, "Gravity", 0.15)
- elements.property(nanite, "MenuVisible", 1)
- elements.property(nanite, "MenuSection", elements.SC_POWERED)
- elements.property(nanite, "Properties", elements.TYPE_LIQUID + elements.PROP_LIFE_DEC)
- local function naniteUpdate(i, x, y, s, nt)
- if (sim.partProperty(i, "life") <= 0) then
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) and (sim.partProperty(part, "life") == 3) then
- if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_PSCN) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_PSCN)
- sim.partProperty(i, "life", 12)
- elseif (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_NSCN) then
- sim.partProperty(i, "ctype", elements.DEFAULT_PT_NSCN)
- sim.partProperty(i, "life", 12)
- elseif (sim.partProperty(part, "ctype") == chromium) then
- sim.partProperty(i, "ctype", chromium)
- sim.partProperty(i, "life", 12)
- end
- elseif (sim.partProperty(part, "type") == nanite) and (sim.partProperty(part, "life") == 11)
- and (sim.partProperty(i, "ctype") ~= sim.partProperty(part, "ctype")) then
- sim.partProperty(i, "ctype", sim.partProperty(part, "ctype"))
- sim.partProperty(i, "life", 12)
- end
- end
- end
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PSCN) or (nt == 0) then
- sim.partProperty(i, "vx", 0)
- sim.partProperty(i, "vy", 0)
- elseif (sim.partProperty(i, "ctype") == chromium) and (sim.partProperty(i, "life") <= 4) and (math.random(1, 4) == 1) then
- sim.partProperty(i, "type", chromium)
- end
- if (sim.partProperty(i, "tmp") <= 0) then
- if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PSCN) and (math.random(1, 240) == 1) then
- sim.partProperty(i, "tmp", math.random(60, 90))
- end
- else
- sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 1)
- end
- end
- local function naniteGraphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- if (sim.partProperty(i, "life") >= 9) then
- rRed = rRed + (sim.partProperty(i, "life") * 2)
- rGreen = rGreen + (sim.partProperty(i, "life") * 2)
- rBlue = rBlue + (sim.partProperty(i, "life") * 3)
- if (math.random(1, 12) == 1) or (sim.partProperty(i, "life") == 12) then
- rMode = rMode + ren.PMODE_FLARE
- end
- elseif (sim.partProperty(i, "tmp") >= 1) then
- local lMod = sim.partProperty(i, "tmp")
- if (lMod >= 90) then
- lMod = 90
- end
- rRed = rRed + math.floor(lMod * 0.1) - 12
- rGreen = rGreen + math.floor(lMod * 0.6) - 10
- rBlue = rBlue + lMod - 8
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(nanite, "Update", naniteUpdate)
- elements.property(nanite, "Graphics", naniteGraphics)
- local forceField1 = elements.allocate("ARAD", "FP32")
- elements.element(forceField1, elements.element(elements.DEFAULT_PT_FRME))
- elements.property(forceField1, "Name", "FP32")
- elements.property(forceField1, "Description", "Force Field Projector P32. Requires continuous power. Produces a circular light shield.")
- elements.property(forceField1, "Color", 0x00ee99)
- elements.property(forceField1, "MenuVisible", 1)
- elements.property(forceField1, "MenuSection", elements.SC_POWERED)
- elements.property(forceField1, "Properties", elements.TYPE_SOLID + elements.PROP_LIFE_DEC)
- local function ff1Update(i, x, y, s, nt)
- if (nt >= 1) then
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) and (sim.partProperty(part, "life") == 3) then
- sim.partProperty(i, "life", 10)
- end
- end
- end
- if (sim.partProperty(i, "tmp") >= 360) then
- sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 358)
- else
- sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") + 2)
- end
- local lRads = sim.partProperty(i, "tmp") * (3.142 / 180)
- local xMod = math.floor(33 * math.sin(lRads))
- local yMod = math.floor(33 * math.cos(lRads)) * -1 -- positive Y is down in TPT, so this needs to be inverted
- local function shieldCreate(lp, nx, ny)
- if (sim.photons(nx, ny) ~= nil) then
- sim.partKill(sim.photons(nx, ny))
- end
- if (sim.pmap(nx, ny) ~= nil) and (sim.partProperty(sim.pmap(nx, ny), "type") == elements.DEFAULT_PT_BRAY) and (sim.partProperty(sim.pmap(nx, ny), "life") <= 30) then
- sim.partKill(sim.pmap(nx, ny))
- end
- local newPart = sim.partCreate(-1, nx, ny, elements.DEFAULT_PT_BRAY)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", sim.partProperty(lp, "temp") - 2)
- sim.partProperty(newPart, "life", 90)
- sim.partProperty(newPart, "ctype", 0xff80)
- end
- end
- if (sim.partProperty(i, "life") >= 1) then
- shieldCreate(i, x + xMod, y + yMod)
- shieldCreate(i, x - xMod, y - yMod)
- local xMod = math.floor(34 * math.sin(lRads))
- local yMod = math.floor(34 * math.cos(lRads)) * -1
- shieldCreate(i, x + xMod, y + yMod)
- shieldCreate(i, x - xMod, y - yMod)
- end
- end
- local function ff1Graphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- if (sim.partProperty(i, "life") >= 1) and (sim.partProperty(i, "life") <= 11) then
- rRed = rRed + (sim.partProperty(i, "life") * 3)
- rBlue = rBlue + (sim.partProperty(i, "life") * 3)
- rMode = rMode + ren.PMODE_GLOW
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(forceField1, "Update", ff1Update)
- elements.property(forceField1, "Graphics", ff1Graphics)
- local forceField2 = elements.allocate("ARAD", "FP96")
- elements.element(forceField2, elements.element(elements.DEFAULT_PT_FRME))
- elements.property(forceField2, "Name", "FP96")
- elements.property(forceField2, "Description", "Force Field Projector P96. Requires continuous power. Produces a larger circular shield.")
- elements.property(forceField2, "Color", 0x0099ee)
- elements.property(forceField2, "MenuVisible", 1)
- elements.property(forceField2, "MenuSection", elements.SC_POWERED)
- elements.property(forceField2, "Properties", elements.TYPE_SOLID + elements.PROP_LIFE_DEC)
- local function ff2Update(i, x, y, s, nt)
- if (nt >= 1) then
- for part in sim.neighbors(x, y, 1, 1) do
- if (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) and (sim.partProperty(part, "life") == 3) then
- sim.partProperty(i, "life", 10)
- end
- end
- end
- if (sim.partProperty(i, "tmp") >= 360) then
- sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 359)
- else
- sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") + 1)
- end
- local lRads = sim.partProperty(i, "tmp") * (3.142 / 180)
- local xMod = math.floor(97 * math.sin(lRads))
- local yMod = math.floor(97 * math.cos(lRads)) * -1 -- positive Y is down in TPT, so this needs to be inverted
- local function shieldCreate(lp, nx, ny)
- if (sim.photons(nx, ny) ~= nil) then
- sim.partKill(sim.photons(nx, ny))
- end
- if (sim.pmap(nx, ny) ~= nil) and (sim.partProperty(sim.pmap(nx, ny), "type") == elements.DEFAULT_PT_BRAY) and (sim.partProperty(sim.pmap(nx, ny), "life") <= 30) then
- sim.partKill(sim.pmap(nx, ny))
- end
- local newPart = sim.partCreate(-1, nx, ny, elements.DEFAULT_PT_BRAY)
- if (newPart >= 0) then
- sim.partProperty(newPart, "temp", sim.partProperty(lp, "temp") - 2)
- sim.partProperty(newPart, "life", 120)
- sim.partProperty(newPart, "ctype", 0x17ff)
- end
- end
- if (sim.partProperty(i, "life") >= 1) then
- for j = 97, 99 do
- for k = 0, 2 do
- xMod = math.floor(j * math.sin(lRads + (k * 2.094)))
- yMod = math.floor(j * math.cos(lRads + (k * 2.094))) * -1
- -- 2.094 = 2(pi)/3; creates points that form an equilateral triangle, hopefully
- shieldCreate(i, x + xMod, y + yMod)
- end
- end
- end
- end
- local function ff2Graphics(i, colr, colg, colb)
- local rRed = colr
- local rGreen = colg
- local rBlue = colb
- local rMode = ren.PMODE_FLAT
- if (sim.partProperty(i, "life") >= 1) and (sim.partProperty(i, "life") <= 11) then
- rRed = rRed + (sim.partProperty(i, "life") * 3)
- rGreen = rGreen + (sim.partProperty(i, "life") * 3)
- rMode = rMode + ren.PMODE_GLOW
- end
- return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
- end
- elements.property(forceField2, "Update", ff2Update)
- elements.property(forceField2, "Graphics", ff2Graphics)
Advertisement
Add Comment
Please, Sign In to add comment