Region use on tiles

Hi, is there a way to change a certain group of tiles (imagine a 3x3 patch of tiles) to a different sprite/asset using region and javascript code?
For example assigning the number region 1 to all those 9 tiles, and when the player steps on any of those, the tiles change automatically (using switches)

My guess is that the script is something like:

if ($gameMap.regionId($gameVariables.value(whatever N° you assigned for X), $gameVariables.value(the same with Y)) == 1
*change tiles to \i[index of the new tile] or whatever

I know I can do it with a single event with some switches and then copy that event the number of times that I need it to cover the region that I need tile changed, but it would be so much easier if regions can do that for me


Thank you very much and sorry for my english
I'm going to leave this here for now, as I'm not certain it would absolutely require a plugin. But I think it probably would, so this might need to go to Plugin Requests.

But Yanfly's Region Events plugin comes to mind. http://www.yanfly.moe/wiki/Region_Events_(YEP)

It can use regions to trigger a common event. If it were me, I'd probably first try having events on each of the tiles you want to change, with no image on the first page. Have a second page with a switch trigger and the image you want it to change to. And then use the common event to turn on that switch.
Hi there!
Yes, it is possible. However, you can also do that using events.
You can:
  • Assign each tile image to multiple events(one event for each tile).
  • Create a sprite sheet with all the tiles images, and use just one event.
  • Use the event command that changes the tileset image.
yes and no

there are script commands that can do this, but they will NOT be saved on the map.
if you leave and re-enter the map, the original map tiles will be back.

for a persistent change you'll either need to use the event method or a plugin for tile changes.
Hi, is there a way to change a certain group of tiles (imagine a 3x3 patch of tiles) to a different sprite/asset using region and javascript code?
For example assigning the number region 1 to all those 9 tiles, and when the player steps on any of those, the tiles change automatically (using switches)

My guess is that the script is something like:

if ($gameMap.regionId($gameVariables.value(whatever N° you assigned for X), $gameVariables.value(the same with Y)) == 1
*change tiles to \i[index of the new tile] or whatever

I know I can do it with a single event with some switches and then copy that event the number of times that I need it to cover the region that I need tile changed, but it would be so much easier if regions can do that for me


Thank you very much and sorry for my english
Ok wow this was honestly kind of a challenge but stay with me here lol

Uses 2 of my plugins along with some custom code:

Region Plugin:
Spoiler: Setup/Use
1653456535414.png

Change the separator to something like ~ to avoid it causing issues when running the region script commands
Then in the map's notebox:
JavaScript:
Script 1~ $gameMap.regionList[1].forEach(function(v){var x = v.x, y = v.y, z = 3;$dataMap.data[(z * $dataMap.height + y) * $dataMap.width + x] = 97;});SceneManager._scene._spriteset._tilemap.refresh();
Change z to the tile layer & change the "97" to the tileId you desire to change the tiles to

Custom Script Anywhere:
Spoiler: Setup/Use
lol not really sure if I'm wording this correctly but...

This is used to store coordinates of all the region ids into an object of arrays of objects that can be then used by a Region ID number...
1653456698052.png

Class: Scene_Map
Property of Function: prototype
Function: start
Post Script:
JavaScript:
$gameMap.regionList = {};
for (var x = 0; x < $dataMap.width; x++){
  for (var y = 0; y < $dataMap.height; y++){
    $gameMap.regionList[$gameMap.regionId(x, y)] = $gameMap.regionList[$gameMap.regionId(x, y)] || [];
    $gameMap.regionList[$gameMap.regionId(x, y)].push({x:x,y:y});
  }
}

...That's the basics of it at least.

Doing that looks like this:
Spoiler: Setup & In Game Video


Exactly as @Andar mentioned the tiles will change back when reloading the map (even when returning from the menu)...
that would require just a little more to make them reload the changes each time.
that is also quite possible to do though
that would require just a little more to make them reload the changes each time.
that is also quite possible to do though
I don't have the link, but Shaz wrote a plugin for tile changes that are persistent
here is the link to shaz_TileChanger, but not exactly sure if it works
with CT_Bolt plugins to do so (you need to test it out).
maybe a small modification is required for it.

link [here]

Original thread: https://forums.rpgmakerweb.com/threads/region-use-on-tiles.147907/