• Touching ents
    10 replies, posted
Ok, here i go again. How would one use ENT:Touch to have an entity remove itsself along with another touching entity specifically defined, etc: When ball touches ent:ball2 both are removed and ent:ball3 is created.
[lua] function ENT:Touch //code where it touches something.. self.remove ent.Create("ent_ball3") [/lua] Something like that I'd guess. I can't test it right now, sorry.
I'm fine with that part, i know the functions etc, i just don't know how to define what entity it needs to be touching for ent.Create to activate
Oh, try something like //blahlala code for creating function //creating ent IF ent_ball1 collides with ent_ball2 then self.remove ent_create("ent_ball3") but you'd have to code the self.Remove into both ball1 and ball2. I can't really explain it, but I'm really hoping you get what I mean :)
[lua] function ENT:Touch( HitEnt ) if( IsValid( HitEnt ) and HitEnt:GetClass( "ent_name" ) ) then HitEnt:Remove(); self.Entity:Remove(); --insert code to make ent local myent = ents.Create( "my_ent" ) --blaablablaba end end [/lua] That should be correct.
[QUOTE=Chad Mobile;20017792][lua] function ENT:Touch //code where it touches something.. self.remove ent.Create("ent_ball3") [/lua] Something like that I'd guess. I can't test it right now, sorry.[/QUOTE] No no no no, bad. We do not post misleading code help in this board. I say good day to you, sir.
Chad, would you please stop helping people in this forum until you know how to code properly in Lua.
I wasn't posting code to use, I was giving an idea... Edit: I mean I wasn't saying "Use this code its 100% foolproof" i was meaning "heres my idea"
Correcting Wablur's code [lua] function ENT:Touch( HitEnt ) if( IsValid( HitEnt ) and HitEnt:GetClass() == "ent_name" ) then --insert code to make ent local myent = ents.Create( "my_ent" ) --blaablablaba HitEnt:Remove(); self:Remove(); end end [/lua]
[QUOTE=Chad Mobile;20017903]Oh, try something like //blahlala code for creating function //creating ent IF ent_ball1 collides with ent_ball2 then self.remove ent_create("ent_ball3") but you'd have to code the self.Remove into both ball1 and ball2. I can't really explain it, but I'm really hoping you get what I mean :)[/QUOTE] No i didn't get what you ment. Untill these other fine gentelmen showed up, i was in quite the pickle. I mean, wtf is ent_ball1 collides with ent_ball2... it has nothing todo with lua, it sounds more like game-creator or some shit... But yeah, thanks people working like a treat.
[QUOTE=Disseminate;20030116]Correcting Wablur's code [lua] function ENT:Touch( HitEnt ) if( IsValid( HitEnt ) and HitEnt:GetClass() == "ent_name" ) then --insert code to make ent local myent = ents.Create( "my_ent" ) --blaablablaba HitEnt:Remove(); self:Remove(); end end [/lua][/QUOTE] Oh forgot about the GetClass() == "", wasn't thinking straight.
Sorry, you need to Log In to post a reply to this thread.