ecco7777

CC Particle Generator Pixelart with Modems

Aug 9th, 2020 (edited)
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. br=0.5
  2. delay=0.15
  3. file="bild"
  4.  
  5. function wrapPs(peripheralName)
  6.     periTab = {}
  7.     sideTab = {}
  8.     if peripheralName == nil then
  9.         print("Fehler")
  10.     end
  11.     local peripherals = peripheral.getNames()
  12.     local i2 = 1
  13.     for i = 1, #peripherals do
  14.         if peripheral.getType(peripherals[i]) == peripheralName then
  15.             periTab[i2] = peripheral.wrap(peripherals[i])
  16.             sideTab[i2] = peripherals[i]
  17.             i2 = i2 + 1
  18.         end
  19.     end
  20.     if periTab ~= {} then
  21.         return periTab, sideTab
  22.     else
  23.         return nil
  24.     end
  25.  
  26.     function getPSide(peripheralName)
  27.         if peripheralName == nil then
  28.             print("Fehler")
  29.         end
  30.         local peripherals = peripheral.getNames()
  31.         local i = 1
  32.         while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do
  33.             i = i + 1
  34.         end
  35.         if peripheral.getType(peripherals[i]) == peripheralName then
  36.             return peripherals[i]
  37.         else
  38.             return nil
  39.         end
  40.     end
  41. end
  42.  
  43. pgs=wrapPs("particle_generator")
  44.  
  45. for i=1,#pgs do
  46.     pgs[i].setGeneratorProperty("spawn_y",30)
  47.     pgs[i].setGeneratorProperty("scale",2.6)
  48.     pgs[i].setGeneratorProperty("motion_y",-1)
  49.     pgs[i].setGeneratorProperty("life",1000)
  50.     pgs[i].setGeneratorProperty("collide",true)
  51.     pgs[i].setGeneratorProperty("selected_particle",2)
  52. end
  53.  
  54. color={}
  55. color[" "]={0x00,0x00,0xFF}
  56. color["0"]={0xF0,0xF0,0xF0}
  57. color["1"]={0xF2,0xB2,0x33}
  58. color["2"]={0xE5,0x7F,0xD8}
  59. color["3"]={0x99,0xB2,0xF2}
  60. color["4"]={0xDE,0xDE,0x6C}
  61. color["5"]={0x7F,0xCC,0x19}
  62. color["6"]={0xF2,0xB2,0xCC}
  63. color["7"]={0x4C,0x4C,0x4C}
  64. color["8"]={0x99,0x99,0x99}
  65. color["9"]={0x4C,0x99,0xB2}
  66. color["a"]={0xB2,0x66,0xE5}
  67. color["b"]={0x33,0x66,0xCC}
  68. color["c"]={0x7F,0x66,0x4C}
  69. color["d"]={0x57,0xA6,0x4E}
  70. color["e"]={0xCC,0x4C,0x4C}
  71. color["f"]={0x19,0x19,0x19}
  72.  
  73. fp=fs.open(file,"r")
  74. y=1
  75. line=1
  76. pgn=1
  77. while line~=nil do
  78. line=fp.readLine()
  79.     if line~=nil then
  80.         for i=1,#line do
  81.             if pgn>#pgs then
  82.             pgn=1
  83.             end
  84.             pgs[pgn].setGeneratorProperty("spawn_x",i*br)
  85.             pgs[pgn].setGeneratorProperty("spawn_z",y*br)
  86.             pgs[pgn].setGeneratorProperty("red",color[string.sub(line,i,i)][1])
  87.             pgs[pgn].setGeneratorProperty("green",color[string.sub(line,i,i)][2])
  88.             pgs[pgn].setGeneratorProperty("blue",color[string.sub(line,i,i)][3])
  89.             pgn=pgn+1
  90.         end
  91.         sleep(delay)
  92.        
  93.     end
  94. y=y+1
  95. end
  96.  
  97. for i=1,#pgs do
  98.     pgs[i].setGeneratorProperty("motion_y",0)
  99.     pgs[i].setGeneratorProperty("life",0)
  100. end
Add Comment
Please, Sign In to add comment