You can change a tile's region ID with following script:
JavaScript:
const x = 13;
const y = 25;
const newId = 42;
$dataMap.data[(5 * $dataMap.height + y) * $dataMap.width + x] = newId;
This will change the region ID of the tile at coordinates (13, 25) to 42.
By the way, the 5 represents the region ID layer. If you change it to something else, you'll be modifying a different layer. While I haven't tested it, I doubt that you can use this method to change a tile's sprite, since the spritesheet is most likely cached for performance reasons, as it needs to be accessed on every frame.
That said, keep in mind that this isn't permanent. As soon as the map data is reloaded, the region ID will be reset. This happens whenever the
Scene_Map is created such as:
- When starting a new game.
- When loading a save game.
- When transferring the player (even if it's to the same map).
- When returning from any scene to the
Scene_Map, such as:
- Leaving the pause menu (
Scene_Menu).
- After combat (
Scene_Battle).
- Using an item that triggers a common event (
Scene_Item).
- Leaving a shop (
Scene_Shop).
- After a name input event command (
Scene_Name).
- After returning from the Debug screen (
Scene_Debug).
- Depending on the plugin you use, there may be any number of scenes you could return from.
You will either need a parallel event to ensure the region ID is always properly set, or a plugin that was made for this purpose.