Advertisement
TPT_PL

Nitric Pack (Big Dig Science)

Jan 8th, 2017
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.87 KB | None | 0 0
  1. local ntgn = elem.allocate("BIGDIG", "NTGN")
  2. local amon = elem.allocate("BIGDIG", "AMON")
  3. local amhd = elem.allocate("BIGDIG", "AMHD")
  4. local nhcl = elem.allocate("BIGDIG", "NHCL")
  5.  
  6. elem.element(ntgn, elem.element(elem.DEFAULT_PT_BOYL))
  7. elem.property(ntgn, "Name", "NTGN")
  8. elem.property(ntgn, "Description", "Nitrogen gas. Mostly inert, but in higher temperatures can make more complex elements. Vanishes after some time.")
  9. elem.property(ntgn, "Color", 0x80DFFF)
  10. elem.property(ntgn, "Diffusion", 5)
  11. elem.property(ntgn, "LowTemperature", 273.15 - 195.8)
  12. elem.property(ntgn, "LowTemperatureTransition", tpt.el.ln2.id)
  13. elem.property(tpt.el.ln2.id, "HighTemperature", 273.15 - 195.8)
  14. elem.property(tpt.el.ln2.id, "HighTemperatureTransition", ntgn)
  15.  
  16. local function nitrogen(i, x, y, s, nt)
  17.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  18.     if r ~= nil then
  19.         local rtype = sim.partProperty(r, "type")
  20.         if rtype == tpt.el.hygn.id and sim.partProperty(i, "temp") >= 273.15 + 89.50 then
  21.             sim.partChangeType(r, amon)
  22.             sim.partKill(i)
  23.             return 1
  24.         elseif rtype == tpt.el.ln2.id then
  25.             sim.partChangeType(i, tpt.el.ln2.id)
  26.         end
  27.     end
  28.     if math.random(1, 100) == 100 then
  29.         sim.partKill(i)
  30.         return 1
  31.     end
  32. end
  33.  
  34. elem.property(ntgn, "Update", nitrogen)
  35.  
  36. elem.element(amon, elem.element(tpt.el.hygn.id))
  37. elem.property(amon, "Name", "AMON")
  38. elem.property(amon, "Description", "Ammonia gas, helps plants grow. When solved in water makes a strong base.")
  39. elem.property(amon, "Color", 0x9fdf9f)
  40. elem.property(amon, "Diffusion", 0.75)
  41. elem.property(amon, "Gravity", 0.0001)
  42. elem.property(amon, "Flammable", 100)
  43. elem.property(amon, "Properties", elem.TYPE_GAS+elem.PROP_DEADLY)
  44.  
  45. local function ammonia(i, x, y, s, nt)
  46.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  47.     if r ~= nil then
  48.         local rtype = sim.partProperty(r, "type")
  49.         if (rtype == elem.DEFAULT_PT_WATR or rtype == elem.DEFAULT_PT_DSTW) and math.random(1, 10) == 10 then
  50.             sim.partChangeType(r, amhd)
  51.             sim.partKill(i)
  52.             return 1
  53.         elseif rtype == elem.DEFAULT_PT_PLNT and math.random(1, 10) == 10 then
  54.             sim.partChangeType(r, elem.DEFAULT_PT_VINE)
  55.             sim.partKill(i)
  56.             return 1
  57.         elseif rtype == elem.DEFAULT_PT_WOOD and math.random(1, 10) == 10 then
  58.             sim.partChangeType(i, elem.DEFAULT_PT_VINE)
  59.         end
  60.     end
  61.     if math.random(1, 1000) == 1000 then
  62.         sim.partKill(i)
  63.         return 1
  64.     end
  65. end
  66.  
  67. elem.property(amon, "Update", ammonia)
  68.  
  69. elem.element(amhd, elem.element(elem.DEFAULT_PT_WATR))
  70. elem.property(amhd, "Name", "AMHD")
  71. elem.property(amhd, "Description", "Ammonium hydrate, solution of ammonium in water.")
  72. elem.property(amhd, "Color", 0xd9f2d9)
  73. elem.property(amhd, "HighTemperature", ITH)
  74. elem.property(amhd, "HighTemperatureTransition", NT)
  75. elem.property(amhd, "Weight", 31)
  76.  
  77. local function ammoniumhydrate(i, x, y, s, nt)
  78.     local rx = math.random(x-1, x+1)
  79.     local ry = math.random(y-1, y+1)
  80.     local r = sim.partID(rx, ry)
  81.     if r ~= nil then
  82.         local rtype = sim.partProperty(r, "type")
  83.         if rtype == elem.DEFAULT_PT_ACID then
  84.             sim.partChangeType(i, nhcl)
  85.             sim.partChangeType(r, elem.DEFAULT_PT_WATR)
  86.         end
  87.     else
  88.         if math.random(1, 1000) == 1000 then
  89.             sim.partCreate(-1, rx, ry, amon)
  90.             if math.random(1, 20) == 20 then
  91.                 sim.partChangeType(i, elem.DEFAULT_PT_WATR)
  92.                 return 1
  93.             end
  94.         end
  95.     end
  96.     if sim.partProperty(i, "temp") > 373.15 then
  97.         if math.random(0, 1) == 1 then
  98.             sim.partChangeType(i, elem.DEFAULT_PT_WTRV)
  99.         else
  100.             sim.partChangeType(i, amon)
  101.         end
  102.     end
  103. end
  104.  
  105. elem.property(amhd, "Update", ammoniumhydrate)
  106.  
  107. elem.element(nhcl, elem.element(elem.DEFAULT_PT_SALT))
  108. elem.property(nhcl, "Name", "NHCL")
  109. elem.property(nhcl, "Description", "Ammonium chloride, cools down much in contact with water.")
  110. elem.property(nhcl, "Color", 0xe6ffff)
  111. elem.property(nhcl, "Meltable", 1)
  112. elem.property(nhcl, "HighTemperature", 273.15 + 520)
  113. elem.property(nhcl, "HighTemperatureTransition", elem.DEFAULT_PT_LAVA)
  114.  
  115. local function ammoniumchloride(i, x, y, s, nt)
  116.     local r = sim.partID(math.random(x-1, x+1), math.random(y-1, y+1))
  117.     if r ~= nil then
  118.         local rtype = sim.partProperty(r, "type")
  119.         if rtype == elem.DEFAULT_PT_WATR or rtype == elem.DEFAULT_PT_DSTW or rtype == elem.DEFAULT_PT_SLTW or rtype == elem.DEFAULT_PT_ICE or rtype == elem.DEFAULT_PT_SNOW then
  120.             if sim.partProperty(r, "temp") > 241.15 then
  121.                 sim.partProperty(r, "temp", sim.partProperty(r, "temp")-2)
  122.             end
  123.         end
  124.     end
  125. end
  126.  
  127. elem.property(nhcl, "Update", ammoniumchloride)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement