Advertisement
Guest User

Untitled

a guest
Jul 13th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. -- Color table
  2. local ecolors = {}
  3. ecolors[elem.DEFAULT_PT_PSNS] = 0x200000 -- Red
  4. ecolors[elem.DEFAULT_PT_DTEC] = 0x201000 -- Yellow
  5. ecolors[elem.DEFAULT_PT_LDTC] = 0x001000 -- Green
  6. ecolors[elem.DEFAULT_PT_INVS] = 0x001001 -- Cyan
  7. ecolors[elem.DEFAULT_PT_LSNS] = 0x000001 -- Blue
  8. ecolors[elem.DEFAULT_PT_TSNS] = 0x200001 -- Magenta
  9. -- Anything not here is white
  10. -- Empty space is black
  11.  
  12. -- Gather data
  13. local data, dp = {}, 1
  14. for i in sim.parts() do
  15.     if tpt.get_property("type", i) == elem.DEFAULT_PT_FRME then
  16.         local db, fx = {}, tpt.get_property("x", i)
  17.         local fy = tpt.get_property("y", i)
  18.         for px = 1, 8 do
  19.             local value = 0x20000000
  20.             for py = 1, 6 do
  21.                 local col = tpt.get_property("type", fx + px, fy + py)
  22.                 if col ~= 0 then
  23.                     if ecolors[col] then
  24.                         col = ecolors[col]
  25.                     else
  26.                         col = 0x201001
  27.                     end
  28.                 end
  29.                 value = bit.bor(value, bit.lshift(col, py - 1))
  30.             end
  31.             db[px] = value
  32.         end
  33.         local tmp = tpt.get_property("tmp", i)
  34.         if tmp == 0 then tmp = 1 end
  35.         for i = 1, tmp do
  36.             data[dp] = db
  37.             dp = dp + 1
  38.         end
  39.     end
  40. end
  41.  
  42. -- Write data
  43. sim.clearSim()
  44. tpt.set_pause(1)
  45. dp = dp - 1
  46. for i = dp, 1, -1 do
  47.     for j = 8, 1, -1 do
  48.         local id = tpt.create(200, 100, "phot")
  49.         tpt.set_property("ctype", data[i][j], id)
  50.         tpt.set_property("x", 100, id)
  51.     end
  52. end
  53. tpt.set_property("x", 100)
  54. tpt.set_property("life", 0)
  55. tpt.set_property("vx", 0)
  56. tpt.set_property("vy", 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement