[Resolved]Need tile swap script for RMXP

Started by finalholylight, March 02, 2013, 01:37:19 am

Previous topic - Next topic

finalholylight

March 02, 2013, 01:37:19 am Last Edit: March 03, 2013, 01:10:40 am by finalholylight
I saw this script on other forum but for VXA
QuoteThis script provides functionality for swapping tiles. In a single script call, you can change entire groups of tiles from one tile to another. The changes may be reverted as well using simple script calls.


http://forums.rpgmakerweb.com/index.php?/topic/9396-event-easy-tile-swapping/

Spoiler: ShowHide

Spoiler: ShowHide


Please anyone re-write this script for RMXP.

Wecoc

March 02, 2013, 11:15:33 am #1 Last Edit: March 02, 2013, 12:59:11 pm by Wecoc
Well, you can make 2 maps, with water and without water, and teleport. This would be the easy way xDD
But you can change a tile with a call script:
$game_map.data[x,y,a] = b+384

a is the layer: 0 to 2
b is the number of the tile on the tileset
Example:
$game_map.data[10,9,0] = 2+384

I did a script that replaces all the tiles of a number by another like in 2k.


#==============================================================================
# Replace Tile AddOn
# ---------------------------
=begin

 With this script you can replace tiles of a map like in RPG maker 2k.
 To call this on map, insert the next code on a Script command:
 
     $game_map.replace_tile(tile1,tile2,layer,autotile)
   
 tile1 => integer, initial tile of the tileset
 tile2 => integer, final tile of the tileset
 (layer) => integer, which layer will be altered (0 to 3) or all layers (-1)
           it equals -1 by default
 (autotile) => if true, the change will be on autotiles
           it's set false by default
 
=end
#==============================================================================

class Game_Map
 def replace_tile(a,b,layer=-1,autotile=false)
   @layer = layer
   if autotile == false
     for i in 0..width
       for j in 0..height
         if @layer == -1
           for l in 0..2
             data[i,j,l] = b+384 if data[i,j,l] == a+384
           end
         else
           l = @layer
           data[i,j,l] = b+384 if data[i,j,l] == a+384
         end
       end
     end
   else
     a0 = a*48 ; a1 = (a+1)*48
     b0 = b*48 ; b1 = (b+1)*48
     a_array = []
     b_array = []
     
     for i in a0...a1
       a_array.push(i)
     end
     for i in b0...b1
       b_array.push(i)
     end
     
     for i in 0..width
       for j in 0..height
         if @layer == -1
           for l in 0..2
             for k in 0..a_array.size
               data[i,j,l] = b_array[k] if data[i,j,l] == a_array[k]
             end
           end
         else
           l = @layer
           for k in 0..a_array.size
             if data[i,j,l] == a_array[k]
               data[i,j,l] = b_array[k]
             end
           end
         end
       end
     end
   end
 end
end


How to use:
$game_map.replace_tile(tile1,tile2,layer,autotile)
autotile --> true / false

finalholylight

March 03, 2013, 01:10:04 am #2 Last Edit: March 03, 2013, 01:19:15 am by finalholylight
Wow,that's what I need, thanks a lot  :haha: