Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Auto_Tilesets

[VX] Auto_Tilesets Version: 1.0
By: Darkleo

Features
  • Allows you to use more tilesets
  • Enables you to see the tileset in the editor

Preliminaries
Copy and paste the script above main.
Open your games folder and go into Graphics/System.
You should have the default tilesets. If not, use the resource manager.
Change the tilesets by adding "default_" before each tilesets name.
(Example : "TileA1.png" becomes "default_TileA1.png").

Script
Code:
#==============================================================================

# ** Auto_Tilesets

# Version 1.0 #02/2009

# By Darkleo ([email=cestleonard@aol.com]cestleonard@aol.com[/email])

#==============================================================================

module Data_Tileset

  module_function

  #--------------------------------------------------------------------------

  def [](map_id)

    tileA1 = "TileA1"

    tileA2 = "TileA2"

    tileA3 = "TileA3"

    tileA4 = "TileA4"

    tileA5 = "TileA5"

    tileB  = "TileB"

    tileC  = "TileC"

    tileD  = "TileD"

    tileE  = "TileE"

# Configuration

    case map_id

    when 5 # Map ID

      tileA1 = "special"

    end

# End configuration

    return [tileA1, tileA2, tileA3, tileA4, tileA5,

      tileB, tileC, tileD, tileE]

  end

  #--------------------------------------------------------------------------

  def change_tileset

    map_id = load_data("Data/System.rvdata").edit_map_id

    path = "Graphics/System/"

    default = self[0]

    ext = ".png"

    for i in 0..8

      tileset = self[map_id][i]

      default_tileset = default[i]

      tileset = "default_" + tileset if tileset == default_tileset

      file1 = File.open(path + tileset + ext, 'rb')

      file2 = File.open(path + default_tileset + ext, 'wb')

      file2.write(file1.read)

      file1.close

      file2.close

    end

  end

  change_tileset if $TEST

  #--------------------------------------------------------------------------

end

#==============================================================================

class Spriteset_Map

  #--------------------------------------------------------------------------

  alias old_create_tilemap create_tilemap

  def create_tilemap

    tab = Data_Tileset[$game_map.map_id]

    @tilemap = Tilemap.new(@viewport1)

    for i in 0..8

      @tilemap.bitmaps[i] = Cache.system(tab[i])

    end

    @tilemap.map_data = $game_map.data

    @tilemap.passages = $game_map.passages

  end

  #--------------------------------------------------------------------------

end

#==============================================================================

Instructions
Configuration is from line 19.
For each map, add "when X" (X = map ID) in the script configuration, and add the name of the tileset for that map.
For example, map 5 uses the tileset "special.png" for tileA1 instead of the default tileset "TileA1.png" and map 7 uses the tileset "special2.png" for tileD instead of the default tileset "TileD.png", so the code you would use in the configuration settings is:
Code:
case map_id

    when 5 # Map ID

      tileA1 = "special"

    when 7

      tileD = "special2"

    end

To change the tileset in the editor, select one map, save and run the game.
You will notice in the editor (by changing the map) that the tileset that you see is the one used in the map you have selected when you launched the game.

Terms and Conditions
You can freely use this script, but you must include my name by crediting me on your game


Darkleo.
PS: Thanks to joshuaalanhargreaves to help me to translate the documentation in English.
 
Looks good. I like the way you've made it work in the editor, though I think it'd be even better if you made a special editor project which would allow you to a) configure which maps use which tilesets without going into the Script editor (and selecting from a list of actually available tilesets) and b) reset the System file for working on specific maps within the interface.
 
rey meustrus":24bxiocd said:
Looks good. I like the way you've made it work in the editor, though I think it'd be even better if you made a special editor project which would allow you to a) configure which maps use which tilesets without going into the Script editor (and selecting from a list of actually available tilesets) and b) reset the System file for working on specific maps within the interface.

I think this is a superb script that does not need to be changed. Changing the tilesets in the script editor is convenient enough. I recommend it to anyone who wants to use more tilesets in VX. Really great script darkleo! :thumb:
 
Crap...
I haven't think to the passages.
Wait one or two days to have a second version.
Actually, there is only one passage data for all the tilesets.
In the next version, it will be possible to set passages for each tileset.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top