"Key is pressed" error?

For questions about using Classic.

Post » Thu Sep 25, 2008 10:50 pm

I said what you said kind of, I assumed the two + symbols would show that. Sorry it didn't :)

I wrote it poorly.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Thu Sep 25, 2008 10:52 pm

'Key is pressed' stays true for the entire run through of events until the next tick (where it starts the code again from the top).
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Sep 25, 2008 10:53 pm

[quote="Arima":2xia3lec]'Key is pressed' stays true for the entire run through of events until the next tick (where it starts the code again from the top).[/quote:2xia3lec]

I wonder if another 'key is pressed' should be added on a per event basis.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Thu Sep 25, 2008 10:59 pm

[quote="Arima":2awlpqvo]'Key is pressed' stays true for the entire run through of events until the next tick (where it starts the code again from the top).[/quote:2awlpqvo]
That's pretty much right - but the way triggers work is if you have more than one trigger, when the trigger is fired they run in top-to-bottom order. So if you have 5 'Start of layout' events, they fire in top to bottom order when the layout starts. However, triggers generally run outside the execution of the normal event list - so will have the effect of having run either just before or just after the entire standard event list.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Sep 25, 2008 11:07 pm

Why is that? Couldn't that interfere with the code a lot? Like

Enter is pressed
set x to 10

a is down
set x to 20

If enter is pressed and a is down, and event 1 is run before or after (and depending on if the enter is pressed event is first or second) it could end up with a different result, and it wouldn't be obvious why at all.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Sep 25, 2008 11:21 pm

couldnt you just put the key is pressed event below the event which selects the sub menu item? that way on that frame update only the selection of that frame will be made, then you could just put a new one before the event which says key is pressed and sub menu is open,

order is everything, thats why lots of stuff made in mmf2 gets screwed up easily, those damn checks!!!
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Fri Sep 26, 2008 12:19 am

I always just do it like this:

[code:3e39xori]
+On key is pressed
+Value "press" is equal to 0
+Other condition
-Do stuff
-Set value "press" to 1

Repeat for as many switch states as you need.
After your switch events, add this:

+Always
-Set value "press" to 0
[/code:3e39xori]

That way it runs top to bottom, only triggers the switch if a previous switch hasn't been triggered, and resets itself after checking all the switch conditions.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Sep 26, 2008 12:24 am

'ELSE' in a subevent might be handy here, something along the lines of...

+ On 'Enter' pressed
----+ Value = 1
----> Set Value to 0 (and do other stuff)
----+ ELSE
----> Set Value to 1 (and do other stuff)

This way is completely contained inside the event, and won't suffer the fall-through behavior.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Fri Sep 26, 2008 12:47 am

Or yet another way, if key is down and trigger once.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Fri Sep 26, 2008 12:51 am

Trigger once wasn't working for me when I tried it, either at the top or bottom. Unless you're thinking something different.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests