+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Interact with Entities using an Expression Gate (Like pressing E)

  1. #1
    Wire Amateur Matthias's Avatar
    Join Date
    Jul 2008
    Posts
    51

    Question Interact with Entities using an Expression Gate (Like pressing E)

    Hi,

    I searched a lot, hopefully enough, to say, that i havent found it.

    I think it would be nice, to be able to interact with entities with an Expression Gate.
    Especially, i wanted to design a Expression Gate, to switch the train-switches on gm_wireconstruct, without being forced to leave the Train.
    But sadly i could not find a function like this.
    Are there special reasons not to include it?

    Greetings
    Matthias

  2. #2
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    You could always have a wired User that's been nocollided with everything, including the world via the Adv. Ballsocket method, then applyforce that to wherever you need it.

    Or just have it follow the train and aim where you look, wire it to Mouse1 on the pod controller.

    If you've never applyforce'd anything before, there's tutorials about and we can help you when you get stuck.

  3. #3
    Wire Amateur Matthias's Avatar
    Join Date
    Jul 2008
    Posts
    51

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    But it would be nice anyway, to have something like entity():use()

    (Maybe restricted in the range, from which you can use something)

  4. #4
    Wire Amateur Matthias's Avatar
    Join Date
    Jul 2008
    Posts
    51

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    well... sry for doubleposting, but i want this thread moved to expression-gates-addons or added to public branch? *hope*
    Code:
    e2function void entity:use()
    	if  not this then 
    		return nil 
    	end
    	if  not this:IsValid() then 
    		return nil 
    	end
    --	if (this.IsWorld()) then 
    --		return nil
    --	end	
    --	if not validEntity(this) then 
    --		return nil
    --	end
    	if this.Use and this.GetPlayer then
    		this:Use(this:GetPlayer())
    	end
    end
    feels like the first sensefull thing I did in life.

    i think you can add this as entity.lua in your "\garrysmod\addons\wire\lua\entities\gmod_wire_exp ression2\core\custom"-folder or add this to entity.lua...

    Greetings
    Matthias
    Last edited by Matthias; 07-08-2010 at 01:59 PM.

  5. #5
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    1. Has no prop protection.
    2. You check for this being valid twice.
    3. You are passing the owner of the entity to Use and not the owner of the E2 executing it.

  6. #6
    Wiremod Helper Donkie's Avatar
    Join Date
    May 2008
    Location
    Sweden
    Posts
    1,661

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    Quote Originally Posted by initrd.gz View Post
    1. Has no prop protection.
    2. You check for this being valid twice.
    3. You are passing the owner of the entity to Use and not the owner of the E2 executing it.
    3 times, actually.
    Get out. Seriously, do it.

  7. #7
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    Well, not 3 times. An entity can be something other than nil and still be invalid. But validEntity(E) does the same thing as E ~= nil and E:IsValid()

  8. #8
    Wire Amateur Matthias's Avatar
    Join Date
    Jul 2008
    Posts
    51

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    i just wanted to provide the same security and "features" as the User-Ent does:

    Code:
    if (!trace.Entity) then return false end
    if (!trace.Entity:IsValid() ) then return false end
    if (trace.Entity:IsWorld()) then return false end
    if trace.Entity.Use and trace.Entity.GetPlayer then
    	trace.Entity:Use(trace.Entity:GetPlayer())
    EDIT: Well... the IsWorld() is senseless in that case.
    EDIT2: and the second valid-check - well you are right
    Last edited by Matthias; 07-08-2010 at 09:07 AM.

  9. #9
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    Well, the user is limited in that it is a beam; the one you made is unlimited.

  10. #10
    Wire Amateur Matthias's Avatar
    Join Date
    Jul 2008
    Posts
    51

    Default Re: Interact with Entities using an Expression Gate (Like pressing E)

    Then I'm open to suggestions, how to limit it.

+ Reply to Thread
Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots