• GDCW Impact Error
    4 replies, posted
Hi. I asked permission for their code of some modified GDCW base stuff, and I ran into this error whenever a round impacts with grass. Every other material is fine. Excuse me if it's something simple, I'm a total noob to lua. [code] [ERROR] addons/laser weapons/lua/effects/lase_universal_impact/init.lua:46: attempt to index a nil value 1. unknown - addons/laser weapons/lua/effects/lase_universal_impact/init.lua:46 [/code] Here is the full lua file that it has a problem with. [code] //Sound,Impact // 1 2 3 4 5 //Dirt, Concrete, Metal, Glass, Flesh // 1 2 3 4 5 6 7 8 9 //Dust, Dirt, Sand, Metal, Smoke, Wood, Glass, Blood, YellowBlood local mats={ [MAT_ALIENFLESH] ={9}, [MAT_ANTLION] ={9}, [MAT_BLOODYFLESH] ={8}, [45] ={8}, // Metrocop heads are a source glitch, they have no enumeration [88] ={5}, // Map boundary glitch is now accounted for! [MAT_CLIP] ={5}, [MAT_COMPUTER] ={5}, [MAT_FLESH] ={8}, [MAT_GRATE] ={4}, [MAT_METAL] ={4}, [MAT_PLASTIC] ={5}, [MAT_SLOSH] ={5}, [MAT_VENT] ={4}, [MAT_FOLIAGE] ={5}, [MAT_TILE] ={5}, [MAT_CONCRETE] ={1}, [MAT_DIRT] ={2}, [MAT_SAND] ={3}, [MAT_WOOD] ={6}, [MAT_GLASS] ={7}, } function EFFECT:Init(data) self.Pos = data:GetOrigin() // Pos determines the global position of the effect // self.DirVec = data:GetNormal() // DirVec determines the direction of impact for the effect // self.PenVec = data:GetStart() // PenVec determines the direction of the round for penetrations // self.Scale = data:GetScale() // Scale determines how large the effect is // self.Radius = data:GetRadius() or 1 // Radius determines what type of effect to create, default is Concrete // self.Emitter = ParticleEmitter( self.Pos ) // Emitter must be there so you don't get an error // self.Mat=math.ceil(self.Radius) if mats[self.Mat][1]==1 then self:Dust() elseif mats[self.Mat][1]==2 then self:Dirt() elseif mats[self.Mat][1]==3 then self:Sand() elseif mats[self.Mat][1]==4 then self:Metal() elseif mats[self.Mat][1]==5 then self:Smoke() elseif mats[self.Mat][1]==6 then self:Wood() elseif mats[self.Mat][1]==7 then self:Glass() elseif mats[self.Mat][1]==8 then self:Blood() elseif mats[self.Mat][1]==9 then self:YellowBlood() else self:Smoke() end end function EFFECT:Dust() sound.Play( "Bullet.Concrete", self.Pos) self.Emitter = ParticleEmitter( self.Pos ) for i=0, 15*self.Scale do local Smoke = self.Emitter:Add( "particle/smokesprites_000"..math.random(1,9), self.Pos ) if (Smoke) then Smoke:SetVelocity( self.DirVec * math.random( 20,500*self.Scale) + VectorRand():GetNormalized()*100*self.Scale ) Smoke:SetDieTime( math.Rand( 1 , 3 )*self.Scale ) Smoke:SetStartAlpha( math.Rand( 80, 100 ) ) Smoke:SetEndAlpha( 0 ) Smoke:SetStartSize( 15*self.Scale ) Smoke:SetEndSize( 35*self.Scale ) Smoke:SetRoll( math.Rand(150, 360) ) Smoke:SetRollDelta( math.Rand(-2, 2) ) Smoke:SetAirResistance( 300 ) Smoke:SetGravity( Vector( math.Rand(-70, 70) * self.Scale, math.Rand(-70, 70) * self.Scale, math.Rand(0, -100) ) ) Smoke:SetColor( 0,148,255,255 ) end end for i=0, 10*self.Scale do local Smoke = self.Emitter:Add( "particle/particle_composite", self.Pos ) if (Smoke) then Smoke:SetVelocity( self.DirVec * math.random( 0,400*self.Scale) + VectorRand():GetNormalized()*5*self.Scale ) Smoke:SetDieTime( math.Rand( 0.5 , 1.5 )*self.Scale ) Smoke:SetStartAlpha( 150 ) Smoke:SetEndAlpha( 0 ) Smoke:SetStartSize( 20*self.Scale ) Smoke:SetEndSize( 35*self.Scale ) Smoke:SetRoll( math.Rand(150, 360) ) Smoke:SetRollDelta( math.Rand(-2, 2) ) Smoke:SetAirResistance( 400 ) Smoke:SetGravity( Vector( math.Rand(-50, 50) * self.Scale, math.Rand(-50, 50) * self.Scale, math.Rand(0, -100) ) ) Smoke:SetColor( 105,100,90 ) end end for i=0, 10*self.Scale do local Debris = self.Emitter:Add( "effects/fleck_cement"..math.random(1,2), self.Pos ) if (Debris) then Debris:SetVelocity ( self.DirVec * math.random(200,300*self.Scale) + VectorRand():GetNormalized() * 300*self.Scale ) Debris:SetDieTime( math.random( 0.6, 1) ) Debris:SetStartAlpha( 255 ) Debris:SetEndAlpha( 0 ) Debris:SetStartSize( math.random(2,5*self.Scale) ) Debris:SetRoll( math.Rand(0, 360) ) Debris:SetRollDelta( math.Rand(-5, 5) ) Debris:SetAirResistance( 50 ) Debris:SetColor( 105,100,90 ) Debris:SetGravity( Vector( 0, 0, -600) ) Debris:SetCollide( true ) Debris:SetBounce( 1 ) end end for i=0,1 do local Flash = self.Emitter:Add( "effects/muzzleflash"..math.random(1,4), self.Pos ) if (Flash) then Flash:SetVelocity( self.DirVec*100 ) Flash:SetAirResistance( 200 ) Flash:SetDieTime( 0.1 ) Flash:SetStartAlpha( 255 ) Flash:SetEndAlpha( 0 ) Flash:SetStartSize( math.Rand( 30, 40 )*self.Scale ) Flash:SetEndSize( 0 ) Flash:SetRoll( math.Rand(180,480) ) Flash:SetRollDelta( math.Rand(-1,1) ) Flash:SetColor(255,255,255) end end end function EFFECT:Dirt() sound.Play( "Bullet.Dirt", self.Pos) self.Emitter = ParticleEmitter( self.Pos ) for i=0, 15*self.Scale do local Smoke = self.Emitter:Add( "particle/smokesprites_000"..math.random(1,9), self.Pos ) if (Smoke) then Smoke:SetVelocity( self.DirVec * math.random( 20,500*self.Scale) + VectorRand():GetNormalized()*100*self.Scale ) Smoke:SetDieTime( math.Rand( 1 , 3 )*self.Scale ) Smoke:SetStartAlpha( math.Rand( 80, 100 ) ) Smoke:SetEndAlpha( 0 ) Smoke:SetStartSize( 15*self.Scale ) Smoke:SetEndSize( 35*self.Scale ) Smoke:SetRoll( math.Rand(150, 360) ) Smoke:SetRollDelta( math.Rand(-2, 2) ) Smoke:SetAirResistance( 300 ) Smoke:SetGravity( Vector( math.Rand(-70, 70) * self.Scale, math.Rand(-70, 70) * self.Scale, math.Rand(0, -100) ) ) Smoke:SetColor( 0,148,255,255 ) end end for i=0, 10*self.Scale do local Smoke = self.Emitter:Add( "particle/particle_composite", self.Pos ) if (Smoke) then Smoke:SetVelocity( self.DirVec * math.random( 0,400*self.Scale) + VectorRand():GetNormalized()*5*self.Scale ) Smoke:SetDieTime( math.Rand( 0.5 , 1.5 )*self.Scale ) Smoke:SetStartAlpha( 200 ) Smoke:SetEndAlpha( 0 ) Smoke:SetStartSize( 20*self.Scale ) Smoke:SetEndSize( 30*self.Scale ) Smoke:SetRoll( math.Rand(150, 360) ) Smoke:SetRollDelta( math.Rand(-2, 2) ) Smoke:SetAirResistance( 400 ) Smoke:SetGravity( Vector( math.Rand(-50, 50) * self.Scale, math.Rand(-50, 50) * self.Scale, math.Rand(0, -100) ) ) Smoke:SetColor( 90,83,68 ) end end for i=0, 15*self.Scale do local Debris = self.Emitter:Add( "effects/fleck_cement"..math.random(1,2), self.Pos ) if (Debris) then Debris:SetVelocity ( self.DirVec * math.random(200,300*self.Scale) + VectorRand():GetNormalized() * 300*self.Scale ) Debris:SetDieTime( math.random( 0.75, 1.25) ) Debris:SetStartAlpha( 255 ) Debris:SetEndAlpha( 0 ) Debris:SetStartSize( math.random(3,7*self.Scale) ) Debris:SetRoll( math.Rand(0, 360) ) Debris:SetRollDelta( math.Rand(-5, 5) ) Debris:SetAirResistance( 50 ) Debris:SetColor( 90,83,68 ) Debris:SetGravity( Vector( 0, 0, -600) ) Debris:SetCollide( true ) Debris:SetBounce( 1 ) end end for i=0,1 do local Flash = self.Emitter:Add( "effects/muzzleflash"..math.random(1,4), self.Pos ) if (Flash) then Flash:SetVelocity( self.DirVec*100 ) Flash:SetAirResistance( 200 ) Flash:SetDieTime( 0.1 ) Flash:SetStartAlpha( 255 ) Flash:SetEndAlpha( 0 ) Flash:SetStartSize( math.Rand( 10, 20 )*self.Scale ) Flash:SetEndSize( 0 ) Flash:SetRoll( math.Rand(180,480) ) Flash:SetRollDelta( math.Rand(-1,1) ) Flash:SetColor(255,255,255) end end end function EFFECT:Sand() sound.Play( "Bullet.Dirt", self.Pos) self.Emitter = ParticleEmitter( self.Pos ) for i=0, 15*self.Scale do loca
Can you add a print to what self.Mat is once you've set it?
What? Haha, I know no lua at all. The person that made the addon let me use his code.
Ask him?
Put print( self.Mat ) After self.Mat is declared
Sorry, you need to Log In to post a reply to this thread.