Updated Resources: spread functions (markdown)

Azgaar 2021-05-09 03:11:10 +03:00
parent 4ea7abb56b
commit 2724b5b9af

@ -1,17 +1,22 @@
# 🚧 Under construction. The functionality and page are work in progress
Resource **spread models** are bits of JavaScript code applied for cell to check whether resource can or cannot be placed there. Fantasy Map Generator allows to create custom models, but they are not verified and can easily break the application. Someone else's code can be potentially be harmful as well. Please apply custom spread functions only if you know programming basics. Trusted and useful functions will be listed on this page.
# Technical info
Technically spread models are functional expressions evaluated for each cell to return a Boolean: `true` indicates that resource can be placed in cells and `false` indicates the opposite. The expressions are vanilla JS function, you can use any logical operators (`!` for not, `||` for OR, `&&` for and etc.) and other features.
Build-in functions make models syntax easier to read:
* `nth(number)`: true for each nth cell only, e.g. `nth(2)` will skip 50% of cells
* `biome(biomeId, biomeId, ...)`: check against biome id, see below to get id reference
Build-in functions make models syntax easier to read:
* `habitable()`: true if biome habitability >0
* `habitability()`: check against biome habitability. Always true for habitability `>=100`, false for `0`, skips 50% of cells if habitability is `50` and so on
* `biome(biomeId, biomeId, ...)`: check against biome id, see below to get biome id reference
* `minHeight(number)`: true if cell height >= number. Number is in range `[0-100]`, where `0` is deep ocean and `20` is minimal land elevation
* `maxHeight(number)`: true if cell height <= number
* `minTemp(number)`: true if cell temperature (in Celsius) >= number
* `maxTemp(number)`: true if cell temperature <= number
* `shore(number)`: check against cell distance to shore, where `1` is land next to water (coastline cells), `2` - next land ring, `-1` - water cells next to land (shallow water), `-2, -3, ...` - next water rings, `0` - value not assigned, usually values are assigned only for first 2 land rings, so other land cells have zero value
* `type(string)`: check against cell type. Types of all water cells connected to map border is `ocean`, lake types are `freshwater`, `salt`, `sinkhole`, `frozen`, `lava` and `dry`. Land types are defined not so clear, so I don't recommend to use them. In any case land types are `continent`, `island`, `isle` and `lake_island`
* `nth(number)`: true for each nth cell only, e.g. `nth(2)` skips 50% of cells, `nth(5)` skips 80% of cells
* `random(number)`: percentage of true, e.g. `50` will return true in 50% of cases
Default biome ids:
* 0: Marine