[Request]Else(Invert SOL)

Discussion and feedback on Construct 2

Post » Tue Nov 04, 2014 6:46 pm

I would like to have an option to create logic like this:

----Initialize:----
Code: Select all
3 objects with object.value > 10
9 objects with object value <10


----Logic:----
Code: Select all
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


As it stands, this would be done as follows:

----Logic:----
Code: Select all
Pick object where object.value > 10
----Set object.OverTen to TRUE
Pick object where object.value !> 10
----Set object.OverTen to FALSE

In this case, two picking operations have to be run, which is wasteful, especially when sorting large numbers of objects.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Tue Nov 04, 2014 8:18 pm

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.
Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270

Post » Wed Nov 05, 2014 3:22 am

newt wrote: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...?
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Wed Nov 05, 2014 3:52 am

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.
Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270

Post » Wed Nov 05, 2014 11:50 am

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.
Scirra Founder
B
397
S
236
G
88
Posts: 24,389
Reputation: 194,448

Post » Wed Nov 05, 2014 6:31 pm

@Ashley

I see what you mean about 'OR' blocks...I hadn't thought of that.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests