Complicated: Changing Self Switch of Event in Front of Player?

Hello all 🙂

Working on some 'unlocking' spells. The player can lockpick or if they are skilled enough, they can cast an open spell on the lock. However...

Is there a way to change the self switch of an event directly in front of the player? Here's an additional issue: I want the common event (or whatever) to check if the event directly in front of the player is a 'lock' and then I need it to check what level the lock is, and then lastly, I need it to switch the self switch of that event to the 'unlocked' page.

I haven't the slightest clue where to begin (I did some googling, couldn't find a thing!)

I dedicate this haiku to those who might help me!

We close our hearts shut

Nevertheless, others find ways

to pry them open
The really important piece of information you left out is how are you going to tell whether the event is a 'lock' and how to determine the level, and what "switch it to the unlocked page" means. So all I can give you is a method to get the event in front of the player (this will give you the event itself - not just the event id - if you just want the event id, then you'll need to do something slightly different)

In a Script call:

Code:
x = $game_map.round_x_with_direction($game_player.x, $game_player.direction)y = $game_map.round_y_with_direction($game_player.y, $game_player.direction)evt = $game_map.events_xy(x, y)evt = evt.size > 0 ? evt[0] : nilif (evt)  # do whatever you need to determine the event type and lock level and act on itend
Unfortunately without the extra information I can't tell you what to put in the 'true' block for that if test.
The really important piece of information you left out is how are you going to tell whether the event is a 'lock' and how to determine the level, and what "switch it to the unlocked page" means.
Shaz, thanks for your response. What methods are available in order to label an event and then read that label? I left out those bits of information because I was unsure how to approach them. 'Switching to the unlocked page' just means changing that event's self switch. The regular page will be 'locked' but the page with self switch = a will be 'unlocked.' After the player casts the spell, I want the event to switch to self switch = a.
And how to determine whether it can be unlocked based on the lock level?
I believe you're thinking too complex - why not simply make the player trigger the action button and then ask the result or use conditional branches for it?


Like "this is a locked door, dou you want to use a lockpick on it?"


No need to check for lock or not from the outside, since the event code will only be there if it is a lock and so on.

Original thread: https://forums.rpgmakerweb.com/threads/complicated-changing-self-switch-of-event-in-front-of-player.51856/