

- #How do you create a custom map how to#
- #How do you create a custom map install#
- #How do you create a custom map mod#
- #How do you create a custom map code#
It will set your start position to the middle of the map and a bit above the start of the surface layer. Main.spawnTileY = (int)(Main.worldSurface - 16) Main.spawnTileX = (int)(Main.maxTilesX / 2)
#How do you create a custom map code#
The code for setting the start position is pretty simple: Okay, now that we're done with that we want to setup the spawn position because otherwise it will be (and therefore crash the game) or it will be adopted from the last world you played in. Cave Worlds are also possible, just set the surfacelayer and rocklayer to zero. You can set the start of the surfacelayer or rocklayer to any number you want but you have to set it, otherwise it will be zero or will have the same value as the last world you played in. This calculation is not necessary but it adds a good element of randomness. This is to make sure that the rocklayer always starts under the surfacelayer. The start of the rocklayer is calcuated this way: First it takes 20% of the map height (Main.maxTilesY * 0.2), afterwards it multiplies it by a random number that can vary from 0.63 to 0.76 (63% to 76%) and at the end adds the start coordinates of the surfacelayer to it (multiplication and division first, then addition and subtraction). If you put two numbers into it (like in the example above), it will return a number that is between the two numbers but will never be as high as the highest number.įor the surfacelayer it multiplies the height of the map by 0.3 (30% of the height) and after that it multiplies it by a random number that can vary from 0.90 to 1.09 (90% to 109%). If you put a single integer number into the brackets, it will return a number that is smaller than the one you put into the brackets. There are multiple ways to make it calculate the randomized number. If you call it by writing () it will return an integer number. WorldGen.genRand is a so called "Randomizer" - it is able to calculate random nonnegative numbers. This is somewhat simular to the way the rocklayer and surfacelayer are calculated in the original Terraria. We want to insert all our generation code between the brackets.įirst we have to set where the rocklayer and the surfacelayer start:

The function "GenerateWorld()" is called instead of the normal world generation function. Okay, remember that all our code will be saved in "Global\World.cs". This file will include all of our code and we're only working with this file the whole tutorial. In the "Global" folder you have to save a new, empty file named "World.cs" (Unless it already exists, in which case just edit it).
#How do you create a custom map mod#
You can always download the newest version here: v0.38.īefore you can start to write your own world generator, you have to create a folder named "Global" in your mod folder, if you haven't done that already.
#How do you create a custom map install#
See the Install Guide, if you have problems. See Terraria World Basics for more informations.
#How do you create a custom map how to#
This tutorial will show you how to create a custom World Generator, note that it is still under construction and more sections will be added.
