[Request]Else(Invert SOL)

0 favourites
  • 6 posts
  • I would like to have an option to create logic like this:

    ----Initialize:----

    3 objects with object.value > 10
    9 objects with object value <10[/code:2hkjhyv4]
    
    ----Logic:----
    [code:2hkjhyv4]Pick object where object.value > 10
    ----Set object.OverTen to TRUE
    Else(Invert SOL) //This will select the other 9 objects
    ----Set object.OverTen to FALSE
    [/code:2hkjhyv4]
    
    As it stands, this would be done as follows:
    
    ----Logic:----
    [code:2hkjhyv4]Pick object where object.value > 10
    ----Set object.OverTen to TRUE
    Pick object where object.value !> 10
    ----Set object.OverTen to FALSE
    [/code:2hkjhyv4]
    In this case, two picking operations have to be run, which is wasteful, especially when sorting large numbers of objects.
  • Best place to use a function imo, but the fact is the initial will work, as long as it uses a top tier within the condition to pick.

    Remember every time you start a top tier subevent that does some other picking it forgets what was picked before.

  • Best place to use a function imo, but the fact is the initial will work, as long as it uses a top tier within the condition to pick.

    Remember every time you start a top tier sub-event that does some other picking it forgets what was picked before.

    I'm afraid I don't quite understand you (bit short on sleep today, that's probably part of it).

    I understand what you are saying about a top-tier event not passing it's pick list to the next event. I'm suggesting an exception to this that is dependent on the event prior, much like an else statement.

    An example of where this could be useful is if I want to select all the Foo's that are overlapping Foobar's, and subtract 1 from their health, then select all the Foo's ! overlapping Foobar's and add 1 to their health.

    As it stands you COULD accomplish this thru a hack:

    global fooHealthUp

    global fooColDmg

    ------

    Every tick

    --- Foo.health + fooHealthUp

    If (Foo overlapping Foobar)

    --- Foo.health - (fooHealthUp + fooColDmg)

    However, IMHO, this is inelegant and not-at-all-obvious. And if you are doing something more substantial (say moving objects) you are still performing redundant actions.

    I don't understand how using a function would help here...?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Basically a function breaks picking, and also breaks things up.. the opposite of what you are going for I know, but it can help to keep things separate, at least mentally.

    Pick else sounds like it might be a good idea, but it just goes against the flow of picking, and filtering, which removes objects from the sol, rather than adding to it.

  • The original version of the 'Else' condition did this, but it was extremely complicated to code, buggy, possibly performance impacting, and confusing to use as well (I forget specifically why, but I think it was for cases like OR blocks followed by a SOL-inverting ELSE start to get pretty hard to reason about).

    I also want to avoid having two types of 'Else' condition, since this takes a nice simple straightforward event which beginners can understand immediately, to something you need to go sifting through the manual to understand.

    Also the workaround is simple: just follow with the same event but with inverted conditions.

  • Ashley

    I see what you mean about 'OR' blocks...I hadn't thought of that.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)