Advertisement
TPT_PL

Chlorofluoric Pack (Big Dig)

Oct 29th, 2016
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.49 KB | None | 0 0
  1. local fluor = elem.allocate("BIGDIG", "FLUR")
  2. local chlor = elem.allocate("BIGDIG", "CHLR")
  3. local hifi = elem.allocate("BIGDIG", "HF")
  4. local clo2 = elem.allocate("BIGDIG", "CLO2")
  5. local clf3 = elem.allocate("BIGDIG", "CLF3")
  6. local perchloric = elem.allocate("BIGDIG", "HCLO4")
  7.  
  8. elem.element(fluor, elem.element(elem.DEFAULT_PT_CAUS))
  9. elem.property(fluor, "Name", "FLUR")
  10. elem.property(fluor, "Gravity", 0.5)
  11. elem.property(fluor, "Description", "Fluorine, heavy, corrosive gas. Reacts with some other gases.")
  12. elem.property(fluor, "Color", 0xFF6699)
  13. elem.property(fluor, "Properties", elem.TYPE_GAS+elem.PROP_DEADLY)
  14.  
  15. local function flurUpdate(i, x, y, s, nt)
  16.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  17.     if r ~= nil then
  18.         local rtype = sim.partProperty(r, "type")
  19.         if rtype == elem.DEFAULT_PT_H2 then
  20.             sim.partChangeType(i, hifi)
  21.             sim.partChangeType(r, hifi)
  22.         elseif rtype ~= chlor and elem.property(rtype, "Hardness") > 0 then
  23.             if math.random(1, 5) == 1 then
  24.                 sim.partKill(r)
  25.                 if math.random(1, 10) == 1 then
  26.                     sim.partKill(i)
  27.                     return 1
  28.                 end
  29.             end
  30.         end
  31.     end
  32. end
  33.  
  34. elem.property(fluor, "Update", flurUpdate)
  35.  
  36.  
  37. elem.element(hifi, elem.element(elem.DEFAULT_PT_CAUS))
  38. elem.property(hifi, "Name", "HGFL")
  39. elem.property(hifi, "Description", "Hydrogen fluoride, can eat through even glass.")
  40. elem.property(hifi, "Color", 0xCC99FF)
  41. elem.property(hifi, "Properties", elem.TYPE_GAS+elem.PROP_DEADLY)
  42.  
  43. local function hgflUpdate(i, x, y, s, nt)
  44.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  45.     if r ~= nil then
  46.         local rtype = sim.partProperty(r, "type")
  47.         if rtype ~= hifi and rtype ~= elem.DEFAULT_PT_DMND then
  48.             local chance
  49.             if elem.property(rtype, "Hardness") <= 10 then
  50.                 chance = 50
  51.             else
  52.                 chance = 5
  53.             end;
  54.             if math.random(1, chance) == 1 then
  55.                 sim.partKill(r)
  56.                 if math.random(1, 10) == 1 then
  57.                     sim.partKill(i)
  58.                     return 1
  59.                 end
  60.             end
  61.         end
  62.     end
  63. end
  64.  
  65. elem.property(hifi, "Update", hgflUpdate)
  66.  
  67. elem.element(chlor, elem.element(elem.DEFAULT_PT_CAUS))
  68. elem.property(chlor, "Name", "CHLR")
  69. elem.property(chlor, "Description", "Chlorine, corrosive but less than FLUR. Toxic, spreads quickly and may rust some metals.")
  70. elem.property(chlor, "Color", 0xCCFF99)
  71. elem.property(chlor, "Diffusion", 5)
  72. elem.property(chlor, "Properties", elem.TYPE_GAS+elem.PROP_DEADLY)
  73.  
  74. local function chlrUpdate(i, x, y, s, nt)
  75.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  76.     if r ~= nil then
  77.         local rtype = sim.partProperty(r, "type")
  78.         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_PSCN or rtype == elem.DEFAULT_PT_NSCN or rtype == elem.DEFAULT_PT_TTAN then
  79.             if math.random(1, 10) == 1 then
  80.                 sim.partChangeType(r, elem.DEFAULT_PT_BMTL)
  81.                 sim.partProperty(r, "tmp", 1)
  82.             end
  83.         elseif rtype == fluor and sim.pressure(x/4, y/4) >= 10 then
  84.             sim.partChangeType(r, clf3)
  85.             sim.partKill(i)
  86.             return 1
  87.         elseif rtype == elem.DEFAULT_PT_O2 and sim.pressure(x/4, y/4) >= 5 then
  88.             sim.partChangeType(r, clo2)
  89.             sim.partKill(i)
  90.             return 1
  91.         elseif rtype ~= chlor and elem.property(rtype, "Hardness") > 0 then
  92.             if math.random(1, 10) == 1 then
  93.                 sim.partKill(r)
  94.                 if math.random(1, 10) == 1 then
  95.                     sim.partKill(i)
  96.                     return 1
  97.                 end
  98.             end
  99.         end
  100.     end
  101. end
  102.  
  103. elem.property(chlor, "Update", chlrUpdate)
  104.  
  105. elem.element(clf3, elem.element(elem.DEFAULT_PT_CAUS))
  106. elem.property(clf3, "Name", "CLF3")
  107. elem.property(clf3, "Description", "Chlorine trifluoride, almighty gas of death, reacts explosively with almost everything.")
  108. elem.property(clf3, "Color", 0xFFCC99)
  109. elem.property(clf3, "Gravity", 0.25)
  110. elem.property(clf3, "Diffusion", 3)
  111. elem.property(clf3, "Properties", elem.TYPE_GAS+elem.PROP_DEADLY)
  112.  
  113. local function clf3Update(i, x, y, s, nt)
  114.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  115.     if r ~= nil then
  116.         local rtype = sim.partProperty(r, "type")
  117.         if rtype ~= clf3 and rtype ~= chlor and rtype ~= fluor and rtype ~= elem.DEFAULT_PT_DMND and rtype ~= elem.DEFAULT_PT_CLNE and rtype ~= elem.DEFAULT_PT_PCLN and rtype ~= elem.DEFAULT_PT_VOID then
  118.             sim.partChangeType(i, elem.DEFAULT_PT_FIRE)
  119.             sim.partChangeType(r, elem.DEFAULT_PT_FIRE)
  120.             sim.partProperty(i, "temp", 5273.15)
  121.             sim.partProperty(r, "temp", 5273.15)
  122.             sim.pressure(x/4, y/4, 5)
  123.         end
  124.     end
  125. end
  126.  
  127. elem.property(clf3, "Update", clf3Update)
  128.  
  129. elem.element(clo2, elem.element(elem.DEFAULT_PT_CAUS))
  130. elem.property(clo2, "Name", "CLO2")
  131. elem.property(clo2, "Description", "Chlorine dioxide, destroys metals and living things, used to make perchloric acid.")
  132. elem.property(clo2, "Properties", elem.TYPE_GAS+elem.PROP_DEADLY)
  133. elem.property(clo2, "Gravity", -0.1)
  134. elem.property(clo2, "Diffusion", 5)
  135. elem.property(clo2, "Color", 0xDDFFCC)
  136.  
  137. local function clo2update(i, x, y, s, nt)
  138.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  139.     if r ~= nil then
  140.         local rtype = sim.partProperty(r, "type")
  141.         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_PSCN or rtype == elem.DEFAULT_PT_NSCN or rtype == elem.DEFAULT_PT_TTAN or rtype == elem.DEFAULT_PT_RBDM then
  142.             if math.random(1, 10) == 1 then
  143.                 sim.partChangeType(r, elem.DEFAULT_PT_BMTL)
  144.                 sim.partProperty(r, "tmp", 1)
  145.             end
  146.         elseif rtype == elem.DEFAULT_PT_PLNT or rtype == elem.DEFAULT_PT_WOOD or rtype == elem.DEFAULT_PT_VINE then
  147.             sim.partKill(r)
  148.         elseif rtype == elem.DEFAULT_PT_WTRV and sim.pressure(x/4, y/4) >= 5 then
  149.             sim.partChangeType(i, perchloric)
  150.             sim.partKill(r)
  151.             return 1
  152.         end
  153.     end
  154. end
  155.  
  156. elem.property(clo2, "Update", clo2Update)
  157.  
  158. elem.element(perchloric, elem.element(elem.DEFAULT_PT_ACID))
  159. elem.property(perchloric, "Name", "PACD")
  160. elem.property(perchloric, "Description", "Perchloric acid, toxic, explosive liquid. Reacts with flammable materials.")
  161. elem.property(perchloric, "Color", 0xE6FFE6)
  162. elem.property(perchloric, "Diffusion", 0.25)
  163. elem.property(perchloric, "Flammable", 2000)
  164. elem.property(perchloric, "Explosive", 1)
  165.  
  166. local function pacdUpdate(i, x, y, s, nt)
  167.     local r = sim.partID(x+math.random(-1,1),y+math.random(-1,1))
  168.     if r ~= nil then
  169.         local rtype = sim.partProperty(r, "type")
  170.         if elem.property(rtype, "Flammable") > 100 and rtype ~= perchloric then
  171.             sim.partChangeType(r, elem.DEFAULT_PT_FIRE)
  172.             if elem.property(rtype, "Explosive") == 2 then
  173.                 sim.pressure(x/4, y/4, 3)
  174.             end
  175.         elseif rtype == elem.DEFAULT_PT_PLNT or rtype == elem.DEFAULT_PT_WOOD or rtype == elem.DEFAULT_PT_VINE then
  176.             sim.partKill(r)
  177.         end
  178.     end
  179. end
  180.  
  181. elem.property(perchloric, "Update", pacdUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement