Hachem16

Sparkly *_*

Dec 28th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. mapInfo = {}
  2. sparkles = {}
  3. xml = [[]]
  4. function eventNewGame()
  5.     if tfm.get.room.xmlMapInfo then
  6.         mapInfo = tfm.get.room.xmlMapInfo
  7.         xml = mapInfo.xml
  8.         set_sparkles(xml)
  9.     end
  10. end
  11. function set_sparkles(xml)
  12.     sparkles = {}
  13.     local spk_str = xml:match("<O>(.-)</O>")
  14.     for line in spk_str:gmatch("<O(.-)/>") do
  15.         if line:match('SP="%d+"') then
  16.             -- I had to make it seperated because the order of these can be different
  17.             local x = line:match('X="(%d+)"')
  18.             local y = line:match('Y="(%d+)"')
  19.             local part = line:match('SP="(%d+)"')
  20.             local typ = line:match('TY="(.-)"')
  21.             local vel = line:match('VE="(%d+)"')
  22.             local num = line:match('N="(%d+)"')
  23.             sparkles[#sparkles+1] = {x=x, y=y, part=part, type=typ, num = num, vel=vel}
  24.         end
  25.     end
  26. end
  27.  
  28. function show_animation(x, y, part, typ, num, vel)
  29.     local x = tonumber(x) or 0
  30.     local y = tonumber(y) or 0
  31.     local num = tonumber(num) or 30
  32.     local part = tonumber(part) or 0
  33.     local vel = tonumber(vel) or 2
  34.     if typ == "circle" then
  35.         for l=1,num do
  36.             local ang = l*(360/num)
  37.             local x_vel = vel*math.cos(ang)
  38.             local y_vel = vel*math.sin(ang)
  39.             tfm.exec.displayParticle(part, x, y, x_vel, y_vel)
  40.         end
  41.     elseif typ == "square" then
  42.         for l = -vel, vel, vel/6 do
  43.             for o = -vel,vel, vel/6 do
  44.                 tfm.exec.displayParticle(part, x, y, l, o)
  45.             end
  46.         end
  47.     else
  48.         show_animation(x, y, part, "circle", nul, vel)
  49.     end
  50. end
  51.  
  52. function eventLoop(tp, tr)
  53.     for k,v in pairs(sparkles) do
  54.         show_animation(v.x, v.y, v.part, v.type, v.num, v.vel)
  55.     end
  56. end
  57. tfm.exec.newGame("@6431320")
Advertisement
Add Comment
Please, Sign In to add comment