Advertisement
Scien_tific

FDST element

Jul 11th, 2019
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local id = elem.allocate("FDST","S_TMOD")
  2.  
  3. local function update_fdst(i,x,y)
  4.     for n in sim.neighbours(x,y,1,1) do
  5.         if sim.partProperty(n,sim.FIELD_TYPE) ~= id then
  6.             if math.random(0,999) == 0 then
  7.                 sim.partChangeType(i,elem.DEFAULT_PT_DUST)
  8.             end
  9.            
  10.             break
  11.         end
  12.     end
  13. end
  14.  
  15. local function update_dust(i,x,y)
  16.     if sim.pressure(math.floor(x / 4),math.floor(y / 4)) <= -5 then
  17.         sim.partChangeType(i,id)
  18.     end
  19.    
  20.     if sim.partProperty(i,sim.FIELD_VX) >= 4 or sim.partProperty(i,sim.FIELD_VY) >= 4 or sim.partProperty(i,sim.FIELD_VX) <= -4 or sim.partProperty(i,sim.FIELD_VY) <= -4 then
  21.         sim.partChangeType(i,id)
  22.     end
  23. end
  24.  
  25. elem.property(id,"Enabled",1)
  26. elem.property(id,"Name","FDST")
  27. elem.property(id,"Colour",elem.property(elem.DEFAULT_PT_DUST,"Colour"))
  28. elem.property(id,"MenuVisible",1)
  29. elem.property(id,"MenuSection",elem.SC_GAS)
  30. elem.property(id,"Advection",1)
  31. elem.property(id,"AirDrag",0)
  32. elem.property(id,"AirLoss",1)
  33. elem.property(id,"Loss",0.2)
  34. elem.property(id,"Collision",-0.1)
  35. elem.property(id,"Gravity",0.1)
  36. elem.property(id,"Diffusion",1)
  37. elem.property(id,"HotAir",0)
  38. elem.property(id,"Falldown",0)
  39. elem.property(id,"Flammable",10)
  40. elem.property(id,"Explosive",0)
  41. elem.property(id,"Meltable",0)
  42. elem.property(id,"Hardness",10)
  43. elem.property(id,"Weight",1)
  44. elem.property(id,"Temperature",273.15 + sim.R_TEMP)
  45. elem.property(id,"HeatConduct",50)
  46. elem.property(id,"Description","Fine dust. Condenses into dust when pressurized or on contact with other elements.")
  47. elem.property(id,"State",elem.ST_GAS)
  48. elem.property(id,"HighPressure",5)
  49. elem.property(id,"HighPressureTransition",elem.DEFAULT_PT_DUST)
  50. elem.property(id,"Properties",elem.TYPE_GAS)
  51. elem.property(id,"Update",update_fdst)
  52.  
  53. elem.property(elem.DEFAULT_PT_DUST,"Update",update_dust)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement