What am I doing wrong - 'else' command

Just started using Construct 2? Post your questions here

Post » Sun Aug 23, 2015 10:41 pm

How come the below block of code works and the above block of code does not work?

Image
B
5
S
1
Posts: 20
Reputation: 415

Post » Sun Aug 23, 2015 10:45 pm

The little green arrow indicates that the "On key pressed" is a trigger, which works differently than a regular event. It gets called outside of the main script loop. The second way is the most appropriate mechanism to use.
ImageImageImage
B
71
S
22
G
248
Posts: 3,756
Reputation: 138,058

Post » Sun Aug 23, 2015 11:28 pm

Hm, seems really awkward to create many menus then?

If UI # 1 (main menu) is up, then hitting arrows should let you do X
If UI # 2 (sound menu) is up, then hitting buttons should let you Y
If UI #3 (inventory) is up, then hitting buttons should let you do Z

You could only do a single trigger and cascade actions based on what menu was up?
B
5
S
1
Posts: 20
Reputation: 415

Post » Mon Aug 24, 2015 1:40 am

You can use Groups to toggle whole groups of events.
For #1, The "Main" group would be active, all others inactive.
For #2, the "Sound" group would be active, all others inactive.
etc.
ImageImageImage
B
71
S
22
G
248
Posts: 3,756
Reputation: 138,058

Post » Mon Aug 24, 2015 2:04 am

Hm, but if the Sound group is a sub-menu within the Main menu, I'm still having issues where commands cascade. For example, when I hit Enter it goes through several menus. I would really like to do something like:

If Menu 1 is up,
-arrows move up and down
-if enter pressed while sound selected, go into Menu 2
-if enter pressed while display selected, go into Menu 3

else If Menus 2 is up
-if enter pressed, toggle volume

else if Menu 3 is up
-if enter pressed, toggle display

It sounds like the only alternative is to say

-if enter pressed,
if on menu 1, do x
if on menu 2, do y
if on menu 3,do z

But this gets really unintuitive quickly with a lot of menus and multiple controls per menu (e.g., enter, arrows, left, right, gamepad controls, etc)
B
5
S
1
Posts: 20
Reputation: 415

Post » Mon Aug 24, 2015 4:00 pm

This would happen if you enable the group and then that group's code is turned on so the same event is triggered in the next group, just due to timing. If you put a Wait 0 before the activate, it will get delayed until the end of the event sheet, and will only get picked up next time.
ImageImageImage
B
71
S
22
G
248
Posts: 3,756
Reputation: 138,058


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest