Question about condition order and parenting

Get help using Construct 2

Post » Thu Jul 18, 2013 3:24 pm

I have this situation, where I want to be able to select multiple units like in rts.

To do this I need an if...else if... loops with if...else if... loop inside (to cover every type of mouse dragging and unit positions). It would be so simple in plain js, but I have no idea how to do this with events. Is it even possible?

Something like this:

[code]if(start_x > end_x)
     if(start_x < unit_x+unit_width/2 && ...)
else if (...)
How can I do this using events?

Maybe there is already that functionality (selecting multiple objects) that I don't know about? Or maybe a way to do this without all those if's?
Posts: 3
Reputation: 181

Post » Thu Jul 18, 2013 3:42 pm

You can do ifs, elses, ... and whatever you could do in JS in logic. Example with some comments

If you're having trouble about picking, it's not exactly the same. By default (when no condition is applied), every object in the layout is picked. After each condition, you select a little more elements, removing from the selected list elements that don't meet the conditions. That means that adding a condition "Ennemy.HP > 0" won't pick ennemy with HP>0 but will remove every ennemy with HP <= 0 from the selected list. This is why there are conditions like "pick all", to add items to the selected list.
Certain conditions, like "compare 2 values" in the System object, are boolean conditions, and won't be considered as affecting an object type. They will just block an event from triggering if they are false.
The best way to really understand all the possibilities of this system is to create a sample capx, and try with lots of debug, see what triggers in what cases, find out what the "wait" action can do to the function parameters, discover that removing every object from the selected list will prevent the event from triggering, thus will trigger the else event, ...
Experimentation is a nice friend here, but there are also lots of things in tutorials ;)
Posts: 473
Reputation: 6,211

Post » Thu Jul 18, 2013 4:06 pm


Check out the RTS template.
Posts: 1,098
Reputation: 11,222

Post » Thu Jul 18, 2013 5:45 pm

Thank you for that example, it explained what I wanted.

I managed to work it out without all the if..else conditions however, and encountered another

I still don't understand events well, I'm really new to this.

I want the last block part to be done even if first two won't happen at all. So the first two parts just switch coords if needed to, and the third part should be done even if nothing was changed in previous blocks, but it doesn't happen. It won't run if first two blocks didn't run. How to do it?
Posts: 3
Reputation: 181

Post » Thu Jul 18, 2013 6:03 pm

Your link takes me to a page "that doesn't exist".
Please correct the link.

If it is built upon Guizmus' example, simply add a blank event as event number 6, it will be executed every tick no matter what.

Without a clear view at what you got though, this advice might be wrong.

Also don't hesitate to check and re-check how events work if you're still unsure.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Posts: 7,310
Reputation: 71,069

Post » Thu Jul 18, 2013 6:26 pm

Not really sure what is wrong with the link, it works when I use it :/

I didn't use any example, I'm trying to do very basic thing but I fail to understand how events work.

To be more clear, I'm trying to do:

on button release
if(something) then do something
if(something) then do something
do other stuff

But everything stops after first if, when it is not true, I want it to continue and do second if and stuff after that too no matter if the first if's were true.

And I don't see any rts template in my templates. Am I missing something?
Posts: 3
Reputation: 181

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, totoe and 7 guests