Tile Changer (Copy Tiles and Change Tiles)

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
Tile Changer
2018.03.24
by Shaz

Introduction
This plugin allows you to copy a block of tiles from another map to the current map, copy a block of tiles from one spot on the current map to another, or to change individual tiles to a specific tile Id.

How to use
Add to your plugin folder (call it Shaz_TileChanger.js) and enable in the plugin manager.
Set up the notes on the current map only if you want to copy tiles from other maps.
Use the plugin commands to copy or change tiles.

Map notes must be in the following format - one name/map pair for each map you want to copy tiles from:
Code:
<load:[{"name":"pinkroom","map":120},
       {"name":"blueroom","map":121},
       {"name":"greenroom","map":122}]>
I suggest doing this in a text editor, as the line won't fit in the map note window, so it's hard to see and can be easy to make mistakes.

When using the CopyTiles command to copy from another map, use the 'name' from the map note box rather than the map id. This does not need to be the same as the display name or the editor name of the map.

Plugin Commands

CopyTiles dx dy 'source' sx1 sy1 sx2 sy2 z-list
Copies tiles from another (or the same) map, where
dx is the x-coordinate of the top left destination area
dy is the y-coordinate of the top left destination area
source is the 'name' of the source map in the map note or 'self' if you want to copy a section of the current map - you need to put quotes around this name.
sx1 is the x-coordinate of the top left source area
sy1 is the y-coordinate of the top left source area
sx2 is the x-coordinate of the bottom right source area
sy2 is the y-coordinate of the bottom right source area
z-list is an optional series of z values indicating which layers to copy; if more than one, just use spaces between; if omitted, all layers will be copied

ChangeTile x y z tileId
Changes the tile at the specified coordinates and layer to the tileId
indicated. Note - no auto-formatting of autotiles happens here.

Z-layers
0 - ground layer (most A tiles)
1 - ground cover layer (A1 tiles with transparent areas, and right 4 columns of A2 tiles)
2 - upper layer 1
3 - upper layer 2
4 - shadow layer
5 - region layer

All arguments can be script commands that will be evaluated - make sure there are no spaces anywhere within the individual arguments/script commands.

Example


CopyTiles 3 3 'destroyed' 5 8 9 12
copies the area between 5,8 and 9,12 from the 'destroyed' map to the current map, with the upper left at 3,3. All layers are copied

CopyTiles 3 3 'wilted' 5 8 9 12 2 3
copies layers 2 and 3 (the upper layers) between 5,8 and 9,12 from the 'wilted' map to the current map, with the upper left at 3,3

ChangeTile 3 3 2 0
replaces the tile at coordinate 3,3 on layer 0 (upper layer 1) with tile 0 (which is the 'erase' tile - so this is removing whatever tile may have previously been there)

Plugin
Download from pastebin
make sure to save it as Shaz_TileChanger.js

Credit
- Shaz

Terms
- free for use in commercial games
- do not post elsewhere - link back to this page

Notes
This plugin changes/copies the tile Id, not the image. So your other maps should use the same tileset, or at least have the the tiles that you want to copy in the same position on both tilesets. Otherwise you could be trying to copy a vase with flowers from one map, and have it turn into a teddy bear on the other.

[introduced 2018.03.24] This plugin now saves the tile changes. If you leave the map (to another map, the battle screen or a menu) and return, the tile changes will still be there. You do not need to add a parallel process event to re-run the tile changes anymore.

I have only done basic testing with this plugin. If you have issues, please provide me with a copy/paste, or screenshots of
1. Your plugin command
2. Your map note box if you're using the CopyTiles command (copy/paste that one)
3. The console log, showing the error message and the script name and line number

Change Log
2018.03.24 1.10 - tile changes are now saved. Solves issue of tiles reverting when returning from the menu or battle, and an event to re-change the tiles when coming from another map are no longer required.
 
Last edited:

Canini

Veteran
Veteran
Joined
Mar 29, 2016
Messages
1,006
Reaction score
668
First Language
Swedish
Primarily Uses
RMVXA
Nice! A few practical examples of how this could be implemented in a game would be useful.
 

JareX

Veteran
Veteran
Joined
Dec 30, 2013
Messages
33
Reaction score
8
First Language
Spanish
Primarily Uses
I tryed to use the following command: ChangeTile 14 4 1 4

That replaced the tile on the map on position 14,4 with the 4th tile of the "B" tab of the tileset.

But the tile I'm looking to be put there is not on the "B" tab but rather on the "D" tab of my tileset.

How do I do that?

****EDIT

I figured it out: ChangeTile 14 4 3 523

The tile ID was just bigger.

Thank you! just what I was looking for!
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
B-E sheets all have 256 tiles, so the first B tile will be 0, then the first tile on each of the other sheets will be 256 more. A5 comes next, then A1-A4 but because they're autotiles, it's quite tricky to work out the numbers. You normally wouldn't want to swap the A tiles anyway.
 

Rehwihola

Villager
Member
Joined
Mar 19, 2018
Messages
10
Reaction score
2
First Language
Finnish
Primarily Uses
RMMV
Awesome plugin, thank you very much! I used the ChangeTile command to set some tiles. However if I hit esc to enter to menu and then esc again to return the game, the tiles are gone. Any ideas how to fix that? It doesn't seem to be a graphics issue as the tile id's get reset to 0. I can set them again, but I hope there's a better way.
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
@Rehwihola is it JUST when you enter the menu? What happens if you transfer to a different map and come back again?

This plugin only changes tiles while you're on the map. If you leave the map and return, the original tiles will be there. This may be what's happening when you go to the menu.

To make it a permanent change, you need to add a parallel process event that's conditioned by a switch, that runs the commands to change the tiles, then erases itself. Then, when you want the tiles to change, you just turn on the switch. That event will run, change the tiles, and erase itself. If you leave the map and return, that event will run, change the tiles, and erase itself.
 

Rehwihola

Villager
Member
Joined
Mar 19, 2018
Messages
10
Reaction score
2
First Language
Finnish
Primarily Uses
RMMV
Hey, thanks for your reply. The changed tiles reset to original ones if I visit the menu or save&continue. I haven't implemented any map transfers yet, but I expect the same result. I can set the tiles using an event, but if I delete the event at the end it doesn't seem to reappear when the tiles reset.

I did manage override the `Game_Player.prototype.executeMove` function and change the tiles there whenever they are reset. If I visit the menu or save&continue, the tiles will reset but after I move they'll change back to what they should be. I'd like to know if there's a better way. =)

@Rehwihola is it JUST when you enter the menu? What happens if you transfer to a different map and come back again?

This plugin only changes tiles while you're on the map. If you leave the map and return, the original tiles will be there. This may be what's happening when you go to the menu.

To make it a permanent change, you need to add a parallel process event that's conditioned by a switch, that runs the commands to change the tiles, then erases itself. Then, when you want the tiles to change, you just turn on the switch. That event will run, change the tiles, and erase itself. If you leave the map and return, that event will run, change the tiles, and erase itself.
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
that doesn't sound right - executeMove runs FAR too often to be doing this. Better for you to follow the suggestions given to make it work when it's supposed to work. What you've done is only going to cause more problems down the track.

Did you do what I said and create a parallel process event that changes the tile then erases itself? Please show a screenshot of that.
 

Rehwihola

Villager
Member
Joined
Mar 19, 2018
Messages
10
Reaction score
2
First Language
Finnish
Primarily Uses
RMMV
Yeah, I tried that. When I start the game I get the message from the event and see the tile. When I go to menu, I see the tile still at the background. When I exit the menu the tile is gone, and there's no more messages from the event (that I deleted). :blink:

that doesn't sound right - executeMove runs FAR too often to be doing this. Better for you to follow the suggestions given to make it work when it's supposed to work. What you've done is only going to cause more problems down the track.

Did you do what I said and create a parallel process event that changes the tile then erases itself? Please show a screenshot of that.
 

Attachments

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
I'll see if I can reproduce it - what you've got there should work.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
That was helpful - thank you. It looks like whenever you go to a different scene (menu, battle) and come back again, it reloads the map data entirely.

If that's the case, there are two solutions ... I can do what that plugin does, and simply save the map data prior to going to another scene and then reload it after the map scene is recreated, or I can make the tile changes permanent so they are saved with the save file, and whenever you re-enter that map (whether from the menu or battle scenes, or simply transfer from a different map), the tile changes will be re-done.

The latter is probably preferable, because it would remove the need for the parallel process event to re-do the tile change every time the map is loaded. But it could make the save files quite large.

I won't be able to do it and test until the weekend, so I'll take a couple of days to weigh the pros/cons of both approaches.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
I have made an update to this plugin. Due to the issues reported by @Rehwihola where tile changes were reverting when coming back from the menu, I have changed the plugin to save the tile alterations. This means you no longer need to add a special event just to re-do the tile changes when you come back to the map.

Please redownload from the original link.

Thanks to @Rehwihola for helping me test the new version.
 

Will Lawless

Villager
Member
Joined
Jan 15, 2017
Messages
6
Reaction score
1
First Language
English
Primarily Uses
Hello! Not to frazzle you out, but it appears this plugin is not working after v1.6.1.

I created a new project to test it. It's kicking back a failed to load Shaz_TileChanger.js. I also went into beta and created projects with v1.5.1 (failure to load) and v1.5.2 (black screen; game will not start in playtest).

Just thought I would let you know.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
Hey @Will Lawless

I just tested it out in a 1.6.1 project and I'm not having any issues. Failed to load is an unusual message, and indicates that something might have been deleted from the plugin contents. Could you try to redownload and replace the existing version in your project and see if that fixes it?
 

Will Lawless

Villager
Member
Joined
Jan 15, 2017
Messages
6
Reaction score
1
First Language
English
Primarily Uses
@Shaz Not a problem. Here is what I did:

1. Downloaded the plugin from fresh. Renamed it Shaz_TileChanger.js
2. Went on Steam and opt'ed out of beta (in case it was the issue). Allowed the application to download and update completely. Although opt'ing into beta and downloading anything back to v1.5.1 apparently does not help.
3. Started a new project.
4. Placed the plugin in the plugin folder.
5. Activated it in the plugin manager.
6. Tried to launch a playtest.

Showing screenshots of all. I also pulled it into sublime text and verified that it didn't cut anything off or change any of the code. If I turn off the plugin, the game starts up correctly. Console does not show any errors.

If it's working for you and other people, great. Why it's not working for me is... uhm... troublesome.

It is worth noting I am using a lot of other plugins in other projects, and they seem to be running fine. Only this one is giving me any issues. However, especially if I am the only one experiencing this problem, I totally don't expect you to fix it. Just to be clear. Thanks for looking into it.

sublime.PNG Failtoload.PNG
 

Attachments

Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,139
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
@Will Lawless

The issue can be seen in your Sublime Text screenshot. When you saved the file, it got called Shaz_TileChanger.js.js

Just remove the last .js and you should be good to go :)
 
Last edited:

Will Lawless

Villager
Member
Joined
Jan 15, 2017
Messages
6
Reaction score
1
First Language
English
Primarily Uses
Well, that worked. How embarrassing. I'm used to creating .js from textpad. Really, thanks for your help.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

There's another Humble Bundle available now for RPG developer assets, this time focused somewhat more towards pixel art style games.
Ive got a long lost half uncle. Thats real cool.
I forget what is bumping rule in this forum. Is anyone know? Thank you.
BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?
I feel that I should cut down on my order queue so I can get some more time for my projects, its been quite a longggg while since I worked on them LOL

Forum statistics

Threads
97,899
Messages
947,697
Members
129,127
Latest member
rawegg
Top