Advertisement
BombBloke

Particle Emitter (RandomPeripherals)

Aug 11th, 2015
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. local partMax, delay = 8, 0.1
  2. local block = {"minecraft:wool", "minecraft:stained_glass", "minecraft:stained_glass_pane", "minecraft:stained_hardened_clay"}
  3. local holo = {peripheral.find("hologram_projector")}
  4.  
  5. do
  6.     local interfaces = {peripheral.find("universalInterface")}
  7.     for i = 1, #interfaces do for _, side in pairs(rs.getSides()) do
  8.         local thisPer = interfaces[i].wrapPeripheral(side)
  9.         if thisPer.setVelocity then holo[#holo + 1] = thisPer end
  10.     end end
  11. end
  12.  
  13. if #holo == 0 then error("No projectors found.") end
  14.  
  15. local particles = {}
  16. for i = 1, #holo do
  17.     holo[i].clear("minecraft:air", 0)
  18.     holo[i].setVelocity(1)
  19.    
  20.     particles[i] = {}
  21.     for j = 1, partMax do particles[i][j] = {3.5, 0, 3.5, math.random() - 0.5, math.random(), math.random() - 0.5, block[math.random(#block)], math.random(16) - 1} end
  22. end
  23.  
  24. while true do
  25.     for i = 1, #holo do
  26.         local thesePars = particles[i]
  27.         local holoMap, marked = {}, {}
  28.         for j = 1, #thesePars do
  29.             local thisPar = thesePars[j]
  30.             local PosMark = thisPar[1] .. thisPar[2] .. thisPar[3]
  31.            
  32.             if not marked[PosMark] then
  33.                 holoMap[#holoMap + 1] = {["x"] = thisPar[1], ["y"] = thisPar[2], ["z"] = thisPar[3], ["name"] = "minecraft:air"}
  34.                 marked[PosMark] = true
  35.             end
  36.            
  37.             thisPar[1] = thisPar[1] + thisPar[4]
  38.             thisPar[2] = thisPar[2] + thisPar[5]
  39.             thisPar[3] = thisPar[3] + thisPar[6]
  40.            
  41.             if thisPar[1] < 0 or thisPar[1] >= 8 or thisPar[2] >= 8 or thisPar[3] < 0 or thisPar[3] >= 8 then
  42.                  thisPar = {3.5, 0, 3.5, math.random() - 0.5, math.random(), math.random() - 0.5, block[math.random(#block)], math.random(16) - 1}
  43.                  particles[i][j] = thisPar
  44.             end
  45.            
  46.             holoMap[#holoMap + 1] = {["x"] = thisPar[1], ["y"] = thisPar[2], ["z"] = thisPar[3], ["name"] = thisPar[7], ["meta"] = thisPar[8]}
  47.             marked[thisPar[1] .. thisPar[2] .. thisPar[3]] = true
  48.         end
  49.        
  50.         holo[i].draw(holoMap)
  51.     end
  52.    
  53.     sleep(delay)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement