Tile Changer (Copy Tiles and Change Tiles)

Discussion in 'JS Plugin Releases (RMMV)' started by Shaz, Jan 26, 2018.

  1. Shaz

    Shaz Veteran

    Messages:
    34,293
    Likes Received:
    8,934
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Tile Changer
    2018.01.26
    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. There should not be any spaces in the name!

    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 should not 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.

    This plugin does not save the tile changes. If you leave the map and return, it will revert to its appearance in the editor. If you want the tile changes to stick, you will need to add a parallel process event that re-runs the tile changes under the appropriate conditions, and deletes itself.


    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
     
    Last edited: Jan 28, 2018
    #1
  2. Canini

    Canini Veteran

    Messages:
    620
    Likes Received:
    354
    First Language:
    Swedish
    Nice! A few practical examples of how this could be implemented in a game would be useful.
     
    #2
    Sauteed_Onion likes this.
  3. Shaz

    Shaz Veteran

    Messages:
    34,293
    Likes Received:
    8,934
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Check the Examples heading.
     
    #3
    Sauteed_Onion likes this.
  4. JareX

    JareX Veteran

    Messages:
    33
    Likes Received:
    8
    First Language:
    Spanish
    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: Feb 10, 2018
    #4
    Sauteed_Onion likes this.
  5. Shaz

    Shaz Veteran

    Messages:
    34,293
    Likes Received:
    8,934
    Location:
    Australia
    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.
     
    #5
  6. Llareian

    Llareian Jack of All Trades, Master of None

    Messages:
    581
    Likes Received:
    1,199
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Last edited: Feb 13, 2018 at 5:45 AM
    #6
    Shaz likes this.

Share This Page