Advertisement
TPT_PL

TPT_PL's Mod

Nov 13th, 2016
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.35 KB | None | 0 0
  1. local magn = elem.allocate("TPTPL", "MAGN")
  2. local mgnp = elem.allocate("TPTPL", "MGNP")
  3. local mgno = elem.allocate("TPTPL", "MGNO")
  4.  
  5. -- Magnesium oxide
  6. elem.element(mgno, elem.element(elem.DEFAULT_PT_BREC))
  7. elem.property(mgno, "Name", "MGNO")
  8. elem.property(mgno, "Description", "Magnesium oxide, oxidized MAGN/MGNP. Neutralyzes ACID.")
  9. elem.property(mgno, "Color", 0x5C5C3D)
  10.  
  11. local function magnoxide(i, x, y, s, nt)
  12.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  13.     if r ~= nil then
  14.         local rtype = sim.partProperty(r, "type")
  15.         if rtype == elem.DEFAULT_PT_ACID then
  16.             sim.partChangeType(r, elem.DEFAULT_PT_DSTW)
  17.             sim.partChangeType(i, elem.DEFAULT_PT_SALT)
  18.         elseif rtype == elem.DEFAULT_PT_H2 and sim.pressure(x/4, y/4) >= 2.00 then
  19.             sim.partChangeType(r, elem.DEFAULT_PT_DSTW)
  20.             sim.partChangeType(i, mgnp)
  21.         end
  22.     end
  23. end
  24.  
  25. elem.property(mgno, "Update", magnoxide)
  26.  
  27. -- Magnesium
  28. elem.element(magn, elem.element(elem.DEFAULT_PT_SPNG))
  29. elem.property(magn, "Name", "MAGN")
  30. elem.property(magn, "Description", "Magnesium, hard to ignite, burns long with a very hot flame.")
  31. elem.property(magn, "Color", 0xB8B894)
  32. elem.property(magn, "Flammable", 0)
  33. elem.property(magn, "HighPressure", 5)
  34.  
  35. local function magnesium(i, x, y, s, nt)
  36.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  37.     if r ~= nil then
  38.         local rtype = sim.partProperty(r, "type")
  39.         if sim.partProperty(i, "tmp") == 0 then
  40.             if sim.partProperty(r, "temp") >= 1773.15 then
  41.                 sim.partProperty(i, "tmp", 1)
  42.                 sim.partProperty(i, "life", 150)
  43.             elseif rtype == elem.DEFAULT_PT_ACID then
  44.                 sim.partChangeType(r, elem.DEFAULT_PT_H2)
  45.                 sim.partChangeType(i, elem.DEFAULT_PT_SALT)
  46.             end
  47.         else
  48.             if (rtype == elem.DEFAULT_PT_WATR or rtype == elem.DEFAULT_PT_WTRV or rtype == elem.DEFAULT_PT_DSTW) and sim.partProperty(i, "tmp") == 1 then
  49.                 sim.partChangeType(r, elem.DEFAULT_PT_HYGN)
  50.                 sim.partChangeType(i, mgno)
  51.             elseif rtype == elem.DEFAULT_PT_O2 and sim.partProperty(i, "tmp") == 1 then
  52.                 sim.partChangeType(i, mgno)
  53.             elseif rtype == elem.DEFAULT_PT_CO2 and sim.partProperty(i, "tmp") == 1 then
  54.                 sim.partChangeType(r, elem.DEFAULT_PT_BCOL)
  55.                 sim.partChangeType(i, mgno)
  56.             end
  57.         end
  58.     end
  59.     if sim.partProperty(i, "tmp") == 1 then
  60.         if sim.partProperty(i, "life") ~= 1 and sim.partProperty(i, "life") > 0 then
  61.             local p1 = sim.partCreate(-1, x, y+1, elem.DEFAULT_PT_FIRE)
  62.             if p1 >= 0 then
  63.                 sim.partProperty(p1, "temp", 3775.15)
  64.             end
  65.             local p2 = sim.partCreate(-1, x+1, y, elem.DEFAULT_PT_FIRE)
  66.             if p2 >= 0 then
  67.                 sim.partProperty(p2, "temp", 3775.15)
  68.             end
  69.             local p3 = sim.partCreate(-1, x, y-1, elem.DEFAULT_PT_FIRE)
  70.             if p3 >= 0 then
  71.                 sim.partProperty(p3, "temp", 3775.15)
  72.             end
  73.             local p4 = sim.partCreate(-1, x-1, y, elem.DEFAULT_PT_FIRE)
  74.             if p4 >= 0 then
  75.                 sim.partProperty(p4, "temp", 3775.15)
  76.             end
  77.             sim.partProperty(i, "life", sim.partProperty(i, "life")-1)
  78.         else
  79.             sim.partKill(i)
  80.         end
  81.     end
  82. end
  83.  
  84. elem.property(magn, "Update", magnesium)
  85.  
  86. -- Magnesium powder
  87. elem.element(mgnp, elem.element(elem.DEFAULT_PT_DUST))
  88. elem.property(mgnp, "Name", "MGNP")
  89. elem.property(mgnp, "Description", "Magnesium powder, a lot easier to ignite than MAGN and also burns hotter.")
  90. elem.property(mgnp, "Color", 0xE0E0D1)
  91. elem.property(mgnp, "Flammable", 0)
  92. elem.property(magn, "HighPressureTransition", mgnp)
  93.  
  94. local function mgpowder(i, x, y, s, nt)
  95.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  96.     if r ~= nil then
  97.         local rtype = sim.partProperty(r, "type")
  98.         if sim.partProperty(i, "tmp") == 0 then
  99.             if sim.partProperty(r, "temp") >= 693.15 then
  100.                 sim.partProperty(i, "tmp", 1)
  101.                 sim.partProperty(i, "life", 100)
  102.             elseif rtype == elem.DEFAULT_PT_ACID then
  103.                 sim.partChangeType(r, elem.DEFAULT_PT_H2)
  104.                 sim.partChangeType(i, elem.DEFAULT_PT_SALT)
  105.             end
  106.         else
  107.             if (rtype == elem.DEFAULT_PT_WATR or rtype == elem.DEFAULT_PT_WTRV or rtype == elem.DEFAULT_PT_DSTW) and sim.partProperty(i, "tmp") == 1 then
  108.                 sim.partChangeType(r, elem.DEFAULT_PT_HYGN)
  109.                 sim.partChangeType(i, mgno)
  110.             elseif rtype == elem.DEFAULT_PT_O2 and sim.partProperty(i, "tmp") == 1 then
  111.                 sim.partChangeType(i, mgno)
  112.             elseif rtype == elem.DEFAULT_PT_CO2 and sim.partProperty(i, "tmp") == 1 then
  113.                 sim.partChangeType(r, elem.DEFAULT_PT_BCOL)
  114.                 sim.partChangeType(i, mgno)
  115.             end
  116.         end
  117.     end
  118.     if sim.partProperty(i, "tmp") == 1 then
  119.         if sim.partProperty(i, "life") ~= 1 and sim.partProperty(i, "life") > 0 then
  120.             local p1 = sim.partCreate(-1, x, y+1, elem.DEFAULT_PT_FIRE)
  121.             if p1 >= 0 then
  122.                 sim.partProperty(p1, "temp", 4775.15)
  123.             end
  124.             local p2 = sim.partCreate(-1, x+1, y, elem.DEFAULT_PT_FIRE)
  125.             if p2 >= 0 then
  126.                 sim.partProperty(p2, "temp", 4775.15)
  127.             end
  128.             local p3 = sim.partCreate(-1, x, y-1, elem.DEFAULT_PT_FIRE)
  129.             if p3 >= 0 then
  130.                 sim.partProperty(p3, "temp", 4775.15)
  131.             end
  132.             local p4 = sim.partCreate(-1, x-1, y, elem.DEFAULT_PT_FIRE)
  133.             if p4 >= 0 then
  134.                 sim.partProperty(p4, "temp", 4775.15)
  135.             end
  136.             sim.partProperty(i, "life", sim.partProperty(i, "life")-1)
  137.         else
  138.             sim.partKill(i)
  139.         end
  140.     end
  141. end
  142.  
  143. elem.property(mgnp, "Update", mgpowder)
  144.  
  145. -- Iridium
  146. local irdm = elem.allocate("TPTPL", "IRDM")
  147. elem.element(irdm, elem.element(elem.DEFAULT_PT_GOLD))
  148. elem.property(irdm, "Name", "IRDM")
  149. elem.property(irdm, "Description", "Iridium, corroded by OXYG only. Creates FIRE when spark passes through.")
  150. elem.property(irdm, "Color", 0xAFCBCF)
  151. elem.property(irdm, "HighTemperature", 2447 + 273.15)
  152.  
  153. local function iridium(i, x, y, s, nt)
  154.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  155.     if r ~= nil then
  156.         local rtype = sim.partProperty(r, "type")
  157.         if rtype == elem.DEFAULT_PT_O2 and math.random(1, 1000) == 1 then
  158.             sim.partKill(i);
  159.             return 1
  160.         end
  161.     end
  162.     if sim.partProperty(i, "life") == 4 then
  163.         local fire = sim.partCreate(-1, math.random(x-1, x+1), math.random(y-1, y+1), elem.DEFAULT_PT_FIRE)
  164.         if fire > -1 then
  165.             sim.partProperty(fire, "temp", sim.partProperty(i, "temp"))
  166.         end
  167.     end
  168. end
  169.  
  170. elem.property(irdm, "Update", iridium)
  171.  
  172. -- Radon
  173. local radn = elem.allocate("TPTPL", "RADN")
  174. elem.element(radn, elem.element(elem.DEFAULT_PT_NBLE))
  175. elem.property(radn, "Name", "RADN")
  176. elem.property(radn, "Description", "Radon, radioactive noble gas. Glows, emits NEUT and decays into NBLE when sparked.")
  177. elem.property(radn, "Color", 0x006622)
  178. elem.property(radn, "MenuSection", elem.SC_NUCLEAR)
  179. elem.property(radn, "Properties", elem.TYPE_GAS+elem.PROP_RADIOACTIVE+elem.PROP_CONDUCTS+elem.PROP_LIFE_DEC)
  180.  
  181. local function radon(i, x, y, s, nt)
  182.     if sim.partProperty(i, "life") == 4 then
  183.         local decay = math.random(1, 10)
  184.         if decay == 1 then
  185.             sim.partKill(i);
  186.             sim.partCreate(-3, x, y, elem.DEFAULT_PT_NEUT);
  187.             return 1
  188.         elseif decay > 1 and decay <= 4 then
  189.             sim.partProperty(i, "type", elem.DEFAULT_PT_NBLE)
  190.         end
  191.     end
  192. end
  193.  
  194. local function radonGlow(i, r, g, b)
  195.     if sim.partProperty(i, "life") == 0 then
  196.         return 0, 0x00020000, 255, r, g, b, 20, r, g, b
  197.     else
  198.         return 0, 0x00000041, 255, r, g, b, 20, r, g, b
  199.     end
  200. end
  201.  
  202. elem.property(radn, "Update", radon)
  203. elem.property(radn, "Graphics", radonGlow)
  204.  
  205. -- Francium
  206. local fran = elem.allocate("TPTPL", "FRAN")
  207. elem.element(fran, elem.element(elem.DEFAULT_PT_BREL))
  208. elem.property(fran, "Name", "FRAN")
  209. elem.property(fran, "Description", "Francium, decays in just seconds. Don't allow it to contact with water.")
  210. elem.property(fran, "Color", 0xE6F2FF)
  211. elem.property(fran, "MenuSection", elem.SC_NUCLEAR)
  212. elem.property(fran, "Properties", elem.TYPE_SOLID+elem.PROP_RADIOACTIVE)
  213.  
  214. local function francium(i, x, y, s, nt)
  215.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  216.     if r ~= nil then
  217.         local rtype = sim.partProperty(r, "type")
  218.         if rtype == elem.DEFAULT_PT_WATR or rtype == elem.DEFAULT_PT_DSTW or rtype == elem.DEFAULT_PT_SLTW or rtype == elem.DEFAULT_PT_CBNW or rtype == elem.DEFAULT_PT_WTRV or rtype == elem.DEFAULT_PT_ICE or rtype == elem.DEFAULT_PT_SNOW then
  219.             sim.partProperty(r, "temp", 1273.15)
  220.             local react = math.random(1, 5)
  221.             if react == 1 then
  222.                 sim.partKill(i);
  223.                 sim.partCreate(-3, x, y, elem.DEFAULT_PT_NEUT);
  224.                 return 1
  225.             elseif react == 2 then
  226.                 sim.partKill(i);
  227.                 sim.partCreate(-3, x, y, elem.DEFAULT_PT_PROT);
  228.                 return 1
  229.             elseif react == 3 then
  230.                 sim.partKill(i);
  231.                 sim.partCreate(-3, x, y, elem.DEFAULT_PT_ELEC);
  232.                 return 1
  233.             elseif react == 4 then
  234.                 sim.partChangeType(i, elem.DEFAULT_PT_H2);
  235.             else
  236.                 sim.partChangeType(i, radn);
  237.             end;
  238.             sim.partProperty(i, "temp", 1273.15)
  239.             sim.pressure(x/4, y/4, 50)
  240.         end
  241.     end
  242.     if math.random(1, 100) == 1 then
  243.         local react = math.random(1, 5)
  244.         if react == 1 then
  245.             sim.partKill(i);
  246.             sim.partCreate(-3, x, y, elem.DEFAULT_PT_NEUT);
  247.             return 1
  248.         elseif react == 2 then
  249.             sim.partKill(i);
  250.             sim.partCreate(-3, x, y, elem.DEFAULT_PT_PROT);
  251.             return 1
  252.         elseif react == 3 then
  253.             sim.partKill(i);
  254.             sim.partCreate(-3, x, y, elem.DEFAULT_PT_PHOT);
  255.             return 1
  256.         elseif react == 4 then
  257.             sim.partChangeType(i, elem.DEFAULT_PT_H2);
  258.         else
  259.             sim.partChangeType(i, radn);
  260.         end;
  261.     end
  262. end
  263.  
  264. elem.property(fran, "Update", francium)
  265.  
  266. -- Tritium oxide
  267. local trit = elem.allocate("TPT_PL", "TRIT")
  268. elem.element(trit, elem.element(elem.DEFAULT_PT_DEUT))
  269. elem.property(trit, "Name", "3H2O")
  270. elem.property(trit, "Description", "Tritium oxide, water with radioactive hydrogen isotope.")
  271. elem.property(trit, "Weight", 40)
  272.  
  273. local function tritium(i, x, y, s, nt)
  274.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  275.     if r ~= nil then
  276.         local rtype = sim.partProperty(r, "type")
  277.         if rtype == elem.DEFAULT_PT_NEUT then
  278.             sim.pressure(x/4, y/4, sim.pressure(x/4, y/4)+math.random(100, 200))
  279.             sim.partProperty(i, "temp", sim.partProperty(i, "temp")+math.random(7273.15, 8273.15))
  280.             if math.random(1, 3) == 1 then
  281.                 for i=1,math.random(5, 10) do
  282.                     sim.partCreate(-3, x, y, elem.DEFAULT_PT_PROT)
  283.                 end
  284.             end
  285.             if math.random(1, 1000) == 1 then
  286.                 sim.partChangeType(i, elem.DEFAULT_PT_EQVE)
  287.             end
  288.         elseif rtype == elem.DEFAULT_PT_PROT then
  289.             sim.pressure(x/4, y/4, sim.pressure(x/4, y/4)-math.random(100, 200))
  290.             sim.partProperty(i, "temp", sim.partProperty(i, "temp")+math.random(7273.15, 8273.15))
  291.             if math.random(1, 3) == 1 then
  292.                 for i=1,math.random(5, 10) do
  293.                     sim.partCreate(-3, x, y, elem.DEFAULT_PT_ELEC)
  294.                 end
  295.             end
  296.             if math.random(1, 1000) == 1 then
  297.                 sim.partChangeType(i, elem.DEFAULT_PT_EQVE)
  298.             end
  299.         elseif rtype == elem.DEFAULT_PT_ELEC then
  300.             sim.pressure(x/4, y/4, sim.pressure(x/4, y/4)+math.random(100, 200))
  301.             sim.partProperty(i, "temp", sim.partProperty(i, "temp")+math.random(7273.15, 8273.15))
  302.             if math.random(1, 3) == 1 then
  303.                 for i=1,math.random(5, 10) do
  304.                     sim.partCreate(-3, x, y, elem.DEFAULT_PT_PHOT)
  305.                 end
  306.             end
  307.             if math.random(1, 1000) == 1 then
  308.                 sim.partChangeType(i, elem.DEFAULT_PT_EQVE)
  309.             end
  310.         elseif rtype == elem.DEFAULT_PT_PHOT then
  311.             sim.pressure(x/4, y/4, sim.pressure(x/4, y/4)-math.random(100, 200))
  312.             sim.partProperty(i, "temp", sim.partProperty(i, "temp")+math.random(7273.15, 8273.15))
  313.             if math.random(1, 3) == 1 then
  314.                 for i=1,math.random(5, 10) do
  315.                     sim.partCreate(-3, x, y, elem.DEFAULT_PT_NEUT)
  316.                 end
  317.             end
  318.             if math.random(1, 1000) == 1 then
  319.                 sim.partChangeType(i, elem.DEFAULT_PT_EQVE)
  320.             end
  321.         end
  322.     end
  323. end
  324.  
  325. elem.property(trit, "Update", tritium)
  326.  
  327. sim.can_move(elem.DEFAULT_PT_ELEC, trit, 2)
  328. sim.can_move(elem.DEFAULT_PT_PHOT, trit, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement