All buttons are working as the Action button right before teleporting

Hello there,

This is my first real post on this board, but I've introduced myself here. Here's the situation.

I have a key that summons a common event, which teleports the character on another map, which acts like a Pokédex, sort of. I do this because I need a Bestiary, yet no Bestiary script that I've been looking into fills my needs. Instead of listing all monsters that have been encountered/fought, I want to be able to manually tell which 'monsters' (heroes and NPC's, actually) are to be displayed. Since my project won't have any combat, I don't need to know how many times they've been beaten, or what are their stats, or their strenghts and weaknesses, or whatever. Just a list of characters, with a little picture and some strings of text. And since I have absolutely no clue about scripting, that's why I'm using a map instead. I call it the Codex.

Here's my problem.

When my player's character is facing an event, pressing the 'Codex' key will, as intended, teleport the player on the Codex map, but it will also trigger the event, which is unintended. In practice, I press the key, I'm teleported in the Codex, then the event of the previous map starts to talk. This is very annoying.

Can you guys help me? Thanks in advance. Have a good day.
Post screenshots of your events
Sure.
(I know text says it's the A key while event says it's the Y key, but that's because I was testing different keys, it doesn't change anything obviously.)
Getting a different issue where pressing the "codex" button teleports me to the map and returns back immediately. Can't reproduce triggering a map event when facing one.
Haven't you forgot to switch 'on' the 'IsInCodex' switch while still on the map, right before teleporting to the Codex, then 'off', while still in the Codex, right before teleporting back to the previous map?
If I don't, then I just stay stuck on the codex map. Any further presses to the "codex button" will just position me back to the starting point on the codex map. You're not using any scripts, right?

Maybe it would be better for you to just upload a demo.
Many thanks for your time @KK20.

You're not using any scripts, right?

Nope. Well, yes, but I can reproduce the bug even without any script, as you can see in this demo in which I cleaned anything unrelated. (If needed, you'll find the font I use in the 'Fonts' folder.) Don't forget to place yourself facing the event before pressing the 'Codex' key.

One thing I noticed: you'll see there's a message string in common events #14 and #15. If you get rid of these strings, then the game behaves as you said:

Getting a different issue where pressing the "codex" button teleports me to the map and returns back immediately.

But if you leave these strings, then the game behaves as I said:

In practice, I press the key, I'm teleported in the Codex, then the event of the previous map starts to talk.

I just can't wrap my head around it! If it's intended behaviour from the game engine, I'd like to understand how and why.
It is some kind of internal bug with XP; there's a collection of some of them here for example:
Seems like the Input state is carried over during a map transition, and all parallel processes are executed immediately prior to the transition.

What I found that worked for me was to change the CodexKey common event to this:
Code:
Conditional Branch: Script: Input.trigger?(Input::Y)
  Script: Input.update
  # your other conditional branch with the calls to the other common events here
It... it works! I'm not sure how to express my gratitude in proper English, so I won't even try. Instead, allow me to thank you many many muches!

If you're interested in getting a headache, here are my last observations:
- Normal conditional branch WITH messages at the start of common events #14 and #15 will cause the bug I mentioned, i.e. when you press the right key on the first map, said common events will execute (meaning you will access the second map), but then the event you were facing on the first map will inappropriately be triggered after you've arrived on the second map.
- Normal conditional branch WITHOUT messages at the start of said events will cause the bug YOU mentioned, i.e. when you press the right key on the first map, said common events will execute (meaning you will access the second map), but you will immediately be sent back to the first map. However, the event you were facing on the first map will not be inappropriately triggered.
- Scripted condition WITH messages at the start of said events will still cause the bug I mentioned.
- Scripted condition WITHOUT messages at the start of said events won't cause either of these bugs.

What it means, I suppose, is that your workaround only fixes the bug you mentioned, but not the one I mentioned. I'm kind of frustrated about it, but it won't effect the player since I don't intend to display any message right after he arrives on the second map. I'm not even sure why I did put these messages in the first place. Anyway. Your solution makes it work like I intended in the first place, and that's all that matters. Thanks again.

Case closed, I guess?

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/all-buttons-are-working-as-the-action-button-right-before-teleporting.128000/