ent.touch

How can i tell my Entity that if a “other_ent” touches it, then to do something?

[lua]
function ENT:Touch()
local thingies = 0
local Thing = ents.GetByClass(“ent_thing”)
if thing Touches
then Thing:Remove
local thingies = thingies + 1
end
if thingies == 3 then
ent.Create(“new_ent_thing”)
local thingies = 0
end

end
[/lua]

Hopefully this pseudo-code will help you in my intentions

“if a thing touches my ent, get rid of that thing and set thingies to what it was, but with +1 thingies. and if there happens to be three thingies, make a new thingie, then set thingies back to 0”

How the hell do i do this?

[lua]
local thingies = 0 – Start count at zero
function ENT:Touch( hitEnt )
if (hitEnt:GetClass() == ‘ent_thing’) then – If the thing we want to touch it touches it
hitEnt:Remove() – Remove it
thingies = thingies +1 – Increment counter
if (thingies == 3) then – Hit target count
thingies = 0 – Reset counter
local newEnt = ents.Create(‘ent_new_thing’) – Create new thing
end
end
end
[/lua]