"Key is pressed" error?

For questions about using Classic.

Post » Thu Sep 25, 2008 10:17 pm

So I got this:

Pseudo code
[code:xlnlsjkm]
+Key "Enter" is pressed
-Set "1" to "2"

+Key "Enter" is pressed
-Set "2" to "3"[/code:xlnlsjkm]

If I do something like this, it would jump straight to "3".
I'm trying to make a menu, so if I press enter to get to a sub-menu, the first option of that sub-menu is instantly selected, and I want to avoid that.

Any help would be gratly appreciated.
Thanks!
B
2
S
1
G
4
Posts: 92
Reputation: 1,384

Post » Thu Sep 25, 2008 10:23 pm

Events are run from top to bottom. That means first "1" is set to "2", then "2" is set to "3" immediately after.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Thu Sep 25, 2008 10:32 pm

Maybe you just want to add 1 to the value...?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,620

Post » Thu Sep 25, 2008 10:34 pm

[code:2m3c8a7v]+ Enter is pressed
+ X = "2"
- Set X to "3"[/code:2m3c8a7v]

Use this if you don't want to just add like Ashley suggested.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Thu Sep 25, 2008 10:34 pm



can use something like this. as it is in that image, it doesn't work -- the conditional one still needs to be ABOVE the non-conditional. i thought this was a bug but changing the order fixed it.

later tonight i can give you a cap and better explanation -- i already had that image hosted, so it was convenient.

[quote="Jeswen":23ydkpqt][code:23ydkpqt]+ Enter is pressed
+ X = "2"
- Set X to "3"[/code:23ydkpqt]

Use this if you don't want to just add like Ashley suggested.[/quote:23ydkpqt]
just keep in mind that if you have

+ Enter is pressed
- Set X to "2"

infront of that event, it'll still go straight through them in one key press.

you need:

[code:23ydkpqt]+ Enter is pressed
+ X = "2"
- Set X to "3"

+ Enter is pressed
- Set X to "2"[/code:23ydkpqt]
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Thu Sep 25, 2008 10:36 pm

lol, BAM 3 solutions ...

@dyfb: Not if you do it for each X = Y
I just tried it.

Which is what I meant.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Thu Sep 25, 2008 10:42 pm

[quote="Jeswen":68sbqkrf]lol, BAM 3 solutions ...

@dyfb: Not if you do it for each X = Y
I just tried it.

Which is what I meant.[/quote:68sbqkrf]
http://upload.dfyb.net/uploaded/numbers.cap

nope

if they are in order, it'll run through them all at once. to get it to work, you need to reverse their order.
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Thu Sep 25, 2008 10:43 pm

Thanks for the tips, guys. I'll try some of this stuff now.

The weird thing is, I thought it would work the way I had done it in the first place, since the condition is "Key is pressed" instead of "Key is down".
B
2
S
1
G
4
Posts: 92
Reputation: 1,384

Post » Thu Sep 25, 2008 10:43 pm

[quote="dfyb":27gpyewp]nope

if they are in order, it'll run through them all at once. to get it to work, you need to reverse their order.[/quote:27gpyewp]

You didn't do it for each, you took what I said literally as "X = Y" then "X = Z"

No matter though, he's got it!
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Thu Sep 25, 2008 10:47 pm

[quote="Jeswen":27iync02][quote="dfyb":27iync02]nope

if they are in order, it'll run through them all at once. to get it to work, you need to reverse their order.[/quote:27iync02]

You didn't do it for each, you took what I said literally as "X = Y" then "X = Z"

No matter though, he's got it![/quote:27iync02]
can you post a quick example .cap (or screenshot)? not sure what you're saying should be different.
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests