Advertisement
TPT_PL

Sulfurous Pack (Big Dig)

Oct 23rd, 2016
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.56 KB | None | 0 0
  1. local sulfur = elem.allocate("BIGDIG", "SULF")
  2. local so2 = elem.allocate("BIGDIG", "SO2")
  3. local sulfurous = elem.allocate("BIGDIG", "H2SO3")
  4. local sulfacid = elem.allocate("BIGDIG", "H2SO4")
  5.  
  6. elem.element(sulfur, elem.element(elem.DEFAULT_PT_SAND))
  7. elem.property(sulfur, "Name", "SULF")
  8. elem.property(sulfur, "Description", "Sulfur, heavy particles. Used in explosives, somewhat flammable in the basic form.")
  9. elem.property(sulfur, "Color", 0xCC9900)
  10. elem.property(sulfur, "Flammable", 10)
  11. elem.property(sulfur, "Hardness", 5)
  12. elem.property(sulfur, "Properties", elem.PROP_DEADLY)
  13. elem.property(sulfur, "HighTemperature", 273.15 + 118.9)
  14.  
  15. local function sulfUpdate(i, x, y, s, nt)
  16.     r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  17.     if r~= nil then
  18.         temp = sim.partProperty(i, "temp")
  19.         rtype = sim.partProperty(r, "type")
  20.         if rtype == elem.DEFAULT_PT_OXYG and temp >= 365.15 then
  21.             sim.partKill(i)
  22.             sim.partProperty(r, "type", so2)
  23.         elseif rtype == sulfacid and sim.partProperty(r, "tmp") == 1 then
  24.             sim.partKill(i)
  25.             sim.partProperty(r, "tmp", 0)
  26.         end
  27.     end
  28. end
  29.  
  30. elem.property(sulfur, "Update", sulfUpdate)
  31.  
  32. elem.element(so2, elem.element(elem.DEFAULT_PT_BOYL))
  33. elem.property(so2, "Name", "SO2")
  34. elem.property(so2, "Description", "Sulfur dioxide, toxic gas. Creates sulfurous acid with WTRV. Made from mixing hot sulphur and oxygen.")
  35. elem.property(so2, "Color", 0x996633)
  36. elem.property(so2, "Properties", elem.PROP_DEADLY+elem.TYPE_GAS)
  37. elem.property(so2, "Diffusion", 2)
  38.  
  39. local function so2Update(i, x, y, s, nt)
  40.     r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  41.     if r~= nil then
  42.         if sim.partProperty(r, "type") == elem.DEFAULT_PT_WTRV then
  43.             sim.partKill(r)
  44.             sim.partProperty(i, "type", sulfurous)
  45.         end
  46.     end
  47. end
  48.  
  49. elem.property(so2, "Update", so2Update)
  50.  
  51. elem.element(sulfurous, elem.element(elem.DEFAULT_PT_SOAP))
  52. elem.property(sulfurous, "Name", "SOCD")
  53. elem.property(sulfurous, "Description", "Sulfurous acid (H2SO3). Corrodes some metals, makes SACD with OXYG. Decaus at high temperatures.")
  54. elem.property(sulfurous, "Weight", 32)
  55. elem.property(sulfurous, "Color", 0x334D00)
  56. elem.property(sulfurous, "Properties", elem.PROP_DEADLY+elem.TYPE_LIQUID)
  57.  
  58. local function h2so3Update(i, x, y, s, nt)
  59.     r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  60.     if r ~= nil then
  61.         local rtype = sim.partProperty(r, "type")
  62.         if rtype == elem.DEFAULT_PT_METL or (rtype == elem.DEFAULT_PT_BMTL and sim.partProperty(r, "tmp") ~= 1) or rtype == elem.DEFAULT_PT_IRON or rtype == elem.DEFAULT_PT_TUNG then
  63.             sim.partChangeType(r, elem.DEFAULT_PT_BMTL)
  64.             sim.partProperty(r, "tmp", 1)
  65.             sim.partKill(i)
  66.             return 1
  67.         elseif rtype == elem.DEFAULT_PT_PLNT or rtype == elem.DEFAULT_PT_WOOD then
  68.             sim.partKill(r)
  69.             sim.partKill(i)
  70.             return 1
  71.         elseif rtype == elem.DEFAULT_PT_OXYG then
  72.             sim.partChangeType(i, sulfacid)
  73.             sim.partKill(r)
  74.         elseif elem.property(rtype, "Flammable") ~= 0 then
  75.             sim.partChangeType(r, elem.DEFAULT_PT_FIRE)
  76.             sim.partKill(i)
  77.             return 1
  78.         end
  79.     end
  80.     if sim.partProperty(i, "temp") > 573.15 then
  81.         sim.partChangeType(i, so2)
  82.         sim.partCreate(-3, x, y, elem.DEFAULT_PT_WTRV)
  83.     end
  84. end
  85.  
  86. elem.property(sulfurous, "Update", h2so3Update)
  87.  
  88. elem.element(sulfacid, elem.element(elem.DEFAULT_PT_SOAP))
  89. elem.property(sulfacid, "Name", "SACD")
  90. elem.property(sulfacid, "Description", "Sulfuric acid (H2SO4). Eats through most things, can be diluted with DSTW/WATR and concentrated with SULF.")
  91. elem.property(sulfacid, "Color", 0xCCCC00)
  92. elem.property(sulfacid, "Weight", 29)
  93.  
  94. local function h2so4Update(i, x, y, s, nt)
  95.     local tmp = sim.partProperty(i, "tmp")
  96.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  97.     if r ~= nil then
  98.         local rtype = sim.partProperty(r, "type")
  99.         if tmp ~= 1 then
  100.             if rtype == elem.DEFAULT_PT_DSTW then
  101.                 sim.partKill(r)
  102.                 sim.partProperty(i, "tmp", 1)
  103.             elseif rtype == elem.DEFAULT_PT_WATR then
  104.                 if math.random(1, 5) == 1 then
  105.                     sim.partProperty(i, "tmp", 1)
  106.                 end
  107.                 sim.partKill(r)
  108.             else
  109.                 if rtype ~= sulfacid and elem.property(rtype, "Hardness") > 0 and rtype ~= sulfurous then
  110.                     sim.partKill(r)
  111.                     if math.random(1, 10) == 1 then
  112.                         sim.partKill(i)
  113.                         return 1
  114.                     end
  115.                 end
  116.             end
  117.         else
  118.             if rtype == elem.DEFAULT_PT_BCOL then
  119.                 sim.partKill(i)
  120.                 sim.partProperty(r, "type", elem.DEFAULT_PT_BREL)
  121.             end
  122.         end
  123.     end
  124.     local r2 = sim.partID(x, y-1)
  125.     if r2 ~= nil then
  126.         if tmp ~= 1 and sim.partProperty(r2, "type") == sulfacid and sim.partProperty(r2, "tmp") == 1 then
  127.             sim.partProperty(i, "tmp", 1)
  128.             sim.partProperty(r2, "tmp", 0)
  129.         end
  130.     end
  131. end
  132.  
  133. local function h2so4Graphics(i, colr, colg, colb)
  134.     if sim.partProperty(i, "tmp") == 0 then
  135.         r = 204
  136.         g = 204
  137.         b = 0
  138.     else
  139.         r = 153
  140.         g = 255
  141.         b = 51
  142.     end;
  143.     return 0, 0x00000001, 255, r, g, b, 0, 0, 0, 0
  144. end
  145.  
  146. elem.property(sulfacid, "Update", h2so4Update)
  147. elem.property(sulfacid, "Graphics", h2so4Graphics)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement