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

Thread: Expression 2 - Entity Discovery

  1. #1
    Wirererer chiss's Avatar
    Join Date
    Feb 2008
    Posts
    207

    Default Expression 2 - Entity Discovery

    Can someone PLEASE show me some WORKING code of this?

    Everything i try doesn't seem to work?

    Code:
    @name FINDY
    @outputs E:entity GPS:vector Owner:entity O_GPS:vector
    @persist 
    
    interval(1000)
    
    Name="chiss"
    
    if(Owner:name() == Name)
    {
        findExcludePlayer(Owner)
        findInSphere(Owner:pos(),1000)
        E = findResult(findInSphere(Owner:pos(),1000))
        GPS = E:pos()
        O_GPS = Owner:pos()
    }
    else
    {
        Owner=findPlayerByName(Name)
    }
    For example this should just target the closest entity to me?
    (Most of this is someone elses code - no credit to me)

    I can easily get them to track me, or some specific other player. But i can't get it working as a target finder at all.

    I get timer errors all the time too :\ why?
    Last edited by chiss; 12-23-2008 at 09:04 PM.



  2. #2
    Wire Weeaboo Pyro-Fire's Avatar
    Join Date
    Aug 2007
    Location
    WA, Australia
    Posts
    1,804

    Default Re: Expression 2 - Entity Discovery

    Assuming exp2 now entirely resembles lua;

    findResult(findInSphere(self:pos(),1000))
    will give you the entity.



  3. #3
    Master of Mars Magos Mechanicus's Avatar
    Join Date
    May 2008
    Posts
    852

    Default Re: Expression 2 - Entity Discovery

    That is nearly correct usage right there (findResult() isn't supposed to take findInSphere() as an argument, just a number between 1 and whatever findInSphere() returns.). It's just that one or other update broke findInSphere()/findInBox() (and maybe findInCone() too, I haven't checked). Not much to do but revert to the original find.lua or wait until Gwahir's not so busy, I suppose.
    Last edited by Magos Mechanicus; 12-24-2008 at 02:24 AM.
    I can wire anything directly into anything! I'm the Professor!
    -Professor Hubert Farnsworth

  4. #4
    Wire Weeaboo Pyro-Fire's Avatar
    Join Date
    Aug 2007
    Location
    WA, Australia
    Posts
    1,804

    Default Re: Expression 2 - Entity Discovery

    findInSphere returns the entity ID, which findresult uses to select an entity, so used together like that will return the entity.



  5. #5
    Wirererer chiss's Avatar
    Join Date
    Feb 2008
    Posts
    207

    Default Re: Expression 2 - Entity Discovery

    Quote Originally Posted by Pyro-Fire View Post
    Assuming exp2 now entirely resembles lua;

    findResult(findInSphere(selfos(),1000))
    will give you the entity.
    Tried that, with both entity()os() and Owneros(). Neither worked.

    Also the down side to that is itll just find the furthest away thing.

    a few more for safe measure.



  6. #6
    Master of Mars Magos Mechanicus's Avatar
    Join Date
    May 2008
    Posts
    852

    Default Re: Expression 2 - Entity Discovery

    Gwahir's given findInSphere() and such a different interface in E2, so it's not quite like the lua one. Instead, it saves a table from which you can pull results with findResult(Index).
    I can wire anything directly into anything! I'm the Professor!
    -Professor Hubert Farnsworth

  7. #7
    Wirererer chiss's Avatar
    Join Date
    Feb 2008
    Posts
    207

    Default Re: Expression 2 - Entity Discovery

    Quote Originally Posted by Magos Mechanicus View Post
    Gwahir's given findInSphere() and such a different interface in E2, so it's not quite like the lua one. Instead, it saves a table from which you can pull results with findResult(Index).
    We understand that, the problem is its not working.

    Can anyone get this working?



  8. #8
    Wire Sofaking SpectreCat's Avatar
    Join Date
    Mar 2008
    Location
    Sammamish, Washington
    Posts
    504

    Default Re: Expression 2 - Entity Discovery

    Ok this may not be what you are looking for, but it might help. Ill give you an example of a working target finder.

    @ Name Test
    @ Inputs
    @ Outputs X Y Z
    @ Persists Position:vector Target:entity ** You must define the variable as an entity **

    interval (10) ** You need interval otherwise the position will not update, it set for 10milliseconds **

    findByClass ("Players") ** This could be Props, Npcs, Players, etc. **
    Target = findresult(#) **Replace 3, if there were 3 players, you would either be 1 2 or 3 **

    Position = Target: pos() ** Please ignore the space from t: pos, I am trying to avoid ***
    X = Position:x()
    Y = Position:y()
    Z = Position:z()
    Last edited by SpectreCat; 01-03-2009 at 10:25 PM.

  9. #9
    Wirererer chiss's Avatar
    Join Date
    Feb 2008
    Posts
    207

    Default Re: Expression 2 - Entity Discovery

    My conclusion is that a lot of the FIND functions are broken.

    If your above code works it would seem findByClass and findPlayerByName and maybe a few others work.

    I havent heard of anyone getting findInSphere working.



  10. #10
    Wire Noob chizley's Avatar
    Join Date
    Oct 2007
    Posts
    10

    Default Re: Expression 2 - Entity Discovery

    Chiss, remember how you said to me that when I tried to make something you thought could not be done that I have good aspiration?

    Looks like it paid of after a few HOURS:

    Code:
    @name TargetFinder
    @inputs GPS:vector
    @outputs TargetName:string TargetModel:string X Y Z
    @persist Gpsx Gpsy Gpsz Pos:vector TheEnt:entity Find VecPos:vector
    
    
    interval(10)
    #Init GPU
    Gpsx = GPS:x()
    Gpsy = GPS:y()
    GpsZ = GPS:z()
    
    #Set the Vector
    VecPos = vec(Gpsx, Gpsy, Gpsz)
    
    #Find the Target within 1000units of the GPS
    Find = (findInSphere(VecPos,1000))   
    
    #Return
    TheEnt = findResult(1)
    
    
    #Output
    Pos = TheEnt:pos()
    X = Pos:x()
    Y = Pos:y()
    Z = Pos:z()
    TargetName = TheEnt:name()
    TargetModel = TheEnt:model()
    Finished just then... its still fresh.. not perfect tho (welll..?)





    Code:
    @name TargetFinder
    @inputs GPS:vector
    @outputs
    @persist TheEnt:entity Find
    #Most Basic form, Add outputs freely
    #Kudos to Chiss for the GPS tip =]
    interval(10)
    Find = (findInSphere(GPS,1000))   
    TheEnt = findResult(1)
    Last edited by chizley; 01-09-2009 at 07:37 AM.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. E2 Entity Discovery, findResult , Loops?
    By Dave-X in forum Expression 2 Discussion & Help
    Replies: 4
    Last Post: 02-09-2009, 01:13 PM
  2. Welded Entity
    By Hellfire in forum Expression 2 Discussion & Help
    Replies: 6
    Last Post: 01-24-2009, 03:40 AM
  3. scripted entity
    By SenSai in forum Installation and Malfunctions Support
    Replies: 7
    Last Post: 11-22-2007, 07:27 AM
  4. Entity
    By Pyro-Fire in forum Installation and Malfunctions Support
    Replies: 1
    Last Post: 09-25-2007, 09:52 AM
  5. Damage entity
    By MurmeliWirer in forum Ideas & Suggestions
    Replies: 6
    Last Post: 08-25-2007, 10:03 AM

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