0 Favourites

Multiple Keystroke Events

  • How am i able to set multiple different actions upon using one single keystroke?

    In this case above for example using "i", only the first event will work.

    Using 2 events upon the same keystroke always interferes which each other.

    Could someone please explain me what's wrong?

    Is there any workaround for this?

    I've also tried to call a function in stead, but i always came up with the same issues as long as i was using the same keystroke.

    Thanks in advance,

    Everade

  • put a wait 0

    above the inventory toggle visiblities.

  • You don't need "Trigger once" on events like "On key pressed" because they will only trigger only once by design.

    I'm not sure what you want to do here. and what's the point of event nr 157?

    Pressing I will always toggle visible boolean so this event 157 is not needed. If I understood correctly You want to only toggle visibility of inventory, right?

  • oh yeah, what shinkan said

    (I was using set visible and set invisible to test, which only worked with the wait 0)

    all you need is the one event: press i, toggle visible.

    (is toggle visible beta version? or am I missing something?)

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • spacedoubt

    "visible" is just an Inventory object boolean variable.

  • Thought that might be the case.. looking at his events a bit harder, I see how obvious that is now..

    Thanks for pointing that out!

  • Sure thing. Eventually you will fall into the habit of seeing things you never seen before

  • You don't need "Trigger once" on events like "On key pressed" because they will only trigger only once by design.

    I'm not sure what you want to do here. and what's the point of event nr 157?

    Pressing I will always toggle visible boolean so this event 157 is not needed. If I understood correctly You want to only toggle visibility of inventory, right?

    Both events are required.

    I'm well aware that i could "toggle" visible and invisible with just one event.

    This is for my inventory, which uses Drag & Drop to equip and move your items within the inventory.

    So i have to ensure that with "dragging = 0"

    So it only closes if nothing is being moved, right?

    However while the inventory is already invisible, items are also not being dragged!

    So i have to create 2 events for this to make it possible.

    I was thinking a long time for other solutions, but this is the only one that made real sense to me to get it done.

    And yes you're right about the "trigger ones", i guess it's a left over from all my testings, because initialy i've not added those. I've removed it now thanks

    put a wait 0

    above the inventory toggle visiblities.

    Omg you're awesome!

    This actually worked!

    But could you explain me why the hell a "wait 0 seconds" is required?!

    It doesn't make any sense to me at all...

    I just want to understand.

  • quick question, if the inventory is closed, won't dragging also = 0?

    so can't that just be in the same 1 event?

    the wait 0 has something to do with commands just happening too fast or something...

    shinkan can probably explain it better than me.. I stole it from something he said on another post anyway, haha.

  • quick question, if the inventory is closed, won't dragging also = 0?

    so can't that just be in the same 1 event?

    the wait 0 has something to do with commands just happening too fast or something...

    shinkan can probably explain it better than me.. I stole it from something he said on another post anyway, haha.

    yes, that's correct.

    and i've actually tested that multiple times, but for some reason the inventory won't even open up anymore when i've tried that within 1 event.

    I don't know but... in a lot instances it feels like Construct 2 has a lot of bugs.

    I don't really like to implement such "workarounds" just to make it work.

    My game is becoming pretty big, and i'm worried about performance issues if i have to implement such messy events.

  • Like I said, You don't need it.

    Wait 0 will actually delay the following actions until the end of the event sheet.

    One note. You should consider making inventory on separate layer. This way you can only toggle visibility of that layer instead of all needed objects.

    And then you can do something like this

    If layer "inventory" is visible - do stuff in inventory

    Else - don't

    That way you can interact with all inventory elements only if this layer is visible,

  • Update:

    Got it to work now with just a single event.

    Maybe it was a caching issue on the browser...

  • I don't know but... in a lot instances it feels like Construct 2 has a lot of bugs.

    I don't really like to implement such "workarounds" just to make it work.

    My game is becoming pretty big, and i'm worried about performance issues if i have to implement such messy events.

    Nope, there's not a lot of bugs... maybe few but not a lot

    C2 is quite easy but you need to know how stuff works, but that needs time.

    Are you aiming for desktop? or mobiles?

  • Thanks a lot for the help guys!

    I didn't think to make it work with the whole layer!

    I will try that out by tomorrow.

    However i'm not using the drag & drop feature.

    I've used the system written by Yann https://www.scirra.com/forum/need-help-with-something_t65732?start=20

    I think i've learned already more than i've ever expected when posting this thread ^^

    I'm aiming for PC right now

  • I used drag and drop because it was faster. But you can easily modify this to your needs.

    If it's for PC then yeah, You can use whole layer. Or create and destroy all inventory elements instead of hiding them. It's up to you.

    You can do crazy stuff on PC, but remember if you ever feel about moving it to mobile you will need to consider some limitations.

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