Updated Resources: spread functions (markdown)

Azgaar 2021-05-10 22:18:34 +03:00
parent 045d0cb36a
commit a08c3c3f2c

@ -1,11 +1,11 @@
# 🚧 Under construction
Resource **spread models** are applied to check whether resource can or cannot be placed in a cell. Fantasy Map Generator allows to create custom spread models, but it requires some understanding on how models work.
Resource **spread models** are applied to check whether resource can or cannot be placed in a cell. Fantasy Map Generator allows to create custom spread models, but it requires some understanding on how models work. Resources are generated before states and cultures, so models are built on top of geographical data. Once model is changed, you need to regenerate all resources.
# Technical info
Technically spread models are expressions evaluated for each cell to return `true` or `false`. If `true` is returned, the resource can be placed in the cell. The expressions are valid JS functions, you can use logical operators (`!` for not, `||` for OR, `&&` for and, etc.) and other features.
However the function is limited to a number of build-in functions. These functions make models syntax easier to read and write:
The options are limited to a number of build-in functions. These functions make models syntax easier to read and write:
* `random(number)`: percentage of true, e.g. `50` will return true in 50% of cases
* `nth(number)`: true for each nth cell only, e.g. `nth(2)` skips 50% of cells, `nth(5)` skips 80% of cells
* `habitable()`: true if biome habitability is greater than 0