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 (...)
     if(...)
[/code]
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?
B
3
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 ;)
B
17
S
8
G
4
Posts: 461
Reputation: 6,097

Post » Thu Jul 18, 2013 4:06 pm

@mrkujo

Check out the RTS template.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

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 https://copy.com/Qt1HWgB0kY0B.

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?
B
3
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 !
Moderator
B
276
S
103
G
84
Posts: 7,289
Reputation: 83,100

Post » Thu Jul 18, 2013 6:26 pm

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

https://www.copy.com/s/Qt1HWgB0kY0B/wrong.png

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?
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: bangoo, krombanna, YoHoho and 4 guests