Advertisement
TPT_PL

Civilization

Jan 8th, 2017
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.67 KB | None | 0 0
  1. function cross(x, y)
  2.     local l = {sim.partID(x+1, y), sim.partID(x-1, y), sim.partID(x, y+1), sim.partID(x, y-1)}
  3.     return l
  4. end
  5.  
  6. local function woody(i, x, y, s, nt)
  7.     for r=0,3 do
  8.         if cross(x, y)[r] ~= nil and sim.partProperty(cross(x, y)[r], "type") == tpt.el.plnt.id then
  9.             if math.random(1, 100) == 100 then
  10.                 sim.partChangeType(cross(x, y)[r], tpt.el.wood.id);
  11.                 sim.partChangeType(i, tpt.el.spng.id)
  12.             end
  13.         end
  14.     end
  15.     if math.random(1, 1000) == 1 then
  16.         local bc = 0
  17.         for b in sim.neighbors(x, y, 1, 1) do
  18.             if sim.partProperty(b, "type") == tpt.el.spng.id or sim.partProperty(b, "type") == tpt.el.wood.id or sim.partProperty(b, "type") == tpt.el.filt.id then
  19.                 bc = bc + 1
  20.             end
  21.         end
  22.         if bc == 8 then
  23.             sim.partChangeType(i, tpt.el.iron.id)
  24.         end
  25.     end
  26. end
  27.  
  28. tpt.element_func(woody, tpt.el.wood.id)
  29.  
  30. local function spongy(i, x, y, s, nt)
  31.     for r=0,3 do
  32.         if cross(x, y)[r] ~= nil and sim.partProperty(cross(x, y)[r], "type") == tpt.el.plnt.id then
  33.             if math.random(1, 100) == 100 then
  34.                 sim.partChangeType(cross(x, y)[r], tpt.el.wood.id);
  35.             end
  36.         end
  37.     end
  38. end
  39.  
  40. tpt.element_func(spongy, tpt.el.spng.id)
  41.  
  42. local function irony(i, x, y, s, nt)
  43.     for r=0,3 do
  44.         if cross(x, y)[r] ~= nil then
  45.             if sim.partProperty(cross(x, y)[r], "type") == tpt.el.spng.id then
  46.                 if math.random(1, 100) == 100 then
  47.                     sim.partChangeType(cross(x, y)[r], tpt.el.iron.id);
  48.                     sim.partChangeType(i, tpt.el.spng.id)
  49.                 end
  50.             elseif sim.partProperty(cross(x, y)[r], "type") == tpt.el.iron.id and math.random(1, 10) == 10 then
  51.                 sim.partChangeType(cross(x, y)[r], tpt.el.spng.id);
  52.                 sim.partChangeType(i, tpt.el.wax.id)
  53.             end
  54.         end
  55.     end
  56. end
  57.  
  58. tpt.element_func(irony, tpt.el.iron.id)
  59.  
  60. local function waxy(i, x, y, s, nt)
  61.     for r=0,3 do
  62.         if cross(x, y)[r] ~= nil then
  63.             if math.random(1, 10) == 10 then
  64.                 if sim.partProperty(cross(x, y)[r], "type") == tpt.el.wood.id and sim.partProperty(i, "ctype") == 0 then
  65.                     sim.partChangeType(cross(x, y)[r], tpt.el.iron.id);
  66.                     sim.partChangeType(i, tpt.el.iron.id)
  67.                     return 1
  68.                end
  69.             end
  70.             if math.random(1, 100) == 100 then
  71.                 if sim.partProperty(cross(x, y)[r], "type") == tpt.el.spng.id and sim.partProperty(i, "ctype") == 0 then
  72.                     sim.partChangeType(cross(x, y)[r], tpt.el.wax.id);
  73.                     sim.partChangeType(i, tpt.el.spng.id)
  74.                 elseif sim.partProperty(cross(x, y)[r], "type") == tpt.el.filt.id and sim.partProperty(i, "ctype") == 0 then
  75.                     sim.partChangeType(cross(x, y)[r], tpt.el.wax.id);
  76.                     if sim.partProperty(i, "ctype") == 0 then
  77.                         sim.partChangeType(i, tpt.el.filt.id)
  78.                     else
  79.                         sim.partChangeType(i, tpt.el.spng.id)
  80.                     end
  81.                     sim.partProperty(i, "ctype", tpt.el.filt.id)
  82.                 elseif sim.partProperty(cross(x, y)[r], "type") == tpt.el.plnt.id and sim.partProperty(i, "ctype") == tpt.el.filt.id then
  83.                     sim.partChangeType(cross(x, y)[r], tpt.el.wood.id);
  84.                     sim.partChangeType(i, tpt.el.filt.id)
  85.                     sim.partProperty(i, "ctype", 0)
  86.                 end
  87.             end
  88.         end
  89.     end
  90. end
  91.  
  92. tpt.element_func(waxy, tpt.el.wax.id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement