• LUA Question about CLUParticleEmitters
    4 replies, posted
Im learing LUA and the first little thing im trying to make is on TTT, it triggers a smoke explosion when you left click and hit somebody. It works but the smoke is really weak and looks very transparent. I have used the code from the TTT smoke grenade, can anyone help in making it darker or not see through or somehing ? [code] if CLIENT then print("lol2") local ply = LocalPlayer() local vector = ply:GetPos() local em = ParticleEmitter(vector) for i=1,20 do local r = math.random(10,30) local prpos = VectorRand() * r prpos.z = prpos.z + 32 local model = Model("particle/particle_noisesphere") local p = em:Add(model ,vector) if p then local gray = math.random(75, 200) p:SetColor(gray, gray, gray) p:SetStartAlpha(255) p:SetEndAlpha(255) p:SetVelocity(VectorRand() * math.Rand(900, 1300)) p:SetLifeTime(0) p:SetDieTime(math.Rand(50, 70)) p:SetStartSize(250) p:SetEndSize(math.random(1, 40)) p:SetRoll(math.random(-180, 180)) p:SetRollDelta(math.Rand(-0.1, 0.1)) p:SetAirResistance(600) p:SetCollide(true) p:SetBounce(0.4) p:SetLighting(false) end em:Finish() end end [/code] also this error is printed to the console when you try left click [quote] [ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_knife.lua:112: Tried to use invalid object (type CLuaEmitter) (Object was NULL or not of the right type) [/quote]
Check if your emitter is valid or not equal to nil
I put this in the code to check if it was nil [code] if em == nil then print("test") end [/code] It did not return test so it is not nil, I dont know how to check if its valid =/
[QUOTE=Batzz;47414087]I put this in the code to check if it was nil [code] if em == nil then print("test") end [/code] It did not return test so it is not nil, I dont know how to check if its valid =/[/QUOTE] [code] if IsValid(em) then [/code]
Thanks for the code extra [code] if IsValid(em) then print("IS VALID") end [/code] It did not print IS VALID so its obviously not valid
Sorry, you need to Log In to post a reply to this thread.