cool_username_2

TPT - Radtech v1.0 Script Paste

Sep 16th, 2025
72
2
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 57.46 KB | Software | 2 0
  1. -- TPT Lua Script - Content Mod
  2. -- ReallyJustDont's Radiation and Technology Mod v1.0
  3. -- 2025
  4.  
  5. local radon = elements.allocate("ARAD", "RDON")
  6. local radium = elements.allocate("ARAD", "RDIM")
  7.  
  8. elements.element(radon, elements.element(elements.DEFAULT_PT_NBLE))
  9. elements.property(radon, "Name", "RDON")
  10. elements.property(radon, "Description", "Radon. Heavy, translucent gas. Absorbs protons, but may turn into radium or other heavy metals.")
  11. elements.property(radon, "Color", 0x007766)
  12. elements.property(radon, "MenuVisible", 1)
  13. elements.property(radon, "MenuSection", elements.SC_NUCLEAR)
  14. elements.property(radon, "Gravity", 0.02)
  15. elements.property(radon, "Diffusion", 0.5)
  16. elements.property(radon, "HotAir", 0)
  17. elements.property(radon, "Properties", elements.TYPE_GAS + elements.PROP_PHOTPASS + elements.PROP_NEUTPASS + elements.PROP_DEADLY)
  18.  
  19. local function radonUpdate(i, x, y, s, nt)
  20.     local protons = 0
  21.     for part in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_PROT) do
  22.         protons = protons + 1
  23.         if (math.random(1, 4) == 1) then
  24.             sim.partKill(part)
  25.             sim.partProperty(i, "life", sim.partProperty(i, "life") + 4)
  26.         end -- if
  27.     end -- for
  28.     if (protons == 0) and (math.random(1, 8) == 1) and (sim.partProperty(i, "life") > 0) then
  29.         sim.partProperty(i, "life", sim.partProperty(i, "life") - 1)
  30.     end -- if
  31.     if (sim.partProperty(i, "life") >= 20) then
  32.         sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 0.2)
  33.         if (math.random(1, 2) == 1) then
  34.             if (math.random(1, 4) == 1) then
  35.                 sim.partProperty(i, "type", elements.DEFAULT_PT_PLUT)
  36.             else
  37.                 sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
  38.             end
  39.         else
  40.             sim.partProperty(i, "type", radium)
  41.         end
  42.  
  43.         return -1
  44.     end -- if
  45. end -- function
  46.  
  47. local function radonGraphics(i, colr, colg, colb)
  48.     local rMode = ren.DECO_FIRE + ren.FIRE_BLEND
  49.     if (sim.partProperty(i, "life") >= 2) then
  50.         rMode = rMode + ren.PMODE_FLARE
  51.     end
  52.     return 0, rMode, 150, colr, colg, colb, 150, colr / 2, colg / 2, colb / 2
  53. end -- function
  54.  
  55. elements.property(radon, "Update", radonUpdate)
  56. elements.property(radon, "Graphics", radonGraphics)
  57.  
  58. elements.element(radium, elements.element(elements.DEFAULT_PT_GOLD))
  59. elements.property(radium, "Name", "RDIM")
  60. elements.property(radium, "Description", "Radium. Solid, reactive, and sometimes emits hot neutrons. Decays under pressure, and can also melt.")
  61. elements.property(radium, "Color", 0x00cc33)
  62. elements.property(radium, "MenuVisible", 1)
  63. elements.property(radium, "MenuSection", elements.SC_NUCLEAR)
  64. elements.property(radium, "Hardness", 4)
  65. elements.property(radium, "Properties", elements.TYPE_SOLID + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE)
  66. elements.property(radium, "HighTemperature", 700 + 273) -- 700 celsius converted to kelvin
  67. elements.property(radium, "PhotonReflectWavelengths", 0x1fe00)
  68.  
  69. local function radiumUpdate(i, x, y, s, nt)
  70.     local water = 0
  71.     if (math.random(1, 4) == 1) then
  72.         for part in sim.neighbors(x, y, 1, 1) do
  73.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_WATR) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_DSTW) then
  74.                 water = water + 3
  75.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_CBNW) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_O2) then
  76.                 water = water + 2
  77.             end
  78.         end
  79.     end -- if
  80.     if (math.random(1, 100) < water) or (sim.partProperty(i, "life") >= 100) then
  81.         for part in sim.neighbors(x, y, 2, 2, radium) do
  82.             sim.partProperty(part, "life", 100)
  83.         end
  84.         sim.partProperty(i, "life", 0)
  85.         sim.partProperty(i, "tmp", 50)
  86.         sim.partProperty(i, "type", elements.DEFAULT_PT_SING)
  87.         for count = 1, 8, 1 do
  88.             sim.partCreate(-2, math.random(x - 3, x + 3), math.random(y - 3, y + 3), elements.DEFAULT_PT_PLSM)
  89.         end
  90.         return -1
  91.     end
  92.     if (sim.pressure(x / 4, y / 4) >= 2) then
  93.         if (math.random(1, 100) < sim.pressure(x / 4, y / 4)) then
  94.             sim.partProperty(i, "life", sim.partProperty(i, "life") + 1)
  95.         end
  96.     end
  97.     local neutFactor = 6000
  98.     if (s >= 2) then -- if 2 or more empty spaces near this particle
  99.         neutFactor = 4500
  100.     end
  101.     if (sim.partProperty(i, "life") >= 50) or (sim.partProperty(i, "temp") >= (400 + 273)) then
  102.         neutFactor = neutFactor - 1000
  103.     end
  104.     if (math.random(1, neutFactor) == 1) then
  105.         local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
  106.         if (newPart >= 0) then
  107.             sim.partProperty(newPart, "temp", 400 + 273 + (sim.partProperty(i, "temp") / 5))
  108.         end
  109.     end
  110. end
  111.  
  112. local function radiumGraphics(i, colr, colg, colb)
  113.     local rRed = colr
  114.     local rGreen = colg
  115.     local rBlue = colb
  116.     local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
  117.     if (sim.partProperty(i, "temp") >= (400 + 273)) then -- start glowing at 400C
  118.         local tempDiff = (sim.partProperty(i, "temp") - 673) / 2
  119.         if (tempDiff > 150) then
  120.             tempDiff = 150
  121.         end
  122.         rRed = rRed + tempDiff
  123.         rGreen = rGreen - (tempDiff * 0.8)
  124.     end
  125.     if (sim.partProperty(i, "life") >= 0) and (sim.partProperty(i, "life") <= 200) then
  126.         rRed = rRed + (sim.partProperty(i, "life") / 4)
  127.         rBlue = rBlue + (sim.partProperty(i, "life") / 5)
  128.         if (sim.partProperty(i, "life") >= 50) then
  129.             rMode = rMode + ren.FIRE_ADD
  130.         end
  131.     else
  132.         rRed = rRed + 20
  133.         rBlue = rBlue + 20
  134.     end
  135.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
  136. end -- function
  137.  
  138. elements.property(radium, "Update", radiumUpdate)
  139. elements.property(radium, "Graphics", radiumGraphics)
  140.  
  141. local tritium = elements.allocate("ARAD", "TRIT")
  142.  
  143. elements.element(tritium, elements.element(elements.DEFAULT_PT_GEL))
  144. elements.property(tritium, "Name", "TRIT")
  145. elements.property(tritium, "Description", "Liquid tritium. Specialized for fast proton reactions; reverts to DEUT when electrified.")
  146. elements.property(tritium, "Color", 0x9966ff)
  147. elements.property(tritium, "MenuVisible", 1)
  148. elements.property(tritium, "MenuSection", elements.SC_NUCLEAR)
  149. elements.property(tritium, "Gravity", 0.11)
  150. elements.property(tritium, "Weight", 33)
  151. elements.property(tritium, "HeatConduct", 190)
  152. elements.property(tritium, "Properties", elements.TYPE_LIQUID + elements.PROP_SPARKSETTLE)
  153.  
  154. local function tritiumUpdate(i, x, y, s, nt)
  155.     if (nt >= 2) or (math.random(1, 100) == 1) then
  156.         local protVal = 0
  157.         local elecVal = 0
  158.         for part in sim.neighbors(x, y, 1, 1) do
  159.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_PROT) then
  160.                 protVal = protVal + 2
  161.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_ELEC) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_LIGH) then
  162.                 elecVal = elecVal + 2
  163.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_EMBR) then
  164.                 elecVal = elecVal + 1
  165.             end
  166.         end
  167.  
  168.         if (elecVal > protVal) then
  169.             if (math.random(1, 4) <= elecVal) then
  170.                 sim.partProperty(i, "life", 30 + (2 * elecVal))
  171.                 sim.partProperty(i, "ctype", 0)
  172.                 sim.partProperty(i, "type", elements.DEFAULT_PT_DEUT)
  173.                
  174.                 return -1
  175.             end
  176.         end
  177.         if (protVal > elecVal) then
  178.             sim.partProperty(i, "ctype", elements.DEFAULT_PT_PROT)
  179.             if (math.random(1, 4) <= protVal) then
  180.                 sim.partProperty(i, "life", sim.partProperty(i, "life") + 10)
  181.                 local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PROT)
  182.                 if (newPart >= 0) then
  183.                     sim.partProperty(newPart, "temp", 1200 + 273 + (sim.partProperty(i, "temp") * 0.8))
  184.                 end
  185.                 sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) - 0.4)
  186.             end
  187.             if (sim.partProperty(i, "life") >= 60) then
  188.                 sim.partKill(i)
  189.  
  190.                 return -1
  191.             end
  192.         end
  193.     end
  194.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PROT) and (sim.partProperty(i, "life") >= 1) then
  195.         sim.partProperty(i, "life", sim.partProperty(i, "life") - 1)
  196.         if (sim.partProperty(i, "life")) <= 1 then
  197.             sim.partProperty(i, "ctype", 0)
  198.         end
  199.     end
  200. end
  201.  
  202. local function tritiumGraphics(i, colr, colg, colb)
  203.     local rRed = colr
  204.     local rGreen = colg
  205.     local rBlue = colb
  206.     local rMode = ren.PMODE_FLAT + ren.PMODE_BLUR
  207.     if (math.random(1, 100) == 1) then
  208.         rMode = rMode + ren.PMODE_FLARE
  209.         rRed = rRed + 10
  210.         rGreen = rGreen + 8
  211.         rBlue = rBlue + 10
  212.     end
  213.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PROT) then
  214.         rRed = rRed + 30
  215.         rGreen = rGreen - 10
  216.         rBlue = rBlue - 10
  217.         if (math.random(1, 100) == 1) then
  218.             rMode = rMode + ren.PMODE_LFLARE
  219.         end
  220.     end
  221.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
  222. end -- function
  223.  
  224. elements.property(tritium, "Update", tritiumUpdate)
  225. elements.property(tritium, "Graphics", tritiumGraphics)
  226.  
  227. local neutronium = elements.allocate("ARAD", "NTRM")
  228.  
  229. elements.element(neutronium, elements.element(elements.DEFAULT_PT_GOO))
  230. elements.property(neutronium, "Name", "NTRM")
  231. elements.property(neutronium, "Description", "Neutronium. Loses power over time, can be charged with neutrons. Vulnerable to pressure if unpowered.")
  232. elements.property(neutronium, "Color", 0x0099ff)
  233. elements.property(neutronium, "MenuVisible", 1)
  234. elements.property(neutronium, "MenuSection", elements.SC_NUCLEAR)
  235. elements.property(neutronium, "HeatConduct", 120)
  236. elements.property(neutronium, "Hardness", 0)
  237. elements.property(neutronium, "Loss", 0)
  238. elements.property(neutronium, "Properties", elements.TYPE_SOLID + elements.PROP_SPARKSETTLE + elements.PROP_LIFE_DEC)
  239. elements.property(neutronium, "PhotonReflectWavelengths", 0xff80)
  240.  
  241. local function neutroniumCreate(i, x, y, t, v)
  242.     sim.partProperty(i, "life", 3000)
  243. end
  244.  
  245. local function neutroniumUpdate(i, x, y, s, nt)
  246.     if (nt >= 1) then
  247.         for part in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_NEUT) do
  248.             local lifeAdd = 1200 + sim.partProperty(part, "life")
  249.             sim.partKill(part)
  250.             if (sim.partProperty(i, "life") <= 3000) then
  251.                 lifeAdd = lifeAdd + 1800
  252.             end
  253.             sim.partProperty(i, "life", sim.partProperty(i, "life") + lifeAdd)
  254.         end
  255.     end
  256.     if (math.random(1, 4) == 1) then
  257.         for part in sim.neighbors(x, y, 1, 1, neutronium) do
  258.             if (sim.partProperty(part, "life") < (sim.partProperty(i, "life") - 10)) then
  259.                 local lSum = sim.partProperty(i, "life") + sim.partProperty(part, "life")
  260.                 if (sim.partProperty(i, "life") > (lSum * 0.6)) then
  261.                     sim.partProperty(i, "life", lSum * 0.6)
  262.                     sim.partProperty(part, "life", lSum * 0.5)
  263.                 else
  264.                     sim.partProperty(i, "life", sim.partProperty(i, "life") - 8)
  265.                     sim.partProperty(part, "life", sim.partProperty(part, "life") + 8)
  266.                 end
  267.             end
  268.         end
  269.     end
  270.     if (math.random(1, 20) == 1) and (sim.partProperty(i, "life") == 0) then
  271.         if (sim.pressure(x / 4, y / 4) >= 4) then
  272.             sim.partProperty(i, "life", 60)
  273.             sim.partProperty(i, "type", elements.DEFAULT_PT_BRAY)
  274.  
  275.             return -1
  276.         end
  277.     end
  278. end
  279.  
  280. local function neutroniumGraphics(i, colr, colg, colb)
  281.     local rRed = colr
  282.     local rGreen = colg
  283.     local rBlue = colb
  284.     local rMode = ren.PMODE_FLAT
  285.     if (sim.partProperty(i, "life") > 0) then
  286.         rMode = rMode + ren.PMODE_GLOW
  287.         local lightAdd = sim.partProperty(i, "life") / 20
  288.         if (lightAdd >= 90) then
  289.             lightAdd = 90
  290.         end
  291.         rRed = rRed + lightAdd
  292.         rGreen = rGreen + lightAdd
  293.  
  294.         if (sim.partProperty(i, "life") >= 3600) and (math.random(1, 60) == 1) then
  295.             rMode = rMode + ren.PMODE_FLARE
  296.         end
  297.     else
  298.         rBlue = rBlue - math.random(20, 40)
  299.     end
  300.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
  301. end
  302.  
  303. elements.property(neutronium, "Create", neutroniumCreate)
  304. elements.property(neutronium, "Update", neutroniumUpdate)
  305. elements.property(neutronium, "Graphics", neutroniumGraphics)
  306.  
  307. local actinium = elements.allocate("ARAD", "ACTN")
  308. local curium = elements.allocate("ARAD", "CURI")
  309. local zeroAlloy = elements.allocate("ARAD", "ZRAL")
  310.  
  311. elements.element(actinium, elements.element(elements.DEFAULT_PT_GOO))
  312. elements.property(actinium, "Name", "ACTN")
  313. elements.property(actinium, "Description", "Actinium. Solid, can oxidize. Absorbs protons and neutrons, but may turn into heavier metals. Decays under pressure.")
  314. elements.property(actinium, "Color", 0x0066ff)
  315. elements.property(actinium, "MenuVisible", 1)
  316. elements.property(actinium, "MenuSection", elements.SC_NUCLEAR)
  317. elements.property(actinium, "HeatConduct", 160)
  318. elements.property(actinium, "Hardness", 4)
  319. elements.property(actinium, "Loss", 0)
  320. elements.property(actinium, "Properties", elements.TYPE_SOLID + elements.PROP_SPARKSETTLE + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE + elements.PROP_LIFE_DEC)
  321. elements.property(actinium, "PhotonReflectWavelengths", 0x1fff8)
  322.  
  323. local function actiniumUpdate(i, x, y, s, nt)
  324.     if (nt >= 2) then
  325.         local oxiFactor = 0
  326.         for part in sim.neighbors(x, y, 1, 1) do
  327.             local oxiPart = false
  328.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_O2) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_CO2) then
  329.                 oxiFactor = oxiFactor + 3
  330.                 oxiPart = true
  331.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_FOG) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_WTRV) then
  332.                 oxiFactor = oxiFactor + 2
  333.                 oxiPart = true
  334.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_BOYL) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_GAS) then
  335.                 oxiFactor = oxiFactor + 1
  336.                 oxiPart = true
  337.             end
  338.             if (sim.partProperty(i, "ctype") ~= elements.DEFAULT_PT_O2) and (oxiFactor >= 3) and (math.random(1, 20) == 1) and (oxiPart) then
  339.                 sim.partProperty(i, "ctype", elements.DEFAULT_PT_O2)
  340.                 sim.partProperty(part, "type", elements.DEFAULT_PT_EMBR)
  341.                 sim.partProperty(part, "life", math.random(90, 120))
  342.             end
  343.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_NEUT) then
  344.                 if (math.random(1, 4) == 1) then
  345.                     sim.partKill(part)
  346.                     sim.partProperty(i, "life", sim.partProperty(i, "life") + 20)
  347.                 end
  348.             end
  349.         end
  350.     else
  351.         local partHere = sim.photons(x, y)
  352.         if (partHere ~= nil) and (math.random(1, 2) == 1) then
  353.             if (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_NEUT) then
  354.                 sim.partKill(partHere)
  355.                 sim.partProperty(i, "life", sim.partProperty(i, "life") + 20)
  356.             end
  357.         end
  358.     end
  359.     if (sim.partProperty(i, "life") >= 80) then
  360.         sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 0.4)
  361.         sim.partProperty(i, "life", 0)
  362.         sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 5)
  363.         sim.partProperty(i, "ctype", 0)
  364.         if (math.random(1, 2) == 1) then
  365.             if (math.random(1, 2) == 1) then
  366.                 sim.partProperty(i, "type", elements.DEFAULT_PT_PLUT)
  367.             else
  368.                 sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
  369.             end
  370.         else
  371.             sim.partProperty(i, "type", curium)
  372.         end
  373.  
  374.         return -1
  375.     end
  376.     local pThreshold = 8
  377.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_O2) then
  378.         pThreshold = 4
  379.     end
  380.     if (sim.pressure(x / 4, y / 4) >= pThreshold) and (math.random(1, 120) <= sim.pressure(x / 4, y / 4)) then
  381.         local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
  382.         if (newPart >= 0) then
  383.             sim.partProperty(newPart, "temp", 50 + sim.partProperty(i, "temp"))
  384.         end
  385.  
  386.         sim.partProperty(i, "life", 0)
  387.         sim.partProperty(i, "ctype", 0)
  388.         if (math.random(1, 2) == 1) then
  389.             if (math.random(1, 2) == 1) then
  390.                 sim.partProperty(i, "type", elements.DEFAULT_PT_STNE)
  391.             else
  392.                 sim.partProperty(i, "type", elements.DEFAULT_PT_SAND)
  393.             end
  394.         else
  395.             sim.partProperty(i, "type", radon)
  396.         end
  397.  
  398.         return -1
  399.     end
  400. end
  401. local function actiniumGraphics(i, colr, colg, colb)
  402.     local rRed = colr
  403.     local rGreen = colg
  404.     local rBlue = colb
  405.     local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
  406.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_O2) then
  407.         rRed = rRed + 50
  408.         rGreen = rGreen + 50
  409.     end
  410.     if (math.random(1, 60) < sim.partProperty(i, "life")) then
  411.         rRed = rRed + 20
  412.         rGreen = rGreen + 20
  413.         rMode = rMode + ren.PMODE_FLARE
  414.     end
  415.    
  416.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  417. end
  418.  
  419. elements.property(actinium, "Update", actiniumUpdate)
  420. elements.property(actinium, "Graphics", actiniumGraphics)
  421.  
  422. elements.element(curium, elements.element(elements.DEFAULT_PT_GOO))
  423. elements.property(curium, "Name", "CURI")
  424. elements.property(curium, "Description", "Curium. Solid, undergoes beta decay. Can be accelerated by electrons or low pressure.")
  425. elements.property(curium, "Color", 0xff3366)
  426. elements.property(curium, "MenuVisible", 1)
  427. elements.property(curium, "MenuSection", elements.SC_NUCLEAR)
  428. elements.property(curium, "HeatConduct", 160)
  429. elements.property(curium, "Hardness", 6)
  430. elements.property(curium, "Loss", 0)
  431. elements.property(curium, "Properties", elements.TYPE_SOLID + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE)
  432. elements.property(curium, "PhotonReflectWavelengths", 0x3c00000f)
  433.  
  434. local function curiumUpdate(i, x, y, s, nt)
  435.     if (nt >= 2) then
  436.         local elecFactor = 1200
  437.         local isozFactor = 0
  438.         for part in sim.neighbors(x, y, 1, 1) do
  439.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_ELEC) and (elecFactor >= 600) then
  440.                 elecFactor = elecFactor - 120
  441.             end
  442.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_ISOZ) then
  443.                 isozFactor = isozFactor + 1
  444.             end
  445.         end
  446.         if (isozFactor >= 1) then
  447.             for part in sim.neighbors(x, y, 1, 1) do
  448.                 if (sim.partProperty(part, "type") == curium) and (isozFactor >= 2) then
  449.                     isozFactor = isozFactor - 1
  450.                     sim.partProperty(part, "type", zeroAlloy)
  451.                 end
  452.                 if (sim.partProperty(part, "type") == elements.DEFAULT_PT_ISOZ) then
  453.                     sim.partKill(part)
  454.                 end
  455.             end
  456.             sim.partProperty(i, "type", zeroAlloy)
  457.  
  458.             return -1
  459.         end
  460.         if (sim.pressure(x / 4, y / 4) <= -2) then
  461.             elecFactor = elecFactor - 150
  462.             if (sim.pressure(x / 4, y / 4) <= -10) then
  463.                 elecFactor = elecFactor - 150
  464.             end
  465.         end
  466.         if (math.random(1, elecFactor) == 1) then
  467.             local newPart = sim.partCreate(-2, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_ELEC)
  468.             if (newPart >= 0) then
  469.                 sim.partProperty(newPart, "temp", 300 + (sim.partProperty(i, "temp") * 0.9))
  470.                 sim.partProperty(i, "life", sim.partProperty(i, "life") + 1)
  471.             end
  472.         end
  473.         if (sim.partProperty(i, "life") >= 6) then
  474.             sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) - 0.4)
  475.             sim.partProperty(i, "life", 0)
  476.             sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 5)
  477.             sim.partProperty(i, "ctype", 0)
  478.             if (math.random(1, 2) == 1) then
  479.                 if (math.random(1, 2) == 1) then
  480.                     sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
  481.                 else
  482.                     sim.partProperty(i, "type", radon)
  483.                 end
  484.             else
  485.                 sim.partProperty(i, "type", radium)
  486.             end
  487.  
  488.             return -1
  489.         end
  490.     end
  491. end
  492. local function curiumGraphics(i, colr, colg, colb)
  493.     local rRed = colr
  494.     local rGreen = colg
  495.     local rBlue = colb
  496.     local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
  497.     if (sim.partProperty(i, "life") >= 3) then
  498.         rGreen = rGreen + 50
  499.         rBlue = rBlue + 60
  500.         if (sim.partProperty(i, "life") >= 5) and (math.random(1, 2) == 1)then
  501.             rMode = rMode + ren.PMODE_LFLARE
  502.         end
  503.     end
  504.    
  505.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  506. end
  507.  
  508. elements.property(curium, "Update", curiumUpdate)
  509. elements.property(curium, "Graphics", curiumGraphics)
  510.  
  511. elements.element(zeroAlloy, elements.element(elements.DEFAULT_PT_TTAN))
  512. elements.property(zeroAlloy, "Name", "ZRAL")
  513. elements.property(zeroAlloy, "Description", "Zero Alloy. Created by infusing Curium with Isotope-Z. Cools itself and emits photons. Melts into ISOZ with extreme heat.")
  514. elements.property(zeroAlloy, "Color", 0x3300ff)
  515. elements.property(zeroAlloy, "MenuVisible", 1)
  516. elements.property(zeroAlloy, "MenuSection", elements.SC_NUCLEAR)
  517. elements.property(zeroAlloy, "Hardness", 2)
  518. elements.property(zeroAlloy, "Properties", elements.TYPE_SOLID + elements.PROP_PHOTPASS + elements.PROP_RADIOACTIVE)
  519. elements.property(zeroAlloy, "HighTemperature", 3333 + 273) -- 3,333 celsius converted to kelvin
  520. elements.property(zeroAlloy, "HighTemperatureTransition", elements.DEFAULT_PT_ISOZ)
  521.  
  522. local function zeroAlloyUpdate(i, x, y, s, nt)
  523.     local photFactor = 3000
  524.     if (sim.pressure(x / 4, y / 4) <= -2) then
  525.         photFactor = 2700
  526.         if (sim.pressure(x / 4, y / 4) <= -4) then
  527.             photFactor = photFactor + (sim.pressure(x / 4, y / 4) * 2)
  528.         end
  529.     end
  530.     if (sim.partProperty(i, "temp") >= 273) then
  531.         photFactor = photFactor - (sim.partProperty(i, "temp") / 10)
  532.     end
  533.     if (math.random(1, photFactor) == 1) then
  534.         local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PHOT)
  535.         if (newPart >= 0) then
  536.             local newTemp = sim.partProperty(i, "temp") * 0.9
  537.             if (sim.partProperty(i, "temp") >= 173) then
  538.                 newTemp = newTemp - 2
  539.             end
  540.             sim.partProperty(newPart, "temp", newTemp)
  541.             sim.partProperty(newPart, "vx", math.random(-3, 3))
  542.             sim.partProperty(newPart, "vy", math.random(-3, 3))
  543.             sim.partProperty(i, "life", 45)
  544.         end
  545.     elseif (sim.partProperty(i, "life") > 0) then
  546.         sim.partProperty(i, "life", sim.partProperty(i, "life") - 1)
  547.     end
  548. end
  549.  
  550. local function zeroAlloyGraphics(i, colr, colg, colb)
  551.     local rRed = colr
  552.     local rGreen = colg
  553.     local rBlue = colb
  554.     local rMode = ren.PMODE_FLAT + ren.PMODE_GLOW
  555.     if (sim.partProperty(i, "temp") >= (1333 + 273)) then
  556.         local tempDiff = sim.partProperty(i, "temp") - 1333 - 273
  557.         rRed = rRed + (tempDiff / 20) + 5
  558.         if (rRed > 150) then
  559.             rRed = 150
  560.         end
  561.     end
  562.     if (sim.partProperty(i, "life") >= 5) and (sim.partProperty(i, "life") <= 50) then
  563.         rRed = rRed + sim.partProperty(i, "life")
  564.         rGreen = rGreen + sim.partProperty(i, "life")
  565.         if (math.random(1, 60) <= sim.partProperty(i, "life")) then
  566.             rMode = rMode + ren.PMODE_FLARE
  567.         end
  568.     end
  569.    
  570.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed / 2, rGreen / 2, rBlue / 2
  571. end
  572.  
  573. elements.property(zeroAlloy, "Update", zeroAlloyUpdate)
  574. elements.property(zeroAlloy, "Graphics", zeroAlloyGraphics)
  575.  
  576. local oganesson = elements.allocate("ARAD", "OGAN")
  577.  
  578. elements.element(oganesson, elements.element(elements.DEFAULT_PT_STNE))
  579. elements.property(oganesson, "Name", "OGAN")
  580. elements.property(oganesson, "Description", "Oganesson. Very heavy particles that quickly decay and release energy. High destructive potential.")
  581. elements.property(oganesson, "Color", 0x9999cc)
  582. elements.property(oganesson, "MenuVisible", 1)
  583. elements.property(oganesson, "MenuSection", elements.SC_NUCLEAR)
  584. elements.property(oganesson, "Gravity", 0.5)
  585. elements.property(oganesson, "Advection", 0.2)
  586. elements.property(oganesson, "Temperature", 1273.15)
  587. elements.property(oganesson, "Properties", elements.TYPE_PART + elements.PROP_NEUTPASS + elements.PROP_RADIOACTIVE)
  588. elements.property(oganesson, "HighTemperature", sim.ITH)
  589. elements.property(oganesson, "HighTemperatureTransition", sim.NT)
  590.  
  591. local function oganessonUpdate(i, x, y, s, nt)
  592.     if (nt >= 2) then
  593.         local lifeAdd = 0
  594.         if (math.random(1, 10) == 1) then
  595.             local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
  596.             if (newPart >= 0) then
  597.                 sim.partProperty(newPart, "temp", sim.partProperty(i, "temp") + 200)
  598.                 lifeAdd = lifeAdd + 4
  599.             end
  600.         elseif (math.random(1, 10) == 1) then
  601.             local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PROT)
  602.             if (newPart >= 0) then
  603.                 sim.partProperty(newPart, "temp", sim.partProperty(i, "temp") + 200)
  604.                 lifeAdd = lifeAdd + 5
  605.             end
  606.         end
  607.         if (math.random(1, 15) == 1) then
  608.             local newPart = sim.partCreate(-2, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_PLSM)
  609.             if (newPart >= 0) then
  610.                 sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 1)
  611.                 lifeAdd = lifeAdd + 2
  612.             end
  613.         end
  614.         if (math.random(1, 30) == 1) then
  615.             local newPart = sim.partCreate(-2, math.random(x - 1, x + 1), math.random(y - 1, y + 1), radon)
  616.             if (newPart >= 0) then
  617.                 sim.partProperty(newPart, "temp", sim.partProperty(i, "temp") + 100)
  618.                 lifeAdd = lifeAdd + 10
  619.             end
  620.         end
  621.  
  622.         sim.partProperty(i, "life", sim.partProperty(i, "life") + lifeAdd)
  623.         if (sim.partProperty(i, "life") >= 30) then
  624.             sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 1)
  625.             sim.partProperty(i, "life", 0)
  626.             sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 300)
  627.             sim.partProperty(i, "ctype", 0)
  628.             if (math.random(1, 2) == 1) then
  629.                 if (math.random(1, 2) == 1) then
  630.                     sim.partProperty(i, "type", elements.DEFAULT_PT_SING)
  631.                     sim.partProperty(i, "tmp", 50)
  632.                 else
  633.                     sim.partProperty(i, "type", elements.DEFAULT_PT_PLUT)
  634.                 end
  635.             else
  636.                 sim.partProperty(i, "type", radium)
  637.             end
  638.  
  639.             return -1
  640.         end
  641.     end
  642. end
  643.  
  644. elements.property(oganesson, "Update", oganessonUpdate)
  645.  
  646. local radAmoeba = elements.allocate("ARAD", "RMOE")
  647.  
  648. elements.element(radAmoeba, elements.element(elements.DEFAULT_PT_GEL))
  649. elements.property(radAmoeba, "Name", "RMOE")
  650. elements.property(radAmoeba, "Description", "Radioactive Amoeba. Particles self-assign roles. Eats metal and radiation, dies when cold. Uses Newtonian gravity.")
  651. elements.property(radAmoeba, "Color", 0x119900)
  652. elements.property(radAmoeba, "MenuVisible", 1)
  653. elements.property(radAmoeba, "MenuSection", elements.SC_NUCLEAR)
  654. elements.property(radAmoeba, "Gravity", 0.11)
  655. elements.property(radAmoeba, "Weight", 42)
  656. elements.property(radAmoeba, "HeatConduct", 190)
  657. elements.property(radAmoeba, "Properties", elements.TYPE_LIQUID + elements.PROP_RADIOACTIVE + elements.PROP_NEUTPASS)
  658.  
  659. local function radAmoebaUpdate(i, x, y, s, nt)
  660.     if (sim.partProperty(i, "ctype") == 0) and (math.random(1, 2) == 1) then -- self-assign role if it doesn't have one
  661.         local wallCount = 0
  662.         local nucleusCount = 0
  663.         local eaterCount = 0
  664.         local massCount = 0
  665.         for part in sim.neighbors(x, y, 3, 3, radAmoeba) do
  666.             if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_INSL) then
  667.                 wallCount = wallCount + 1
  668.             elseif (sim.partProperty(part, "ctype") == radAmoeba) then
  669.                 nucleusCount = nucleusCount + 1
  670.             elseif (sim.partProperty(part, "ctype") == radium) then
  671.                 eaterCount = eaterCount + 1
  672.             elseif (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_URAN) then
  673.                 massCount = massCount + 1
  674.             end
  675.         end
  676.         if (nucleusCount == 0) and (math.random(1, 2) == 1) then
  677.             sim.partProperty(i, "ctype", radAmoeba)
  678.         elseif (wallCount <= 3) and (massCount <= 9) then
  679.             sim.partProperty(i, "ctype", elements.DEFAULT_PT_INSL)
  680.         elseif (eaterCount <= 1) and (massCount >= 3) then
  681.             sim.partProperty(i, "ctype", radium)
  682.         else
  683.             sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
  684.         end
  685.     elseif (sim.partProperty(i, "ctype") == radAmoeba) then -- nucleus
  686.         if (sim.pressure(x / 4, y / 4) >= -2) then
  687.             sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) - 0.4)
  688.         end
  689.         sim.gravityMass(x / 4, y / 4, 0.1)
  690.         local wallCount = 0
  691.         local eaterCount = 0
  692.         local nucleusCount = 0
  693.         local xDist = 0
  694.         local yDist = 0
  695.         for part in sim.neighbors(x, y, 3, 3, radAmoeba) do
  696.             if (sim.partProperty(part, "x") > sim.partProperty(i, "x")) then
  697.                 xDist = xDist + 1
  698.             end
  699.             if (sim.partProperty(part, "x") < sim.partProperty(i, "x")) then
  700.                 xDist = xDist - 1
  701.             end
  702.             if (sim.partProperty(part, "y") > sim.partProperty(i, "y")) then
  703.                 yDist = yDist + 1
  704.             end
  705.             if (sim.partProperty(part, "y") < sim.partProperty(i, "y")) then
  706.                 yDist = yDist + 1
  707.             end
  708.             if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_INSL) then
  709.                 wallCount = wallCount + 1
  710.             elseif (sim.partProperty(part, "ctype") == radium) then
  711.                 eaterCount = eaterCount + 1
  712.             elseif (sim.partProperty(part, "ctype") == radAmoeba) then
  713.                 nucleusCount = nucleusCount + 1
  714.             end
  715.         end
  716.         if (nucleusCount >= 2) then
  717.             if (math.random(1, 4) == 1) then
  718.                 sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
  719.             elseif (math.random(1, 4) == 1) then
  720.                 sim.partProperty(i, "ctype", radium)
  721.             end
  722.         end
  723.         if (xDist >= 3) and (sim.partProperty(i, "vx") <= 3) then
  724.             sim.partProperty(i, "vx", sim.partProperty(i, "vx") + 1)
  725.         end
  726.         if (xDist <= -3) and (sim.partProperty(i, "vx") >= -3) then
  727.             sim.partProperty(i, "vx", sim.partProperty(i, "vx") - 1)
  728.         end
  729.         if (yDist >= 3) and (sim.partProperty(i, "vy") <= 3) then
  730.             sim.partProperty(i, "vy", sim.partProperty(i, "vy") + 1)
  731.         end
  732.         if (yDist <= -3) and (sim.partProperty(i, "vy") >= -3) then
  733.             sim.partProperty(i, "vy", sim.partProperty(i, "vy") - 1)
  734.         end
  735.     elseif (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_INSL) then -- wall
  736.         if (math.abs(sim.partProperty(i, "vx")) >= 1) then
  737.             sim.partProperty(i, "vx", sim.partProperty(i, "vx") * 0.8)
  738.         end
  739.         if (math.abs(sim.partProperty(i, "vy")) >= 1) then
  740.             sim.partProperty(i, "vy", sim.partProperty(i, "vy") * 0.8)
  741.         end
  742.  
  743.         local spaceCount = 0
  744.         local wallCount = 0
  745.         local otherCount = 0
  746.         for xOffset = -1, 1, 1 do
  747.             for yOffset = -1, 1, 1 do
  748.                 local currX = x + xOffset
  749.                 local currY = y + yOffset
  750.                 local currPart = sim.pmap(currX, currY)
  751.                 if (currPart == nil) then
  752.                     spaceCount = spaceCount + 1
  753.                 elseif (sim.partProperty(currPart, "type") ~= radAmoeba) then
  754.                     spaceCount = spaceCount + 1
  755.                 elseif (sim.partProperty(currPart, "ctype") == elements.DEFAULT_PT_INSL) then
  756.                     wallCount = wallCount + 1
  757.                 else
  758.                     otherCount = otherCount + 1
  759.                 end
  760.             end
  761.         end
  762.         if (wallCount >= 4) and (spaceCount <= 1) then
  763.             sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
  764.         elseif (spaceCount == 0) then
  765.             local wallTransfer = 1
  766.             local eaterCount = 0
  767.             for part in sim.neighbors(x, y, 1, 1, radAmoeba) do
  768.                 if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_URAN) then
  769.                     local spaceCount = 0
  770.                     for xOffset = -1, 1, 1 do
  771.                         for yOffset = -1, 1, 1 do
  772.                             local currX = sim.partProperty(part, "x") + xOffset
  773.                             local currY = sim.partProperty(part, "y") + yOffset
  774.                             local currPart = sim.pmap(currX, currY)
  775.                             if (currPart == nil) then
  776.                                 spaceCount = spaceCount + 1
  777.                             elseif (sim.partProperty(currPart, "ctype") == radium) then
  778.                                 eaterCount = eaterCount + 1
  779.                             end
  780.                         end
  781.                     end
  782.                     if (spaceCount >= 2) and (wallTransfer == 1) then
  783.                         sim.partProperty(part, "ctype", elements.DEFAULT_PT_INSL)
  784.                         wallTransfer = 0
  785.                     end
  786.                 end
  787.             end
  788.             if (eaterCount >= 3) then
  789.                 sim.partProperty(i, "ctype", elements.DEFAULT_PT_URAN)
  790.             else
  791.                 sim.partProperty(i, "ctype", radium)
  792.             end
  793.         elseif (spaceCount >= 4) and (math.random(1, 300) == 1) then
  794.             local newPart = sim.partCreate(-3, math.random(x - 1, x + 1), math.random(y - 1, y + 1), elements.DEFAULT_PT_NEUT)
  795.             if (newPart >= 0) then
  796.                 sim.partProperty(newPart, "temp", 10 + sim.partProperty(i, "temp"))
  797.             end
  798.             sim.pressure(x / 4, y / 4, sim.pressure(x / 4, y / 4) + 0.5)
  799.         end
  800.     elseif (sim.partProperty(i, "ctype") == radium) then -- eater
  801.         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
  802.             local metals = {elements.DEFAULT_PT_IRON, elements.DEFAULT_PT_METL, elements.DEFAULT_PT_BMTL, elements.DEFAULT_PT_BRMT, elements.DEFAULT_PT_SLCN,
  803.             elements.DEFAULT_PT_BREC, elements.DEFAULT_PT_URAN, elements.DEFAULT_PT_PLUT, elements.DEFAULT_PT_POLO, radium, actinium, curium}
  804.             for part in sim.neighbors(x, y, 1, 1) do
  805.                 local match = false
  806.                 for k, v in pairs(metals) do
  807.                     if (sim.partProperty(part, "type") == v) then
  808.                         match = true
  809.                     end
  810.                 end
  811.                 if not (match) then
  812.                     if (bit.band(elements.property(sim.partProperty(part, "type"), "Properties"), elements.TYPE_ENERGY) > 0) then -- check if particle is energy
  813.                         match = true
  814.                     end
  815.                 end
  816.                 if (match) then
  817.                     sim.partProperty(part, "ctype", 0)
  818.                     sim.partProperty(part, "type", radAmoeba)
  819.                 end
  820.             end
  821.         elseif (s >= 4) then
  822.             sim.partProperty(i, "ctype", elements.DEFAULT_PT_INSL)
  823.         end
  824.     elseif (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_URAN) then -- mass
  825.         if (s >= 3) then -- empty spaces nearby
  826.             sim.partProperty(i, "ctype", elements.DEFAULT_PT_INSL)
  827.         elseif (math.random(1, 120) == 1) then
  828.             sim.partProperty(i, "ctype", 0) -- auto-reassign if needed (e.g. regions with no nuclei)
  829.         end
  830.     end
  831.     local tempThreshold = 273 - 50 -- most particles will start to die at -50 C
  832.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_INSL) then
  833.         tempThreshold = 273 - 75 -- walls are more resilient and can handle down to -75 C
  834.     end
  835.     if (sim.partProperty(i, "temp") <= tempThreshold) then
  836.         if (sim.partProperty(i, "temp") <= 5) or (math.random(1, sim.partProperty(i, "temp")) == 1) then
  837.             if (math.random(1, 2) == 1) then
  838.                 sim.partProperty(i, "ctype", 0)
  839.                 sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 2)
  840.                 if (math.random(1, 2) == 1) then
  841.                     sim.partProperty(i, "type", elements.DEFAULT_PT_URAN)
  842.                 else
  843.                     sim.partProperty(i, "type", radon)
  844.                 end
  845.             else
  846.                 sim.partKill(i)
  847.             end
  848.             return -1
  849.         end
  850.     end
  851. end
  852.  
  853. local function radAmoebaGraphics(i, colr, colg, colb)
  854.     local rRed = colr
  855.     local rGreen = colg
  856.     local rBlue = colb
  857.     local rMode = ren.PMODE_FLAT
  858.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_URAN) then -- mass
  859.         rRed = rRed + math.random(1, 50)
  860.         rGreen = rGreen + math.random(1, 50)
  861.     elseif (sim.partProperty(i, "ctype") == radium) then -- eater
  862.         rMode = rMode + ren.PMODE_GLOW
  863.     elseif (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_INSL) then -- wall
  864.         rMode = rMode + ren.PMODE_BLUR
  865.         if (math.random(1, 4) == 1) then
  866.             rMode = rMode + ren.PMODE_GLOW
  867.         end
  868.         rRed = 150
  869.         rGreen = rGreen + 50
  870.         rBlue = 130
  871.     elseif (sim.partProperty(i, "ctype") == radAmoeba) then -- nucleus
  872.         rRed = rGreen + 20
  873.         rMode = rMode + ren.PMODE_GLOW
  874.     end
  875.    
  876.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  877. end
  878.  
  879. elements.property(radAmoeba, "Update", radAmoebaUpdate)
  880. elements.property(radAmoeba, "Graphics", radAmoebaGraphics)
  881.  
  882. local lead = elements.allocate("ARAD", "LEAD")
  883.  
  884. elements.element(lead, elements.element(elements.DEFAULT_PT_TTAN))
  885. elements.property(lead, "Name", "LEAD")
  886. elements.property(lead, "Description", "Lead. Absorbs radiation efficiently, but heats up in the process. Low melting point. Can also oxidize.")
  887. elements.property(lead, "Color", 0x6677cc)
  888. elements.property(lead, "MenuVisible", 1)
  889. elements.property(lead, "MenuSection", elements.SC_SOLIDS)
  890. elements.property(lead, "HighTemperature", 273 + 327) -- 327 C, the melting point of lead
  891. elements.property(lead, "HeatConduct", 200)
  892. elements.property(lead, "Properties", elements.TYPE_SOLID + elements.PROP_CONDUCTS + elements.PROP_LIFE_DEC + elements.PROP_NEUTPASS)
  893. elements.property(lead, "PhotonReflectWavelengths", 0x0)
  894.  
  895. local function leadUpdate(i, x, y, s, nt)
  896.     if (nt >= 2) then
  897.         local oxiFactor = 0
  898.         for part in sim.neighbors(x, y, 1, 1) do
  899.             local oxiPart = false
  900.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_O2) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_CO2) then
  901.                 oxiFactor = oxiFactor + 3
  902.                 oxiPart = true
  903.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_FOG) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_WTRV) then
  904.                 oxiFactor = oxiFactor + 2
  905.                 oxiPart = true
  906.             elseif (sim.partProperty(part, "type") == elements.DEFAULT_PT_BOYL) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_GAS) then
  907.                 oxiFactor = oxiFactor + 1
  908.                 oxiPart = true
  909.             end
  910.             if (sim.partProperty(i, "tmp") < 1) and (oxiFactor >= 3) and (math.random(1, 4) == 1) and (oxiPart) then
  911.                 sim.partProperty(i, "tmp", 1)
  912.                 sim.partProperty(part, "type", elements.DEFAULT_PT_EMBR)
  913.                 sim.partProperty(part, "life", math.random(90, 120))
  914.             end
  915.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(part, "type") == elements.DEFAULT_PT_NEUT) then
  916.                 sim.partProperty(i, "temp", sim.partProperty(i, "temp") + (sim.partProperty(part, "temp") / 5) - 5)
  917.                 sim.partKill(part)
  918.             end
  919.         end
  920.     else
  921.         local partHere = sim.photons(x, y)
  922.         if (partHere ~= nil) and (math.random(1, 2) == 1) then
  923.             if (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_PROT) or (sim.partProperty(partHere, "type") == elements.DEFAULT_PT_NEUT) then
  924.                 sim.partProperty(i, "temp", sim.partProperty(i, "temp") + (sim.partProperty(partHere, "temp") / 5) - 5)
  925.                 sim.partKill(partHere)
  926.             end
  927.         end
  928.         if (sim.partProperty(i, "life") == 1) then
  929.             sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 1)
  930.         end
  931.     end
  932. end
  933.  
  934. local function leadGraphics(i, colr, colg, colb)
  935.     local rRed = colr
  936.     local rGreen = colg
  937.     local rBlue = colb
  938.     local rMode = ren.PMODE_FLAT
  939.     if (sim.partProperty(i, "tmp") == 1) then
  940.         rRed = rRed / 2
  941.         rGreen = rGreen / 2
  942.         rBlue = (rBlue / 2) - 10
  943.     end
  944.     if (sim.partProperty(i, "temp") >= (273 + 227)) then
  945.         local tempDiff = sim.partProperty(i, "temp") - 273 - 227
  946.         rRed = rRed + tempDiff
  947.         rBlue = rBlue - tempDiff
  948.         if (rBlue < 10) then
  949.             rBlue = 10
  950.         end
  951.         if (tempDiff >= 50) and (math.random(1, 4) == 1) then
  952.             rMode = rMode + ren.FIRE_ADD
  953.             rBlue = (rBlue * 0.8)
  954.         end
  955.     end
  956.    
  957.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  958. end
  959.  
  960. elements.property(lead, "Update", leadUpdate)
  961. elements.property(lead, "Graphics", leadGraphics)
  962.  
  963. local chromium = elements.allocate("ARAD", "CHRM")
  964. local liquidChromium = elements.allocate("ARAD", "LCHR")
  965. local steel = elements.allocate("ARAD", "SSTL")
  966.  
  967. elements.element(chromium, elements.element(elements.DEFAULT_PT_TTAN))
  968. elements.property(chromium, "Name", "CHRM")
  969. elements.property(chromium, "Description", "Chromium. Shiny and conductive metal with a high melting point.")
  970. elements.property(chromium, "Color", 0xddddee)
  971. elements.property(chromium, "Hardness", 1)
  972. elements.property(chromium, "MenuVisible", 1)
  973. elements.property(chromium, "MenuSection", elements.SC_SOLIDS)
  974. elements.property(chromium, "Properties", elements.TYPE_SOLID + elements.PROP_CONDUCTS + elements.PROP_LIFE_DEC)
  975. elements.property(chromium, "HighTemperature", 1907 + 273)
  976. elements.property(chromium, "HighTemperatureTransition", liquidChromium)
  977.  
  978. local function chromiumGraphics(i, colr, colg, colb)
  979.     local rRed = colr
  980.     local rGreen = colg
  981.     local rBlue = colb
  982.     local rMode = ren.PMODE_FLAT
  983.  
  984.     local partTemp = sim.partProperty(i, "temp")
  985.     if (partTemp >= (1407 + 273)) then
  986.         local tempDiff = partTemp - 1407 - 273
  987.         rRed = rRed + (tempDiff / 20)
  988.         if (rRed > 250) then
  989.             rRed = 250
  990.         end
  991.         rGreen = rGreen - (tempDiff / 10)
  992.         if (rGreen < 150) then
  993.             rGreen = 150
  994.         end
  995.         rBlue = rBlue - (tempDiff / 4) - 5
  996.         if (rBlue < 100) then
  997.             rBlue = 100
  998.         end
  999.         if (math.random(1, 4) == 1) then
  1000.             rMode = rMode + ren.FIRE_ADD
  1001.         end
  1002.     end
  1003.     local partLife = sim.partProperty(i, "life")
  1004.     if (partLife >= 2) and (math.random(1, 6) <= partLife) then
  1005.         rGreen = rGreen + 10
  1006.         rBlue = rBlue + 10
  1007.         rMode = rMode + ren.PMODE_FLARE
  1008.     else
  1009.         rGreen = rGreen + math.random(1, 10)
  1010.         rBlue = rBlue + math.random(1, 10)
  1011.     end
  1012.    
  1013.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  1014. end
  1015.  
  1016. elements.property(chromium, "Graphics", chromiumGraphics)
  1017.  
  1018. elements.element(liquidChromium, elements.element(elements.DEFAULT_PT_GEL))
  1019. elements.property(liquidChromium, "Name", "LCHR")
  1020. elements.property(liquidChromium, "Description", "Liquid chromium. Very hot. Can be combined with molten METL or IRON to make stainless steel.")
  1021. elements.property(liquidChromium, "Color", 0xffcc66)
  1022. elements.property(liquidChromium, "MenuVisible", 1)
  1023. elements.property(liquidChromium, "MenuSection", elements.SC_LIQUID)
  1024. elements.property(liquidChromium, "Properties", elements.TYPE_LIQUID + elements.PROP_DEADLY + elements.PROP_LIFE_DEC)
  1025. elements.property(liquidChromium, "Temperature", 2100 + 273.15)
  1026. elements.property(liquidChromium, "LowTemperature", 1906 + 273)
  1027. elements.property(liquidChromium, "LowTemperatureTransition", chromium)
  1028.  
  1029. local function liquidChromiumUpdate(i, x, y, s, nt)
  1030.     if (nt >= 1) then
  1031.         for part in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_LAVA) do
  1032.             if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_IRON) or (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_METL) then
  1033.                 if (sim.partProperty(i, "ctype") ~= steel) then
  1034.                     sim.partProperty(i, "ctype", steel)
  1035.                     sim.partProperty(i, "life", 60)
  1036.                     sim.partKill(part)
  1037.                 end
  1038.             end
  1039.         end
  1040.     end
  1041.     if (sim.partProperty(i, "ctype") == steel) and (sim.partProperty(i, "life") == 0) then
  1042.         sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 5)
  1043.         sim.partProperty(i, "type", elements.DEFAULT_PT_LAVA)
  1044.  
  1045.         return -1
  1046.     end
  1047. end
  1048.  
  1049. local function liquidChromiumGraphics(i, colr, colg, colb)
  1050.     local rRed = colr
  1051.     local rGreen = colg
  1052.     local rBlue = colb
  1053.     local rMode = ren.PMODE_FLAT + ren.PMODE_BLUR
  1054.  
  1055.     if (math.random(1, 120) <= sim.partProperty(i, "life")) then
  1056.         rGreen = rGreen + 5
  1057.         rBlue = rBlue + 5
  1058.         rMode = rMode + ren.PMODE_LFLARE
  1059.     elseif (math.random(1, 4) == 1) then
  1060.         rGreen = rGreen + 6
  1061.         rBlue = rBlue + 12
  1062.         rMode = rMode + ren.FIRE_ADD
  1063.     end
  1064.    
  1065.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  1066. end
  1067.  
  1068. elements.property(liquidChromium, "Update", liquidChromiumUpdate)
  1069. elements.property(liquidChromium, "Graphics", liquidChromiumGraphics)
  1070.  
  1071. elements.element(steel, elements.element(elements.DEFAULT_PT_TTAN))
  1072. elements.property(steel, "Name", "SSTL")
  1073. elements.property(steel, "Description", "Stainless steel. Highly durable metal, can even defend against VIRS.")
  1074. elements.property(steel, "Color", 0xcccccc)
  1075. elements.property(steel, "Hardness", 0)
  1076. elements.property(steel, "MenuVisible", 1)
  1077. elements.property(steel, "MenuSection", elements.SC_SOLIDS)
  1078. elements.property(steel, "Properties", elements.TYPE_SOLID + elements.PROP_CONDUCTS + elements.PROP_LIFE_DEC + elements.PROP_HOT_GLOW + elements.PROP_SPARKSETTLE)
  1079. elements.property(steel, "HighTemperature", 1550 + 273)
  1080.  
  1081. local function steelUpdate(i, x, y, s, nt)
  1082.     if (nt >= 1) then
  1083.         for part in sim.neighbors(x, y, 1, 1) do
  1084.             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
  1085.                 sim.partProperty(part, "type", elements.DEFAULT_PT_EMBR)
  1086.                 sim.partProperty(part, "ctype", 0xee33ff)
  1087.                 sim.partProperty(part, "life", math.random(30, 120))
  1088.             end
  1089.         end
  1090.     end
  1091. end
  1092.  
  1093. elements.property(steel, "Update", steelUpdate)
  1094.  
  1095. local nanite = elements.allocate("ARAD", "NBOT")
  1096.  
  1097. elements.element(nanite, elements.element(elements.DEFAULT_PT_GEL))
  1098. elements.property(nanite, "Name", "NBOT")
  1099. elements.property(nanite, "Description", "Nanobots. Can alter their behavior. Spark with PSCN to harden, NSCN to liquefy, or CHRM to assimilate.")
  1100. elements.property(nanite, "Color", 0x9999aa)
  1101. elements.property(nanite, "Weight", 46)
  1102. elements.property(nanite, "Gravity", 0.15)
  1103. elements.property(nanite, "MenuVisible", 1)
  1104. elements.property(nanite, "MenuSection", elements.SC_POWERED)
  1105. elements.property(nanite, "Properties", elements.TYPE_LIQUID + elements.PROP_LIFE_DEC)
  1106.  
  1107. local function naniteUpdate(i, x, y, s, nt)
  1108.     if (sim.partProperty(i, "life") <= 0) then
  1109.         for part in sim.neighbors(x, y, 1, 1) do
  1110.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) and (sim.partProperty(part, "life") == 3) then
  1111.                 if (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_PSCN) then
  1112.                     sim.partProperty(i, "ctype", elements.DEFAULT_PT_PSCN)
  1113.                     sim.partProperty(i, "life", 12)
  1114.                 elseif (sim.partProperty(part, "ctype") == elements.DEFAULT_PT_NSCN) then
  1115.                     sim.partProperty(i, "ctype", elements.DEFAULT_PT_NSCN)
  1116.                     sim.partProperty(i, "life", 12)
  1117.                 elseif (sim.partProperty(part, "ctype") == chromium) then
  1118.                     sim.partProperty(i, "ctype", chromium)
  1119.                     sim.partProperty(i, "life", 12)
  1120.                 end
  1121.             elseif (sim.partProperty(part, "type") == nanite) and (sim.partProperty(part, "life") == 11)
  1122.             and (sim.partProperty(i, "ctype") ~= sim.partProperty(part, "ctype")) then
  1123.                 sim.partProperty(i, "ctype", sim.partProperty(part, "ctype"))
  1124.                 sim.partProperty(i, "life", 12)
  1125.             end
  1126.         end
  1127.     end
  1128.     if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PSCN) or (nt == 0) then
  1129.         sim.partProperty(i, "vx", 0)
  1130.         sim.partProperty(i, "vy", 0)
  1131.     elseif (sim.partProperty(i, "ctype") == chromium) and (sim.partProperty(i, "life") <= 4) and (math.random(1, 4) == 1) then
  1132.         sim.partProperty(i, "type", chromium)
  1133.     end
  1134.     if (sim.partProperty(i, "tmp") <= 0) then
  1135.         if (sim.partProperty(i, "ctype") == elements.DEFAULT_PT_PSCN) and (math.random(1, 240) == 1) then
  1136.             sim.partProperty(i, "tmp", math.random(60, 90))
  1137.         end
  1138.     else
  1139.         sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 1)
  1140.     end
  1141. end
  1142.  
  1143. local function naniteGraphics(i, colr, colg, colb)
  1144.     local rRed = colr
  1145.     local rGreen = colg
  1146.     local rBlue = colb
  1147.     local rMode = ren.PMODE_FLAT
  1148.  
  1149.     if (sim.partProperty(i, "life") >= 9) then
  1150.         rRed = rRed + (sim.partProperty(i, "life") * 2)
  1151.         rGreen = rGreen + (sim.partProperty(i, "life") * 2)
  1152.         rBlue = rBlue + (sim.partProperty(i, "life") * 3)
  1153.         if (math.random(1, 12) == 1) or (sim.partProperty(i, "life") == 12) then
  1154.             rMode = rMode + ren.PMODE_FLARE
  1155.         end
  1156.     elseif (sim.partProperty(i, "tmp") >= 1) then
  1157.         local lMod = sim.partProperty(i, "tmp")
  1158.         if (lMod >= 90) then
  1159.             lMod = 90
  1160.         end
  1161.         rRed = rRed + math.floor(lMod * 0.1) - 12
  1162.         rGreen = rGreen + math.floor(lMod * 0.6) - 10
  1163.         rBlue = rBlue + lMod - 8
  1164.     end
  1165.    
  1166.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  1167. end
  1168.  
  1169. elements.property(nanite, "Update", naniteUpdate)
  1170. elements.property(nanite, "Graphics", naniteGraphics)
  1171.  
  1172. local forceField1 = elements.allocate("ARAD", "FP32")
  1173.  
  1174. elements.element(forceField1, elements.element(elements.DEFAULT_PT_FRME))
  1175. elements.property(forceField1, "Name", "FP32")
  1176. elements.property(forceField1, "Description", "Force Field Projector P32. Requires continuous power. Produces a circular light shield.")
  1177. elements.property(forceField1, "Color", 0x00ee99)
  1178. elements.property(forceField1, "MenuVisible", 1)
  1179. elements.property(forceField1, "MenuSection", elements.SC_POWERED)
  1180. elements.property(forceField1, "Properties", elements.TYPE_SOLID + elements.PROP_LIFE_DEC)
  1181.  
  1182. local function ff1Update(i, x, y, s, nt)
  1183.     if (nt >= 1) then
  1184.         for part in sim.neighbors(x, y, 1, 1) do
  1185.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) and (sim.partProperty(part, "life") == 3) then
  1186.                 sim.partProperty(i, "life", 10)
  1187.             end
  1188.         end
  1189.     end
  1190.     if (sim.partProperty(i, "tmp") >= 360) then
  1191.         sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 358)
  1192.     else
  1193.         sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") + 2)
  1194.     end
  1195.     local lRads = sim.partProperty(i, "tmp") * (3.142 / 180)
  1196.     local xMod = math.floor(33 * math.sin(lRads))
  1197.     local yMod = math.floor(33 * math.cos(lRads)) * -1 -- positive Y is down in TPT, so this needs to be inverted
  1198.     local function shieldCreate(lp, nx, ny)
  1199.         if (sim.photons(nx, ny) ~= nil) then
  1200.             sim.partKill(sim.photons(nx, ny))
  1201.         end
  1202.         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
  1203.             sim.partKill(sim.pmap(nx, ny))
  1204.         end
  1205.         local newPart = sim.partCreate(-1, nx, ny, elements.DEFAULT_PT_BRAY)
  1206.         if (newPart >= 0) then
  1207.             sim.partProperty(newPart, "temp", sim.partProperty(lp, "temp") - 2)
  1208.             sim.partProperty(newPart, "life", 90)
  1209.             sim.partProperty(newPart, "ctype", 0xff80)
  1210.         end
  1211.     end
  1212.     if (sim.partProperty(i, "life") >= 1) then
  1213.         shieldCreate(i, x + xMod, y + yMod)
  1214.         shieldCreate(i, x - xMod, y - yMod)
  1215.         local xMod = math.floor(34 * math.sin(lRads))
  1216.         local yMod = math.floor(34 * math.cos(lRads)) * -1
  1217.         shieldCreate(i, x + xMod, y + yMod)
  1218.         shieldCreate(i, x - xMod, y - yMod)
  1219.     end
  1220. end
  1221.  
  1222. local function ff1Graphics(i, colr, colg, colb)
  1223.     local rRed = colr
  1224.     local rGreen = colg
  1225.     local rBlue = colb
  1226.     local rMode = ren.PMODE_FLAT
  1227.  
  1228.     if (sim.partProperty(i, "life") >= 1) and (sim.partProperty(i, "life") <= 11) then
  1229.         rRed = rRed + (sim.partProperty(i, "life") * 3)
  1230.         rBlue = rBlue + (sim.partProperty(i, "life") * 3)
  1231.         rMode = rMode + ren.PMODE_GLOW
  1232.     end
  1233.    
  1234.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  1235. end
  1236.  
  1237. elements.property(forceField1, "Update", ff1Update)
  1238. elements.property(forceField1, "Graphics", ff1Graphics)
  1239.  
  1240. local forceField2 = elements.allocate("ARAD", "FP96")
  1241.  
  1242. elements.element(forceField2, elements.element(elements.DEFAULT_PT_FRME))
  1243. elements.property(forceField2, "Name", "FP96")
  1244. elements.property(forceField2, "Description", "Force Field Projector P96. Requires continuous power. Produces a larger circular shield.")
  1245. elements.property(forceField2, "Color", 0x0099ee)
  1246. elements.property(forceField2, "MenuVisible", 1)
  1247. elements.property(forceField2, "MenuSection", elements.SC_POWERED)
  1248. elements.property(forceField2, "Properties", elements.TYPE_SOLID + elements.PROP_LIFE_DEC)
  1249.  
  1250. local function ff2Update(i, x, y, s, nt)
  1251.     if (nt >= 1) then
  1252.         for part in sim.neighbors(x, y, 1, 1) do
  1253.             if (sim.partProperty(part, "type") == elements.DEFAULT_PT_SPRK) and (sim.partProperty(part, "life") == 3) then
  1254.                 sim.partProperty(i, "life", 10)
  1255.             end
  1256.         end
  1257.     end
  1258.     if (sim.partProperty(i, "tmp") >= 360) then
  1259.         sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 359)
  1260.     else
  1261.         sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") + 1)
  1262.     end
  1263.     local lRads = sim.partProperty(i, "tmp") * (3.142 / 180)
  1264.     local xMod = math.floor(97 * math.sin(lRads))
  1265.     local yMod = math.floor(97 * math.cos(lRads)) * -1 -- positive Y is down in TPT, so this needs to be inverted
  1266.     local function shieldCreate(lp, nx, ny)
  1267.         if (sim.photons(nx, ny) ~= nil) then
  1268.             sim.partKill(sim.photons(nx, ny))
  1269.         end
  1270.         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
  1271.             sim.partKill(sim.pmap(nx, ny))
  1272.         end
  1273.         local newPart = sim.partCreate(-1, nx, ny, elements.DEFAULT_PT_BRAY)
  1274.         if (newPart >= 0) then
  1275.             sim.partProperty(newPart, "temp", sim.partProperty(lp, "temp") - 2)
  1276.             sim.partProperty(newPart, "life", 120)
  1277.             sim.partProperty(newPart, "ctype", 0x17ff)
  1278.         end
  1279.     end
  1280.     if (sim.partProperty(i, "life") >= 1) then
  1281.         for j = 97, 99 do
  1282.             for k = 0, 2 do
  1283.                 xMod = math.floor(j * math.sin(lRads + (k * 2.094)))
  1284.                 yMod = math.floor(j * math.cos(lRads + (k * 2.094))) * -1
  1285.                 -- 2.094 = 2(pi)/3; creates points that form an equilateral triangle, hopefully
  1286.                 shieldCreate(i, x + xMod, y + yMod)
  1287.             end
  1288.         end
  1289.     end
  1290. end
  1291.  
  1292. local function ff2Graphics(i, colr, colg, colb)
  1293.     local rRed = colr
  1294.     local rGreen = colg
  1295.     local rBlue = colb
  1296.     local rMode = ren.PMODE_FLAT
  1297.  
  1298.     if (sim.partProperty(i, "life") >= 1) and (sim.partProperty(i, "life") <= 11) then
  1299.         rRed = rRed + (sim.partProperty(i, "life") * 3)
  1300.         rGreen = rGreen + (sim.partProperty(i, "life") * 3)
  1301.         rMode = rMode + ren.PMODE_GLOW
  1302.     end
  1303.    
  1304.     return 0, rMode, 150, rRed, rGreen, rBlue, 50, rRed, rGreen, rBlue
  1305. end
  1306.  
  1307. elements.property(forceField2, "Update", ff2Update)
  1308. elements.property(forceField2, "Graphics", ff2Graphics)
Advertisement
Add Comment
Please, Sign In to add comment