Advertisement
TPT_PL

(Lua) Factory problems

Sep 10th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. local clog = elem.allocate("FACTORY", "CLOG")
  2. elem.element(clog, elem.element(elem.DEFAULT_PT_WOOD))
  3. elem.property(clog, "Name", "CLOG")
  4. elem.property(clog, "Description", "Pipe clog. Can be cleaned with SOAP; uncleaned turns into STNE and eventually tears the pipe apart.")
  5. elem.property(clog, "Color", 0x400000)
  6. elem.property(clog, "Properties", elem.PROP_LIFE_DEC)
  7.  
  8. local function clogUpdate(i, x, y, s, nt)
  9.     if sim.partProperty(i, "tmp2") == 0 then
  10.         sim.partProperty(i, "life", 201)
  11.         sim.partProperty(i, "tmp2", 1)
  12.     end;
  13.     if sim.partProperty(i, "life") == 1 then
  14.         if math.random(1, 25) == 1 then
  15.             sim.partKill(i)
  16.             sim.pressure(x/4, y/4, 6.00, 1, 1)
  17.         else
  18.             sim.partProperty(i, "type", elem.DEFAULT_PT_STNE)
  19.         end
  20.     end
  21.     r = sim.partID(x+math.random(-1, 1), y+math.random(-1, 1))
  22.     if r ~= nil then
  23.         if sim.partProperty(r, "type") == elem.DEFAULT_PT_SOAP or sim.partProperty(r, "type") == elem.DEFAULT_PT_DSTW then
  24.             sim.partKill(i)
  25.         end
  26.     end
  27. end
  28. elem.property(clog, "Update", clogUpdate)
  29.  
  30. local function oilUpdate(i, x, y, s, nt)
  31.     if math.random(1, 1000000000) == 1 then
  32.         sim.partProperty(i, "type", clog)
  33.     end
  34. end
  35. elem.property(elem.DEFAULT_PT_OIL, "Update", oilUpdate)
  36.  
  37. local function deslUpdate(i, x, y, s, nt)
  38.     if math.random(1, 2000000000) == 1 then
  39.         sim.partProperty(i, "type", clog)
  40.     end
  41. end
  42. elem.property(elem.DEFAULT_PT_DESL, "Update", deslUpdate)
  43.  
  44. elem.property(elem.DEFAULT_PT_BRCK, "HighPressure", 5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement