Advertisement
Guest User

Untitled

a guest
Jul 15th, 2020
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. ecolors = {}
  2. ecolors[elem.DEFAULT_PT_PSNS] = 0x40000
  3. ecolors[elem.DEFAULT_PT_DTEC] = 0x40200
  4. ecolors[elem.DEFAULT_PT_LDTC] = 0x00200
  5. ecolors[elem.DEFAULT_PT_INVS] = 0x00201
  6. ecolors[elem.DEFAULT_PT_LSNS] = 0x00001
  7. ecolors[elem.DEFAULT_PT_TSNS] = 0x40001
  8. -- empty space is black
  9. -- anything else is white
  10.  
  11. -- Gather data
  12. local data, dp = {}, 1
  13. for i in sim.parts() do
  14.     if tpt.get_property("type", i) == elem.DEFAULT_PT_FRME then
  15.         local fx = tpt.get_property("x", i)
  16.         local fy = tpt.get_property("y", i)
  17.         local db = {}
  18.         for py = 1, 7 do
  19.             local value = 0x20000000
  20.             for px = 1, 9 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 = 0x40201
  27.                     end
  28.                 end
  29.                 value = bit.bor(value, bit.lshift(col, px - 1))
  30.             end
  31.             db[py] = 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 = 0
  46. while data[dp+1] do
  47.     dp = dp + 1
  48. end
  49. for i = dp, 1, -1 do
  50.     for j = 7, 1, -1 do
  51.         local id = tpt.create(200, 100, "PHOT")
  52.         tpt.set_property("ctype", data[i][j], id)
  53.         tpt.set_property("x", 100, id)
  54.     end
  55. end
  56. tpt.set_property("x", 100)
  57. tpt.set_property("vx", 0)
  58. tpt.set_property("vy", 0)
  59. tpt.set_property("life", 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement