Modding:Content Tutorial Simple Worldgen: Difference between revisions

From Vintage Story Wiki
m
no edit summary
m (Start worldgen tutorial.)
mNo edit summary
Line 52: Line 52:
Block patches all follow a very similar two-part structure. First you define what you want to generate, including the block code and the quantity, and then you define the rules of it spawning, including things such as temperature, height, fertility, as well as the '<nowiki/>''chance''' of it spawning in a chunk.
Block patches all follow a very similar two-part structure. First you define what you want to generate, including the block code and the quantity, and then you define the rules of it spawning, including things such as temperature, height, fertility, as well as the '<nowiki/>''chance''' of it spawning in a chunk.


So, firstly you need to define what to generate. Using the ''blockCodes'' property, you can define an array of all the potential block types. When the generation process happens, one of these blocks will be picked randomly.
So, firstly you need to define what to generate. Using the ''blockCodes'' property, you can define an array of all the potential block types. When the generation process happens, one of these blocks will be picked randomly. In this case, just add the block code for loose sticks underneath the ''comment'' property.<syntaxhighlight lang="json">
"blockCodes": [ "game:loosestick-free" ],
</syntaxhighlight>Next, define a ''quantity.'' This is a ''NatFloat'' (''natural float)'' type - A specific type of random number generator that uses an average and a variable amount.<syntaxhighlight lang="json">
"quantity": {
"avg": 4,
"var": 2
},
</syntaxhighlight>NatFloats can be considerably more complex - However in this example it will return a value between (''avg - var)'' and ''(avg + var).'' In effect, this will pick a random number between 2 and 6, and generate that number of sticks in a localized group.
 
After you have defined what to spawn and how many of them to spawn in a single group, you can add a number of optional criteria for the block spawning.
 
The following properties will limit loose sticks from spawning in some areas:<syntaxhighlight lang="json">
"minTemp": -2,
"minForest": 0,
</syntaxhighlight>There are many more optional criteria that can be used. These include:
 
* ''MinTemp'' and ''MaxTemp''
* ''MinRain'' and ''MaxRain''
* ''MinForest'' and ''MaxForest''
* ''MinShrub'' and ''MaxShrub'' (for how much shrubbery and bushes are in the current area)
* ''MinFertility'' and ''MaxFertility''
* ''MinY'' and ''MaxY'' (for elevation, as a 0-1 decimal relative to the map height. A Y of 0 is the very bottom of the world, a Y of 1 is the world height, and a Y of around 0.43 is sea-level)
 
After adding in the optional criteria, you need to add in a ''chance'' property:<syntaxhighlight lang="json">
"chance": 3
</syntaxhighlight>This value effects how the chance of this rule spawning per chunk. The chance can be a decimal value. For example, a chance of 0.5 means there is a 50% chance per chunk that the blockpatch will be generated. A chance of 3 means that there will be 3 instances of this generating per chunk.


== Conclusion ==
== Conclusion ==
Confirmedusers
637

edits