Save-Point
KTilesetDir VX - 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 VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: KTilesetDir VX (/thread-10773.html)



KTilesetDir VX - kyonides - 10-26-2024

KTilesetDir VX

by Kyonides

Introduction

A forumer once asked for a way to use a secondary group of tilesets, and that led me to come up with this scriptlet.
Every single tileset has the same name as the default one, but all of them should be placed in the Graphics/Tilesets directory instead.

The Script

Code:
# * KTilesetDir VX * #
#  Scripter : Kyonides Arkanthes
#  2024-10-26

# This scriptlet allows you to define a custom tileset directory located in the
# Graphics folder.

module KTileset
  TILESET_DIR = "Tilesets"
  # Add as Many Map ID's as deemed necessary, i.e. [1,2,3,4]
  MAP_IDS = []
end

module Cache
  def self.tileset(filename)
    load_bitmap("Graphics/#{KTileset::TILESET_DIR}/", filename)
  end
end

class Spriteset_Map
  alias :kyon_tileset_dirs_sprtst_map_crt_tilemap :create_tilemap
  def create_tilemap
    if KTileset::MAP_IDS.include?($game_map.map_id)
      create_custom_tilemap
    else
      kyon_tileset_dirs_sprtst_map_crt_tilemap
    end
  end

  def create_custom_tilemap
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.bitmaps[0] = Cache.tileset("TileA1")
    @tilemap.bitmaps[1] = Cache.tileset("TileA2")
    @tilemap.bitmaps[2] = Cache.tileset("TileA3")
    @tilemap.bitmaps[3] = Cache.tileset("TileA4")
    @tilemap.bitmaps[4] = Cache.tileset("TileA5")
    @tilemap.bitmaps[5] = Cache.tileset("TileB")
    @tilemap.bitmaps[6] = Cache.tileset("TileC")
    @tilemap.bitmaps[7] = Cache.tileset("TileD")
    @tilemap.bitmaps[8] = Cache.tileset("TileE")
    @tilemap.map_data = $game_map.data
    @tilemap.passages = $game_map.passages
  end
end

Terms & Conditions

Free for use in non commercial games.
Due credit is mandatory!
Mention this forum in your game credits as well.
That's it! Tongue sticking out