Event Trigger Problem

So I have made an event where the player can turn a lamp on and off and it will switch between two sprites. This event is triggered by Player Action. I have a separate event where when the player finds an item the lamp light surges and goes out. The one thing I cannot figure out is how to switch the sprite back to off if the lamp is triggered by the Player.
Is there a script call to erase an event? If I can erase the event in a separate parallel event it will solve my problem, I think.
I assume you use a switch or self switch to control the lamp's on/off state, correct? If so, just use a script call to manipulate it from the other event.

If the lamp is using a switch, use the following script call:
$gameSwitches.setValue(num, true/false).

If the lamp is using a self switch, use this script call:
$gameSelfSwitches.setValue([mapId, eventId, self switch], value)
I assume you use a switch or self switch to control the lamp's on/off state, correct? If so, just use a script call to manipulate it from the other event.

If the lamp is using a switch, use the following script call:
$gameSwitches.setValue(num, true/false).

If the lamp is using a self switch, use this script call:
$gameSelfSwitches.setValue([mapId, eventId, self switch], value)
Would you be able to give an example of what: $gameSelfSwitches.setValue([mapId, eventId, self switch], value) would look like? 😅
I've been entering what I thought were the right values but I must be doing something wrong. Would eventId be the name I have given the event, or the number of the event?

This is what I entered but I know it's wrong 😩
$gameSelfSwitches.setValue([Fancy Bedroom, Lamp, A], OFF)
Would eventId be the name I have given the event, or the number of the event?
Both eventId and mapId are numerical values. So if your lamp is event 5, and the map it's on is map 2, it would be written as follows:

$gameSelfSwitches.setValue([2, 5, "A"], true)

In your case, you'd change true to false instead, as I figure the self switch would be enabled when the lamp is on.
This is what I entered but I know it's wrong 😩
$gameSelfSwitches.setValue([Fancy Bedroom, Lamp, A], OFF)
Just to expound on @Sword_of_Dusk's correct answer, all IDs in RPG Maker are always numbers.
1716339047917.png


See the corner there? ID, not name.

However, unlike the editor, you never use leading zeros in any IDs that you type into code.

And then even though the editor uses ON/OFF for the switches, in code they're boolean values: true/false.
Just to expound on @Sword_of_Dusk's correct answer, all IDs in RPG Maker are always numbers.
I probably should've specified that. Thanks for providing the additional explanation, Turan.
Both eventId and mapId are numerical values. So if your lamp is event 5, and the map it's on is map 2, it would be written as follows:

$gameSelfSwitches.setValue([2, 5, "A"], true)

In your case, you'd change true to false instead, as I figure the self switch would be enabled when the lamp is on.
Thank you!! My event works how I want it to 😂

Just to expound on @Sword_of_Dusk's correct answer, all IDs in RPG Maker are always numbers.
View attachment 305965

See the corner there? ID, not name.

However, unlike the editor, you never use leading zeros in any IDs that you type into code.

And then even though the editor uses ON/OFF for the switches, in code they're boolean values: true/false.
Thanks, I was totally missing where the map ID's were! This clarification helps so much, especially when someone is terrible at any code 😅
Thank you!! My event works how I want it to 😂
You're welcome. Half the reason I hang around the forums is to help others when I can. Good luck with your project, and don't hesitate to seek more help if needed.
Some bonuses to throw in for you:
1) that script to remotely change an events script call is really valuable. I'd keep that one in mind as it can be used in many different settings.
2) if you are changing a sprite, you could keep put the turned on lamp and the turned off lamp on the same sprite sheet.
Enabling direction fix will prevent it from changing when the player interacts with it.
Then use a move route: (event),
Direction fix off
Turn (direction the "off" lamp is set to on the sprite sheet)
Direction fix on

This would accomplish the same thing visually as having 2 event pages and switching between them with a self switch.

Good luck with your game make!
This thread is closed due to being solved. If you need it reopened, let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/event-trigger-problem.168896/