๐Ÿ™‹ Confusion Regarding Pressing Same Key + Event Execution

Good day every one! :two_hearts:

Here is what I would like to accomplish:

Press X key and image becomes visible. Pres X again and image becomes invisible.

I found everything I need in the event section to make it however one problem arose. First of all there is no If_Else statement. So I decided to create a variable to โ€œguardโ€ the image condition while pressing X, however that did not work since other events relating to same key are been executed almost at the same time. I tired to group and to set event under another event, however did not succeed again, once parent event is false it never falls down to child event.

Iโ€™m new to the engine and just trying to figure out what it can do on the fly - I probably misunderstood how events been executed or called. How can I resolve this issue? :woman_shrugging:

Thank you for any help, so far I had to do everything in JavaScript code with if_else statement :yum:

Yeah, itโ€™s tricky at first with no if-else type statement. It often needs a different approach to the challenge.

Look at 2 events, each with 3 conditions and 1 action each.

Event 1:

The x key is pressed
Image is visible
Trigger once while true

Hide image

Event 2:

The x key is pressed
Image is visible (invert this condition)
Trigger once while true

Show image

I think MrMenโ€™s solution wonโ€™t work in practice.
Try this
More information about it

Hah, teach me for replying so late at night, I canโ€™t even think straight. The first condition changes the visibility, and the second undoes it because it then becomes true in the same frame. Thanks for spotting that one, Jack

Yes thatโ€™s the issue with it :wink: it sends event response to both of them and when it done with first sub event, it deals with second having ALL the needed values for it to successfully meet conditions. :sweat_smile:

You need a variable to block that attempt. Now having understanding how this engine handles events I was able to come up with one variable solution and trigger once is crucial. It feels like it sends multiple events while trigger once made sure its only one time. Or may be itโ€™s just my impressions :woman_shrugging: Documentation did not help much regarding trigger once.

In any lovely case thank you for your โ€œat the bed timeโ€ attempt to help :heart: much much appreciating!

Hello and thank you for your help :two_hearts:

Unfortunately what you have offered did not work at all, well if you move a few things it kinda works but not really :sweat_smile:

Followed your link, yeah I see people struggling with this since itโ€™s not that intuitive on the fly regarding whats happening and without StepByStep debugger itโ€™s hard to catch it.

Any way here is the solution for the keyboard and I believe itโ€™s the same with touch and mouse in principle regarding clicking same buttons & images - should be part of the tutorial I think, people will try to imitate what they see is done in other games using full power of the code script without a doubt.

Oh i uploaded the wrong screenshot, if you swap the two sub-events, it works fine for me.

Maybe something like this might work too?

Edit: Oh I just saw you found a solution already lol

Hello :slightly_smiling_face:

Have tried it again today, nop still doesnโ€™t work - could you upload a correct screenshot of your working states? Iโ€™d much appreciate that, thank you :tulip:

Hello :partying_face:

No, did not work, because pressing key event is sending โ€œeventโ€ to each event that is listening for it and they sort of executing at the same time making whatever action of first event to simply be used for next event that is stored to be executed on the list :hugs:

And while using X not being pressed as conditional guardian is interesting it just fails, because it never has a chance to outplay itself. Did not play further with this, I think you can restructure it this way using while key X is not pressed if itโ€™s one time call event.

No worries tho, thank you for your time and trying to help me :two_hearts: Appreciating this a lot.

P.S. I find it hilarious you used strings โ€œnoโ€ โ€œyesโ€ :blush::+1:

I think mine is and was the same as yours, you just removed 2 unnecessary things.

Hi hi :blush:

Thank you for taking time to answer & trying to help! :+1: