I need help with a chest that can be open again after some steps

Hi again, i need help with a mechanic that im trying to create, i need to make a chest open only if the shopkeeper (the event) is his sprite in a exact location and can be reopened if you walk a certain amount of steps, the problem is that it isn't working the first part if the player don't speak with the event in that location and second is that the chest doesn't reopen after the amount of steps so i figured out if you could help me guys, here are the images of the code i made.
Captura de pantalla (56).png
Hi there!

Try changing the script call condition to:
$gameMap.event(this._eventId).pos(12, 5)
This script call will check if the event is on position X = 12 / Y = 5.
this._eventId = Will get the event ID of the current event. it's optional, you could leave it as 6 too.
Hi there!

Try changing the script call condition to:
$gameMap.event(this._eventId).pos(12, 5)
This script call will check if the event is on position X = 12 / Y = 5.
this._eventId = Will get the event ID of the current event. it's optional, you could leave it as 6 too.
I tried that before but still with no result, the chest can be opened always after you talk to the event in the position 12, 5 also this is the other command page i have for the chest to return to the first phase
Captura de pantalla (55).png
If I understand correctly right now you're having the shopkeeper event check his location and it's set on action button(?) so nothing's happening. Shouldn't you have the chest event check the shopkeeper location when you try to open it?

Also, when opening the chest for the first time, just use the event commands to put the number of steps into a variable. Then when trying to open it again, put the number of steps into another variable and compare it to the old one (and update the old variable if you manage to open it).
I tried that before but still with no result, the chest can be opened always after you talk to the event in the position 12, 5 also this is the other command page i have for the chest to return to the first phaseView attachment 238605
You are showing me something different from the first post.

On the first post, if event 6 is on the coordinates X, Y the switch 104 is flipped on/off.
That screenshot you just sent is related to another event, that as far as I can tell, has its page activated by a self-switch A and has a script condition related to player steps, not the event 6 position.

That previous script call will for sure check the event position.

I guess you need to explain better what you are trying to do and post the screenshot of all event pages in question.
If I understand correctly right now you're having the shopkeeper event check his location and it's set on action button(?) so nothing's happening. Shouldn't you have the chest event check the shopkeeper location when you try to open it?

Also, when opening the chest for the first time, just use the event commands to put the number of steps into a variable. Then when trying to open it again, put the number of steps into another variable and compare it to the old one (and update the old variable if you manage to open it).
Thanks you so much @rpgLord69 and @Eliaquim that worked perfectly, now i can progress qith the karma effect on battles and general luck, and i will try to practice my english so i can explain me better next time, thank you

Original thread: https://forums.rpgmakerweb.com/threads/i-need-help-with-a-chest-that-can-be-open-again-after-some-steps.150719/