PelaoQlo

Warper
Member
Joined
Dec 22, 2020
Messages
1
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
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
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
16,621
Reaction score
9,217
First Language
English
Primarily Uses
RMMV
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.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,828
Reaction score
2,170
First Language
Portuguese - Br
Primarily Uses
RMMZ
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,278
Reaction score
9,702
First Language
German
Primarily Uses
RMMV
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.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,175
Reaction score
728
First Language
Javascript
Primarily Uses
RMMZ
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:
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:
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:

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
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,278
Reaction score
9,702
First Language
German
Primarily Uses
RMMV
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
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,720
Reaction score
2,260
First Language
Dutch
Primarily Uses
RMMV
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]
 

Latest Threads

Latest Posts

Latest Profile Posts

Update on the Unity thing: I had to redo all my map graphics for Unity because the originals were from XP, but it actually looks so much better now in Unity, so I genuinely might make the switch.
Messing around with fragment shaders (filters). This thing is HUGE and I'm surprised almost no one makes good use of. Even the number of plugins that do this stuff are limited.
ScreenShot_6_28_2022_3_2_40.png

There's 7 main areas in the game that are all connected. This train get's you from an underground lab to the center of someone's subconscious. inside the train you can talk to some of the passengers. but going to the top of it, there's battles.
Speedrunning all character portraits just so they all have the same quality. Not sure if this was a good idea, but now I'm almost done.
We now have a gameplay video!

Forum statistics

Threads
123,154
Messages
1,154,453
Members
161,503
Latest member
Asinthew
Top