Skip to content

tileset

Lemonymous edited this page Nov 20, 2022 · 4 revisions

Table of Contents

 

easyEdit.tileset

  This module can be used to add new tilesets to the game, or fetch existing ones.

 

add

  • table   add(string tileset_id, string base_tileset_id)

  To add a new tileset, start by calling this function. Use a unique tileset_id for your tileset to avoid potential collisions with tilesets from other mods.

  You can create a completely blank tileset by leaving base_tileset_id empty, or you can use the id of an existing tileset to get a good base to start from. Anything you change after that, will only affect your own tileset.

 

Example - Blank tileset:

local tileset = easyEdit.tileset:add("steppes")

Example - Tileset based on the grass tileset used on Archive Island:

local tileset = easyEdit.tileset:add("steppes", "grass")

This will return a tileset object, which you can build on using table fields and methods found on this page.

 

get

  • table   get(string tileset_id)

  Returns the tileset object for an existing tileset with this tileset_id.

Vanilla Tileset id
"grass"
"sand"
"snow"
"acid"
"lava"
"volcano"
"vine"
"hologram"

 

tileset

fields

_id

  • string

  The unique id for this tileset.

 

climate

  • string

  Display name for the tileset's climate.

Set by setClimate, and fetched by getClimate.

 

environmentChance

  • number / table

  The chance to change a clear tile to forest, sand, ice or acid when creating a mission with this tileset.

Can be a flat number, or a table with separate percentages for the current difficulty, as well as the various tile types.

Set by setEnvironmentChance, and fetched by getEnvironmentChance.

Example:

-- Give forest, sand, ice and acid an equal 10% chance to occur on each clear tile.
tileset.environmentChance = 10

-- Give forest, sand, ice and acid separate percentage chance of occuring.
tileset.environmentChance = {
	[TERRAIN_FOREST] = 10,
	[TERRAIN_SAND] = 20,
	[TERRAIN_ICE] = 30,
	[TERRAIN_ACID] = 40,
}

-- Give forest, sand, ice and acid separate percentages, as well as separating them by difficulty.
tileset.environmentChance = {
	[DIFF_EASY] = {
		[TERRAIN_FOREST] = 10,
		[TERRAIN_SAND] = 0,
		[TERRAIN_ICE] = 0,
		[TERRAIN_ACID] = 0,
	},
	[DIFF_NORMAL] = {
		[TERRAIN_FOREST] = 10,
		[TERRAIN_SAND] = 0,
		[TERRAIN_ICE] = 0,
		[TERRAIN_ACID] = 0,
	},
	[DIFF_HARD] = {
		[TERRAIN_FOREST] = 16,
		[TERRAIN_SAND] = 0,
		[TERRAIN_ICE] = 0,
		[TERRAIN_ACID] = 0,
	},
}

 

rainChance

  • number

  The chance of rain for this tileset.

Set by setRainChance, and fetched by getRainChance.

 

tileLoc

  • table

  A table containing location offsets for each tile type in tileset. If the table is empty, default location offsets will be used.

 

tilePath

  • string

  Path relative to your mod, used to look for tiles when adding tiles to the tileset. Usually set as a parameter when calling appendAssets.

 

tileTooltip

  • table

  A table containing objects describing tooltip changes for specific tile types for this tileset.

Set by setTileTooltip

 

methods

 

appendAssets

  • void   appendAssets(table self, string tilePath)

  Appends assets from the specified tilePath relative to the mod's directory, and adds the tiles to this tileset.

Example:

tileset:appendAssets("img/tileset/")

 

addTile

  • void   addTile(table self, string fileName, Point tileOffset)

  Adds a single tile to the tileset; looking for the file in the location specified by tilePath.

NOTE: It is easier to add tiles using appendAssets.

Example:

tileset:addTile("ground_0", Point(-28,1))

 

addTiles

  • void   addTiles(table self, table tiles)

  Adds a table of tiles, specified by tiles. The table tiles can be an array of strings, a key/value list of string/Point or a combination of both. The method will call addTile internally for each entry; looking for the file in the location specified by tilePath.

NOTE: It is easier to add tiles using appendAssets.

Example:

-- Adding tiles using an array. Default tile offsets for each terrain type will be used.
tileset:addTiles{
	"ground_0",
	"mountain_0",
}

-- Adding tiles using key/value pairs. Custom tile offsets can be specified.
tileset:addTiles{
	ground_0 = Point(-28,1),
	mountain_0 = Point(-28,-21),
}

-- Adding tiles using a combination of the above.
tileset:addTiles{
	"ground_0",
	mountain_0 = Point(-28,-21),
}

 

copy

  • void   copy(table self, table baseTileset)

  Copies add tileset data from baseTileset to this tileset.

 

Example:

local baseTileset = easyEdit.tileset:get("grass")
tileset:copy(baseTileset)

 

copyAssets

  • void   copyAssets(table self, table baseTileset, boolean overwrite)

  Copies assets from the resource location managed by baseTileset to the resource location managed by this tileset.

NOTE: This method can only be used on game init.

Example:

local baseTileset = easyEdit.tileset:get("grass")
tileset:copyAssets(baseTileset, true)

 

getEnvironemntChance

  • number   getEnvironemntChance(table self, number terrain, number difficutly)

  Returns the chance of a clear tile changing to the specified terrain for the specified difficulty.

Example:

LOG(tileset:getEnvironmentChance(TERRAIN_FOREST, DIFF_EASY))

 

getRainChance

  • number   getRainChance(table self)

  Returns the chance of rain on a map with this tileset.

Example:

LOG(tileset:getRainChance())

 

onDisabled

  • void   onDisabled(table self)

  This function is called when this tileset is no longer in effect. By default this removes any terrain tooltip changes this tileset has specified in tileTooltip.

 

onEnabled

  • void   onEnabled(table self)

  This function is called when this tileset takes effect. By default this adds any terrain tooltip changes this tileset has specified in tileTooltip.

 

setClimate

  • void   setClimate(table self, string climate)

  Sets the display name for the climate of this tileset.

Example:

tileset:setClimate("Temperate")

 

setEmitters

  • void   setEmitters(table dustEmitter, table burstEmitter)

  Sets the "dust" and "burst" emitters used for this tileset. These emitters define which particles are created by for instance moving units from one tile to another. See vanilla file [ITB-ROOT]/scripts/emitters.lua for the makeup of an emitter.

Example:

local dustEmitter = Emitter_Dust:new{
	image = "combat/particle_repair.png",
}
local burstEmitter = Emitter_Burst:new{
	image = "combat/particle_repair.png",
}

tileset:setEmitters(dustEmitter, burstEmitter)

 

setEnvironmentChance

  • void   setEnvironmentChance(table self, number environmentChance)
  • void   setEnvironmentChance(table self, table environmentChance)

  Sets the environment chance for this tileset. See environmentChance for more details on the makeup of the table environmentChance.

 

Example:

local environmentChance = {
	[DIFF_EASY] = {
		[TERRAIN_FOREST] = 10,
		[TERRAIN_SAND] = 0,
		[TERRAIN_ICE] = 0,
		[TERRAIN_ACID] = 0,
	},
	[DIFF_NORMAL] = {
		[TERRAIN_FOREST] = 10,
		[TERRAIN_SAND] = 0,
		[TERRAIN_ICE] = 0,
		[TERRAIN_ACID] = 0,
	},
	[DIFF_HARD] = {
		[TERRAIN_FOREST] = 16,
		[TERRAIN_SAND] = 0,
		[TERRAIN_ICE] = 0,
		[TERRAIN_ACID] = 0,
	},
}

tileset:setEnvironmentChance(environmentChance)

 

setRainChance

  • void   setRainChance(table self, number rainChance)

  Sets the rain chance for maps on this tileset.

Example:

tileset:setRainChance(10)

 

setTilesetIcon

  • void   setTilesetIcon(table self, string iconPath)

  Sets the tileset icon for this tileset. The path specified by iconPath is relative to the mod's root directory.

NOTE: This icon can be automatically set if it is named "env.png" and placed in the same location as the rest of the tileset assets and calling appendAssets.

Example:

tileset:setTilesetIcon("img/tileset/env.png")

 

setTileTooltip

  • void   setTileTooltip(table self, table tileTooltip)

  Sets a custom tooltip for a terrain type for this tileset. tileTooltip is a table with the string fields tile, title and text. The field tile defines the tile type that should display the tooltip specified by title and text.

Field name Type Description
tile string Tile type
title string Displayed tooltip title
text string Displayed tooltip text

Example:

tileset:setTileTooltip{
	tile = "sand",
	title = "Custom Dunes",
	text = "Sand dunes with custom tooltip",
}