SHOW:
|
|
- or go back to the newest paste.
| 1 | - | br=0.5 |
| 1 | + | br=10 |
| 2 | delay=0.15 | |
| 3 | rand=true | |
| 4 | ptgOffset={}
| |
| 5 | ptgOffset[0]=1 | |
| 6 | ptgOffset[1]=2 | |
| 7 | ptgOffset[2]=3 | |
| 8 | ptgOffset[3]=4 | |
| 9 | args={...}
| |
| 10 | ||
| 11 | function loadFile(filename) | |
| 12 | fp=fs.open(filename,"r") | |
| 13 | lines={}
| |
| 14 | i=1 | |
| 15 | lines[i]=fp.readLine() | |
| 16 | while lines[i]~=nil do | |
| 17 | i=i+1 | |
| 18 | lines[i]=fp.readLine() | |
| 19 | end | |
| 20 | return lines | |
| 21 | end | |
| 22 | ||
| 23 | function split (inputstr, sep) | |
| 24 | if sep == nil then | |
| 25 | sep = "%s" | |
| 26 | end | |
| 27 | local t={}
| |
| 28 | for str in string.gmatch(inputstr, "([^"..sep.."]+)") do | |
| 29 | table.insert(t, str) | |
| 30 | end | |
| 31 | return t | |
| 32 | end | |
| 33 | ||
| 34 | function compileObj(lines) | |
| 35 | v = {}
| |
| 36 | vt = {}
| |
| 37 | vn = {}
| |
| 38 | f = {}
| |
| 39 | l = {}
| |
| 40 | print(#lines) | |
| 41 | for i=5, #lines do | |
| 42 | if string.sub(lines[i],1,2)=="v " then | |
| 43 | table.insert(v,split(lines[i])) | |
| 44 | end | |
| 45 | if string.sub(lines[i],1,2)=="vt" then | |
| 46 | table.insert(vt,split(lines[i])) | |
| 47 | end | |
| 48 | if string.sub(lines[i],1,2)=="vn" then | |
| 49 | table.insert(vn,split(lines[i])) | |
| 50 | end | |
| 51 | if string.sub(lines[i],1,2)=="f " then | |
| 52 | table.insert(f,split(lines[i])) | |
| 53 | end | |
| 54 | if string.sub(lines[i],1,2)=="l " then | |
| 55 | table.insert(l,split(lines[i])) | |
| 56 | end | |
| 57 | end | |
| 58 | end | |
| 59 | ||
| 60 | compileObj(loadFile(args[1])) | |
| 61 | ||
| 62 | function wrapPs(peripheralName) | |
| 63 | periTab = {}
| |
| 64 | sideTab = {}
| |
| 65 | if peripheralName == nil then | |
| 66 | print("Fehler")
| |
| 67 | end | |
| 68 | local peripherals = peripheral.getNames() | |
| 69 | local i2 = 1 | |
| 70 | for i = 1, #peripherals do | |
| 71 | if peripheral.getType(peripherals[i]) == peripheralName then | |
| 72 | periTab[i2] = peripheral.wrap(peripherals[i]) | |
| 73 | sideTab[i2] = peripherals[i] | |
| 74 | i2 = i2 + 1 | |
| 75 | end | |
| 76 | end | |
| 77 | if periTab ~= {} then
| |
| 78 | return periTab, sideTab | |
| 79 | else | |
| 80 | return nil | |
| 81 | end | |
| 82 | ||
| 83 | function getPSide(peripheralName) | |
| 84 | if peripheralName == nil then | |
| 85 | print("Fehler")
| |
| 86 | end | |
| 87 | local peripherals = peripheral.getNames() | |
| 88 | local i = 1 | |
| 89 | while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do | |
| 90 | i = i + 1 | |
| 91 | end | |
| 92 | if peripheral.getType(peripherals[i]) == peripheralName then | |
| 93 | return peripherals[i] | |
| 94 | else | |
| 95 | - | pgs=wrapPs("particle_generator")
|
| 95 | + | |
| 96 | end | |
| 97 | end | |
| 98 | end | |
| 99 | - | pgs[i].setGeneratorProperty("scale",2.6)
|
| 99 | + | |
| 100 | pgs,pgss=wrapPs("particle_generator")
| |
| 101 | ||
| 102 | for i=1,#pgs do | |
| 103 | - | pgs[i].setGeneratorProperty("selected_particle",2)
|
| 103 | + | |
| 104 | pgs[i].setGeneratorProperty("scale",0.5)
| |
| 105 | pgs[i].setGeneratorProperty("motion_y",0)
| |
| 106 | pgs[i].setGeneratorProperty("life",1000)
| |
| 107 | pgs[i].setGeneratorProperty("collide",true)
| |
| 108 | pgs[i].setGeneratorProperty("selected_particle",1)
| |
| 109 | - | for i=1,#v do |
| 109 | + | pgs[i].setGeneratorProperty("red",50)
|
| 110 | - | if pgn>#pgs then |
| 110 | + | pgs[i].setGeneratorProperty("green",255)
|
| 111 | - | pgn=1 |
| 111 | + | pgs[i].setGeneratorProperty("blue",200)
|
| 112 | - | end |
| 112 | + | |
| 113 | - | pgs[pgn].setGeneratorProperty("spawn_x",tonumber(v[i][2])*br)
|
| 113 | + | |
| 114 | - | pgs[pgn].setGeneratorProperty("spawn_y",tonumber(v[i][3])*br)
|
| 114 | + | |
| 115 | - | pgs[pgn].setGeneratorProperty("spawn_z",tonumber(v[i][4])*br)
|
| 115 | + | |
| 116 | - | pgn=pgn+1 |
| 116 | + | |
| 117 | if rand==false then | |
| 118 | for i=1,#v do | |
| 119 | if pgn>#pgs then | |
| 120 | pgn=1 | |
| 121 | end | |
| 122 | pgs[pgn].setGeneratorProperty("spawn_x",tonumber(v[i][2])*br)
| |
| 123 | pgs[pgn].setGeneratorProperty("spawn_y",tonumber(v[i][3])*br+ptgOffset[tonumber(string.sub(pgss[pgn],20))])
| |
| 124 | pgs[pgn].setGeneratorProperty("spawn_z",tonumber(v[i][4])*br)
| |
| 125 | pgn=pgn+1 | |
| 126 | sleep(delay) | |
| 127 | end | |
| 128 | else | |
| 129 | while true do | |
| 130 | i=math.random(1,#v) | |
| 131 | if pgn>#pgs then | |
| 132 | pgn=1 | |
| 133 | end | |
| 134 | pgs[pgn].setGeneratorProperty("spawn_x",tonumber(v[i][2])*br)
| |
| 135 | pgs[pgn].setGeneratorProperty("spawn_y",tonumber(v[i][3])*br+ptgOffset[tonumber(string.sub(pgss[pgn],20))])
| |
| 136 | pgs[pgn].setGeneratorProperty("spawn_z",tonumber(v[i][4])*br)
| |
| 137 | pgn=pgn+1 | |
| 138 | sleep(delay) | |
| 139 | end | |
| 140 | ||
| 141 | end | |
| 142 | ||
| 143 | ||
| 144 | for i=1,#pgs do | |
| 145 | pgs[i].setGeneratorProperty("motion_y",0)
| |
| 146 | pgs[i].setGeneratorProperty("life",0)
| |
| 147 | end |