Hey all,
Ive got a problem with using Ent:Touch/Ent:StartTouch, It doesn't seem to give no error messages whatsoever and just does nothing.
Here is the code:
[lua]
function ENT:StartTouch( ent )
if ( ent:IsValid() and ent:GetClass() == "gunlab" ) then
ent:Remove()
end
end
[/lua]
If anyone knows where I am going wrong it will be much appreciated.
Does the SENT have proper physics?
Yes, Ive tried with other Sents aswell but with no luck
What does the rest of the file look like?
[lua]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
function ENT:Initialize()
self.Entity:SetModel( "models/props_outland/basementdoor01a.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )
self.Entity:SetUseType(SIMPLE_USE)
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:StartTouch( ent )
if ( ent:IsValid() and ent:GetClass() == "gunlab" ) then
ent:Remove()
end
end
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "storage_sent" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
[/lua]
Just a little update, I found that
[lua]
function ENT:StartTouch( ent )
ent:Remove()
end
[/lua]
Works but when I used the previous script it doesnt work.. Anyone got a idea?
It's not touching an entity of type "gunlab"
Basically as soon as I ent:GetClass() == "gunlab", it doesnt seem to pick it up.
Debug it:
[lua]
function ENT:StartTouch( ent )
print(ent:GetClass())
end
[/lua]
Post results.
[code]
gunlab
[/code]
Sorry, you need to Log In to post a reply to this thread.