"Key is pressed" error?

This forum is currently in read-only mode.
  • So I got this:

    Pseudo code

    +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!
  • Events are run from top to bottom. That means first "1" is set to "2", then "2" is set to "3" immediately after.

  • Maybe you just want to add 1 to the value...?

  • + Enter is pressed
    + X = "2"
    [ul]
    	[li]Set X to "3"[/code:2m3c8a7v][/li]
    [/ul]
    Use this if you don't want to just add like Ashley suggested.
  • <img src="http://upload.dfyb.net/uploaded/construct_bug01.PNG">

    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.

    + Enter is pressed
    + X = "2"
    - Set X to "3"[/code:23ydkpqt]
    
    Use this if you don't want to just add like Ashley suggested.
    

    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:

    + Enter is pressed
    + X = "2"
    [ul]
    	[li]Set X to "3"[/li]
    [/ul]
    + Enter is pressed
    [ul]
    	[li]Set X to "2"[/code:23ydkpqt][/li]
    [/ul]
  • lol, BAM 3 solutions ...

    @dyfb: Not if you do it for each X = Y

    I just tried it.

    Which is what I meant.

  • lol, BAM 3 solutions ...

    : Not if you do it for each X = Y

    I just tried it.

    Which is what I meant.

    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.

  • 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".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

    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!

  • > 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.

    >

    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!

    can you post a quick example .cap (or screenshot)? not sure what you're saying should be different.

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

    I wrote it poorly.

  • '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).

  • '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).

    I wonder if another 'key is pressed' should be added on a per event basis.

  • '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).

    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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)