Need help on fixing an error for a swep I am making
8 replies, posted
I need some help here as I am somewhat new to lua. I am making a scripted weapon that attaches a physics_cannister entity into an object using the manhack gun as a base, but I get this error when I spawn:
[CODE]ERROR: Trying to derive entity physics_cannister from non existant entity nil![/CODE]
Which means I can't spawn the cannister, and if I try to use the primary function, it gives me this error:
[CODE]ERROR: Trying to derive entity physics_cannister from non existant entity nil!
Error: Tried to make a SENT (physics_cannister) but the 'Type' (phys) was invalid!
[ERROR] lua/weapons/cannister_welder.lua:76: attempt to call method 'SetPos' (a nil value)
1. unknown - lua/weapons/cannister_welder.lua:76[/CODE]
Here's the mentioned line:
[CODE]ent:SetPos( tr.HitPos + self.Owner:GetAimVector() * 1 )[/CODE]
Thanks.
You code for physics_cannister is invalid.
[QUOTE=Robotboy655;45358443]You code for physics_cannister is invalid.[/QUOTE]
So how would I implement it the right way? Do I have to make a scripted entity based off physics_cannister?
Show the code how you spawn it.
[QUOTE=Robotboy655;45358508]Show the code how you spawn it.[/QUOTE]
Oh, here it is:
[CODE]local ent = ents.Create( "physics_cannister" )
local ent = ents.FindByModel( "models/props_c17/canister01a.mdl" )
ent:SetPos( tr.HitPos + self.Owner:GetAimVector() * 1 )
ent:SetAngles( tr.HitNormal:Angle() )
ent:Spawn()[/CODE]
Wtf is local ent = ents.FindByModel( "models/props_c17/canister01a.mdl" )
and why do you have it there?
[QUOTE=Robotboy655;45358563]Wtf is local ent = ents.FindByModel( "models/props_c17/canister01a.mdl" )
and why do you have it there?[/QUOTE]
I thought it would set the model for the physics_cannister entity, whoops.