+ Reply to Thread
Results 1 to 5 of 5

Thread: E2 Entity Discovery, findResult , Loops?

  1. #1
    Wire Noob Dave-X's Avatar
    Join Date
    Dec 2008
    Posts
    13

    Default E2 Entity Discovery, findResult , Loops?

    Is there a way to create loop structure when using the findBy... and findResult?

    For example, if I wanted to add the mass of all the "prop_physics" into one variable.

    In other languages I would do this like this.

    Code:
    For X = 1 to findByClass("prop_physics")
      Weight+=findResult(X):mass()
    Next X

  2. #2
    Wirererer pl0x's Avatar
    Join Date
    Aug 2008
    Posts
    238

    Default Re: E2 Entity Discovery, findResult , Loops?

    No.

  3. #3
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: E2 Entity Discovery, findResult , Loops?

    You cannot loop in expressions (too easy to bog down a server).
    But you can achieve the same effect using interval/timers.

  4. #4
    Wire Noob Dave-X's Avatar
    Join Date
    Dec 2008
    Posts
    13

    Default Re: E2 Entity Discovery, findResult , Loops?

    Quote Originally Posted by Syranide View Post
    You cannot loop in expressions (too easy to bog down a server).
    But you can achieve the same effect using interval/timers.
    Could you give me an example Syranide? How can I go through a list of say, 10 object and find one variable of each object? Like the mass.

  5. #5
    Wire Amateur Peewee's Avatar
    Join Date
    Feb 2009
    Location
    United States
    Posts
    74

    Default Re: E2 Entity Discovery, findResult , Loops?

    Here's an example that will store the masses of everything found in an array.
    NOTE: This method will flip the array, so the first mass will be from the last entity found.
    [highlight=e2]@name Loop example
    @inputs Start
    @outputs IsLooping Results:array
    @persist Counter
    interval(10)
    if(~Start & Start){
    IsLooping = 1
    Counter = NumResults
    #do whatever find function here
    }
    if(!IsLooping){ #Don't do anything else when the loop is being run
    #commands
    #...
    }else{
    Results:setNumber(Counter, findResult(Counter):mass())
    Counter = Counter - 1
    if(Counter < 1){IsLooping = 0} #If there is nothing left, stop looping.
    }
    [/highlight]
    Last edited by Peewee; 02-09-2009 at 01:34 PM. Reason: E2 highlighting is IN!

+ Reply to Thread

Similar Threads

  1. Expression 2 - Entity Discovery
    By chiss in forum Expression 2 Discussion & Help
    Replies: 12
    Last Post: 03-17-2009, 01:02 PM
  2. loops and exec() for E2
    By Pyro-Fire in forum Ideas & Suggestions
    Replies: 23
    Last Post: 03-16-2009, 03:56 PM
  3. E2: how to Track with findResult?
    By rintin in forum Expression 2 Discussion & Help
    Replies: 7
    Last Post: 02-26-2009, 12:32 PM
  4. E2 Loops?
    By Kamrua in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 01-17-2009, 11:07 AM
  5. Loops or copying+pasting?
    By Azrael in forum Wiremod Addons & Coding
    Replies: 3
    Last Post: 02-17-2008, 06:44 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