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.

More terrain tags

This script lets you have more terrains for each map making that each map or
tileset use a unique palette of terrain tags.
It also add support for using codes and not numbers for scripters.

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

# More terrain tags

# By gerkrt/gerrtunk

# Version: 1

# Date: 09/09/2011

# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this 

# script check here: [url=http://usuarios.multimania.es/kisap/english_list.html]http://usuarios.multimania.es/kisap/english_list.html[/url]

# License: GPL, credits

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

=begin

 

------INTRODUCTION------

 

This script lets you have more terrains for each map making that each map or 

tileset use a unique palette of terrain tags.  

It also add support for using codes and not numbers for scripters.

 

------MAP OR TILESET MODE------

 

This script can work in two ways: based on maps or in tilesets. If there

are a palette for all maps using a tileset and for that tileset, or if 

exist a palette for each map. 

 

The sense of the config number => changues with the mode you are using.

 

To use the tileset mode active this line:

Terrain_tileset_mode = true

 

You have to add new lines for each map or tileset

  Maps_indexs = {

    4 => [99,1,2,3,4,5,6,7],

    2 => [8,9,10,11,12,13,14,15],

    9 => [8,9,10,11,12,13,14,15]

  }

 

id de terr/map => [terr1, terr2, terr...]

 

Note that if you dont put a map or tileset here, it will use default ones(0-7)

 

------CODES------

 

You can use :codes for improving visual use of the tags. For this you need 

set default codes, descoment the line and comnt the other set to false.

 

=end

 

module Wep

  Maps_indexs = {

    4 => [99,1,2,3,4,5,6,7],

    2 => [8,9,10,11,12,13,14,15]

  }

  

  #Default_codes = [:op, :wep, :nor, :ir, :lar, :set, :rat, :iku]

  Terrain_tileset_mode = false

  Default_codes = false

end

 

 

class Game_Map

 

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

  # * Get Terrain Tag

  #     x          : x-coordinate

  #     y          : y-coordinate

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

  def terrain_tag(x, y)

 

    if @map_id != 0

      for i in [2, 1, 0]

        tile_id = data[x, y, i]

        if tile_id == nil

          return 0

        else 

          # If by terrain 

          if Wep::Terrain_tileset_mode

            if Wep::Maps_indexs[@map.tileset_id] != nil

              return Wep::Maps_indexs[@map.tileset_id][@terrain_tags[tile_id]]

            else

              if Wep::Default_codes

                return Wep::Default_codes[@terrain_tags[tile_id]]

              else

                return @terrain_tags[tile_id]

              end

            end

            

          # By map

          else

            if Wep::Maps_indexs[@map_id] != nil

              return Wep::Maps_indexs[@map_id][@terrain_tags[tile_id]]

            else

              if Wep::Default_codes

                return Wep::Default_codes[@terrain_tags[tile_id]]

              else

                return @terrain_tags[tile_id]

              end

            end

          end  

        end

      end

    end

 

  end

  

  

end
 
With the default ones, you can use terrain tags from 0 to 7. These tags ids are the same for all the maps.

With my script each map have his own terrain tags, giving a translation from the orignal code (0-7 also, that cant be changued because of the closed editor) to a new number or code, so, you can create more terrain tags to use, but with the limitation of 8 per map(or by tileset, exist two modes).
Maps_indexs = {
4 => [99,1,2,3,4,5,6,7],
2 => [8,9,10,11,12,13,14,15],
}


This means that for map 4 the tag id1 in the map editor is 99, and the rest work like the same.
But for the 2, the 0 is 8, the 1 is 9, the 2 is 10...etc.

So, if you use a event comand get terrain tag of the player, and its in map 2 and the terrain tag of the tile is 2, it will return the number 10 and not 2, so you can use more tags.
 

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