Auto-Tiling

From wiki
Revision as of 04:13, 30 August 2017 by DeamonHunter (Talk | contribs) (Fix pre that wasn't cut off.)

Jump to: navigation, search

There are times where you would want a tile to change it's look depending on what other tiles are around it. It could be objects like roofing tiles or fences. And there are times where you want a tile to change the tiles around it, again like roofing and fences. Auto-Tiling will allow you to do the following;

  • Change the tile you are placing.
  • Change tiles up to 2 blocks away from the tile.
  • Block placing your tile unless certain conditions are met.


How to do Simple Stairs

Before starting this tutorial, be sure to look at Modding#Setting up for Mod Creation.

To start this tutorial off, you will need 3 Tiles. These tiles should similar to the following;

Image containing 3 stair tiles.

For the purposes of this tutorial, the stair on the left will be the "Outer" Stairs, the one on the right will be "Inner" stairs and the one in the middle will be known as "Straight.

The Outer and Inner stairs should have the following in their *.tile files.

{
  "__inherits" : "staxel/tileObject/base.config",
  "code" : "mods.tutorial.MCStairs.inner",
  "voxels" : "mods/[Folder Name]/InnerStair.qb",
  "categories" : [ "stair" ],
  "representativeTile" : "mods.tutorial.MCStairs.straight"
}

Use Inner and Outer depending on which tile this is. Also be sure to change the folder name to the folder you store these tiles in. These tiles are now effectively done. What this does, is set these stairs up as normal Tile Objects. You really do not need to change much about these tiles. The one extra change however is "representativeTile". This will make it so you get the straight tile back instead of the corner pieces.


The next step is to set up the Straight tile file;

{
  "__inherits" : "staxel/tileObject/base.config",
  "code" : "mods.tutorial.MCStairs.straight",
  "voxels" : "mods/[Folder Name]/StraightStair.qb",
  "categories" : [ "stair" ],
  "autoTileInfo" : [

  ]
}

This file is almost set up. The last property is however not complete, as this will be the focus of this tutorial. Feel free to skip to the end if you don't want to figure out what all of this means.


First off lets think of how minecraft steps work. Or rather when they change from straight stairs. Here is a list of the ways they change;

  1. If a stair is behind the stair you are placing, then you will place a corner piece. This corner piece is the Outer stair from before. There are two orientations to this.
  2. If a stair is infront the stair you are placing, then you will place a corner piece. This corner piece is the Inner stair from before. There are two orientations to this.
  3. If there is a stair to the left of the stair you are placing, it will turn into a corner piece if it doesn't line up.
  4. If there is a stair to the right of the stair you are placing, it will turn into a corner piece if it doesn't line up.

Lets start adding in these interactions then. Lets start off with changing how the stair will react when being placed in front of another stair.

[Currently Under Construction]

Config Options

An important thing to note, is that Auto-tiling is not by it's own. It must be placed within a Tile. Before you continue however, there is some information about "autoTileInfo" itself.

"autoTileInfo"

AutoTileInfo is the property which contains all the properties listed below. However this is being mentioned, due to a special condition.

AutoTileInfo is a List of Blobs. This means you can specify multiple different groups of autoTiling in the same tile. It will commonly look like;

"autoTileInfo" : [
  {
    //Group 1
  },
  {
    //Group 2
  },
  {
    //Group 3
  }
]

Another thing to note is that these groups are done in order, with higher groups going first. This can be taken advantage off and make simpler files, as later groups will override earlier results. Take a look at Rope Fence Corner to see this in action.


"directionsToLookIn"

This is yet another list of List of Blobs. It will commonly look like the following;

"DirectionsToLookIn" : [
  {
    "direction" : "",
    "secondDirection" : "",
    "tilesToLookFor" : [],
    "tileCategoriesToLookFor" : [],
    "rotationToLookFor": 0
  },
  {
    //Direction 2
  }
],

"direction"

Valid options (String): "right", "left", "front", "back", "up", "down", "none"

Default Value: No default value is specified. Always need to provide your own.

This is the direction that it will check first. That is, if you say "right" it will check the tile to the right.


"rotationToLookFor"

Valid options (Integer ): 0,1,2 or 3

Default Value: If not specified, will not care about rotation.


If the tile that is searched, the one specified with #"direction" and #"secondDirection", has this specific rotation, then proceed to #"results". Otherwise reject it.


"secondDirection"

Valid options (String): "right", "left", "front", "back", "up", "down", "none"

Default Value: If not specified, will default to "none".

This is the direction that will check second. This will force the checked tile to be one further That is, if you say "right" for direction, then "right" for secondDirection it will check the tile, two tiles to the right.


"tileCategoriesToLookFor"

Valid options (List of String ): A list of any valid strings.

Default Value: If not specified, will not look for categories. Should specify either "tileCategoriesToLookFor" or "tilesToLookFor".


If the tile that is searched, the one specified with #"direction" and #"secondDirection", has any of these categories, then proceed to #"results". (As long as it is not rejected.)


"tileCategoriesToReject"

Valid options (List of String ): A list of any valid strings.

Default Value: If not specified, will not look for categories. Should specify either "tileCategoriesToLookFor" or "tilesToLookFor".


If the tile that is searched, the one specified with #"direction" and #"secondDirection", has any of these categories, then reject going to #"results".


"tilesToLookFor"

Valid options (List of String ): A list of strings each containing the code to a Tile.

Default Value: If not specified, will not reject any tiles.


If the tile that is searched, the one specified with #"direction" and #"secondDirection", has a code in this list, then proceed to #"results". (As long as it is not rejected.)


"tilesToReject"

Valid options (List of String ): A list of strings each containing the code to a Tile.

Default Value: If not specified, will not reject any tiles.


If the tile that is searched, the one specified with #"direction" and #"secondDirection", has a code in this list, then reject going to #"results".


"lookFromOverride"

Valid options (String): "right", "left", "front", "back", "up", "down", "none"

Default Value: No default value is specified. Always need to provide your own.

This is set the central tile to work from. Both "direction" and "secondDirection" will work based off of this direction.


"results"

This is yet another list of List of Blobs. It will commonly look like the following;

"results" : [
  {
    "tileToPlace" : "",
    "direction" : "",
    "secondDirection" : "",
    "rotation" : ""
  },
  {
    //Group 2
  }
],

"alt"

Valid options (Integer): 0, 1, 2 or 3

Default Value: If not specified, will place in a random alt.


This will be the number of the alternative look (alt) that the tile will have.


"tileToPlace"

Valid options (String): A strings containing the code to a Tile.

Default Value: If not specified, will place the the tile.


This will be the tile that is placed in the place specified by #"direction" and #"secondDirection".


"direction"

Valid options (String): "right", "left", "front", "back", "up", "down", "none"

Default Value: No default value is specified. Always need to provide your own.

This is the direction that it will check first. That is, if you say "right" it will check the tile to the right.


"rotation"

Valid options (Integer): 0, 1, 2 or 3

Default Value: If not specified, will place in a random rotation.


This will be the rotation that the tile is placed in.


"secondDirection"

Valid options (String): "right", "left", "front", "back", "up", "down", "none"

Default Value: If not specified, will default to "none".

This is the direction that will check second. This will force the checked tile to be one further That is, if you say "right" for direction, then "right" for secondDirection it will check the tile, two tiles to the right.