Save-Point
Map Tileset Changer during the game - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: Map Tileset Changer during the game (/thread-4124.html)



Map Tileset Changer during the game - Narzew - 05-05-2012

Script for changing tileset during the game.

Download script here
Code:
#==========================================================
#**Map Tileset Changer during the game
#**Author: Narzew
#**Release Date: 06.05.13
#**Version: 3.00
#==========================================================
#**Version Listing:
#**Version 1.00 : 01.04.12 : Basic Release
#**Version 2.00 : 28.04.12 : Compatibilty patch
#**Version 3.00 : 06.05.13 : Added helpers to change tileset in one line
#**Get latest script here: https://pastebin.com/bWmhyygL
#==========================================================
#**License:
#**Creative Commons Share-Alike (CC-SA)
#**Use free, but give credit to author
#**Please don't share script in clear form. Share link to pastebin.
#**Modify free, but give credit to author
#**If you modify the script, please attribute your work to narzew@gmail.com
#**Do not sell this script
#**Do not change license of the modified script
#**Do not sell modified script
#**Do not made commercial games with this script if you don't have
#**original author permission
#==========================================================
#**For scripters:
#**+ = added
#**- = removed
#** ! = rewrited
#** *= aliased
#==========================================================
#** Game_Map::setup*
#** Scene_Map::refresh+
#** Engine Module new
#** Engine.mtc_preconfigure+
#** Engine.mtc_enable+
#** Engine.mtc_disable+
#** Engine.change_tileset+
#** Engine.change_tileset_id+
#==========================================================
#**Instructions :
#**Select the tileset ID and type : Engine.change_tileset(x), where x is the ID
#**of the tileset.
#**If you use custom protect system, you should look at line 121.
#==========================================================
#**Method Listing:
#**Engine.mtc_preconfigure : required to work variable pre-configuration
#**Engine.mtc_enable : enables the script
#**Engine.mtc_disable : disables the script
#**Engine.change_tileset(x) : changes the tileset to x (int)
#**Engine.change_tileset_id(x) : same as change_tileset
#==========================================================

#==========================================================
#**Script
#==========================================================

#==========================================================
#**Game_Map class
#==========================================================

class Game_Map
  
  #==========================================================
  #**Game_Map::setup rewrite
  #==========================================================
  
  alias mtc_setup setup
  def setup(map_id)
    mtc_setup(map_id)
    if $mtc_script_working
      tileset = $data_tilesets[$mtc_tileset_id] if $mtc_script_working
    else
      tileset = $data_tilesets[@map.tileset_id]
    end
    @tileset_name = tileset.tileset_name
    @autotile_names = tileset.autotile_names
    @panorama_name = tileset.panorama_name
    @panorama_hue = tileset.panorama_hue
    @fog_name = tileset.fog_name
    @fog_hue = tileset.fog_hue
    @fog_opacity = tileset.fog_opacity
    @fog_blend_type = tileset.fog_blend_type
    @fog_zoom = tileset.fog_zoom
    @fog_sx = tileset.fog_sx
    @fog_sy = tileset.fog_sy
    @battleback_name = tileset.battleback_name
    @passages = tileset.passages
    @priorities = tileset.priorities
    @terrain_tags = tileset.terrain_tags
  end
  
end

#==========================================================
#**Scene_Map class
#==========================================================

class Scene_Map
  
  #==========================================================
  #**refresh
  #==========================================================
  
  def refresh
    @spriteset = Spriteset_Map.new
  end
  
end

#==========================================================
#**module Engine
#==========================================================

module Engine
  
  #==========================================================
  #**mtc_preconfigure
  #==========================================================
  
  def self.mtc_preconfigure
    $data_map_infos = load_data('Data/MapInfos.rxdata')
    $mtc_tileset_id = 1
    $mtc_script_working = false
    $actual_map = 1 if $actual_map == nil
  end
  
  #==========================================================
  #**mtc_enable
  #==========================================================
  
  def self.mtc_enable
    $mtc_script_working = true
  end
  
  #==========================================================
  #**mtc_disable
  #==========================================================
  
  def self.mtc_disable
    $mtc_script_working = false
    $game_map.setup($game_map.map_id)
    $scene.refresh
    $game_player.moveto($game_player.x,$game_player.y)
  end
  
  #==========================================================
  #**change_tileset
  #==========================================================
  
  def self.change_tileset(x,n=false)
    $mtc_tileset_id = x
    Engine.mtc_enable
    $game_map.setup($game_map.map_id)
    $scene.refresh
    $game_player.moveto($game_player.x,$game_player.y)
  end
  
  #==========================================================
  #**change_tileset_id
  #==========================================================
  
  def self.change_tileset_id(x)
    Engine.change_tileset(x)
  end
  
end

begin
  Engine.mtc_preconfigure
rescue
  print "Failed to load Narzew\'s Tileset Changer Script!"
  exit
end

Instructions

Have fun! :)


RE: Map Tileset Changer during the game - Narzew - 05-06-2013

Script updated! Now you can change map tileset with one command.