Compare commits
49 Commits
b646a8e3e3
...
tahrion_te
| Author | SHA1 | Date | |
|---|---|---|---|
| cfa75bd8f3 | |||
| b08f808167 | |||
| eb69779b0d | |||
| b0fc925750 | |||
| e12b0d64e5 | |||
| efcee33a02 | |||
| ce778673c7 | |||
| 5ec4bdd933 | |||
| 6332f23bf3 | |||
| 966af2328a | |||
| d08ee33400 | |||
| ba97a8f36f | |||
| ef6c0d9fe6 | |||
| c3bdb29852 | |||
| 6904090d19 | |||
| f3c5beb341 | |||
| fc90ae54c0 | |||
| 0952e96452 | |||
| 19d6637a29 | |||
| 6fb06b7109 | |||
| d392414cb7 | |||
| 8c7aaefe09 | |||
| 1d1591accc | |||
| ec614e6080 | |||
| c32d324bfb | |||
| 37d759e48a | |||
| 4b9afcf97d | |||
| c9ce8e5f60 | |||
| b7124419e7 | |||
| 8742b86a44 | |||
| 79111b3cbd | |||
| 087a8eee86 | |||
| cb853778fe | |||
| bdd35af484 | |||
| 882165c9e7 | |||
| e294c34801 | |||
| b6e07d04e3 | |||
| 3d03477467 | |||
| c75e06d274 | |||
| 6d3e9af2f8 | |||
| cabe562dc4 | |||
| 43bee3dae0 | |||
| 4f4b268d3c | |||
| c2b0c54236 | |||
| 907230e67d | |||
| 03ce7983eb | |||
| e81e2141a6 | |||
| 3d0a906a59 | |||
| 18dbce95c0 |
218
docs/MapGen_docs.txt
Normal file
218
docs/MapGen_docs.txt
Normal file
@@ -0,0 +1,218 @@
|
||||
MapGen.PastCalcNoiseValue *MapGen.PastCalcNoiseValue*
|
||||
|
||||
Type: ~
|
||||
|
||||
|
||||
|
||||
MapGen *MapGen*
|
||||
|
||||
Fields: ~
|
||||
{layersByName} (table<string,MapGen.Layer>)
|
||||
{layersList} (MapGen.Layer[])
|
||||
{staticsByName} (table<string,MapGen.StaticLayer>)
|
||||
{staticsList} (MapGen.StaticLayer[])
|
||||
{layersNoisesInitialized} (boolean) Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
||||
{cavernsNoiseInitialized} (boolean) Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
||||
{isRunning} (boolean) A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||
{nodeIDs} (table<string,number>)
|
||||
|
||||
|
||||
MapGenDef *MapGenDef*
|
||||
Definition table for the `MapGen`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
Fields: ~
|
||||
{nodes} (table<string,string>)
|
||||
|
||||
|
||||
MapGen:new({def}) *MapGen:new*
|
||||
|
||||
Parameters: ~
|
||||
{def} (MapGenDef)
|
||||
|
||||
Returns: ~
|
||||
(MapGen)
|
||||
|
||||
|
||||
MapGen:getLayerByHeight({yPos}) *MapGen:getLayerByHeight*
|
||||
Determines which layer a node belongs to based on its height coordinate.
|
||||
|
||||
Parameters: ~
|
||||
{yPos} (number) @return MapGen.Layer?
|
||||
|
||||
|
||||
MapGen:getStaticByHeight({yPos}) *MapGen:getStaticByHeight*
|
||||
Determines which statics layer a node belongs to based on its height coordinate.
|
||||
|
||||
Parameters: ~
|
||||
{yPos} (number) @return MapGen.StaticLayer?
|
||||
|
||||
|
||||
MapGen:registerLayer({name}, {def}) *MapGen:registerLayer*
|
||||
Mark the world area between two heights as a `MapGen.Layer`.
|
||||
|
||||
Note: layers must not overlap.
|
||||
|
||||
Parameters: ~
|
||||
{name} (string) The name that will be assigned to the layer. The name must be unique for each layer.
|
||||
{def} (MapGen.LayerDef) Layer description table, see details `MapGen.LayerDef`.
|
||||
|
||||
|
||||
*MapGen:registerLayerNoiseColor*
|
||||
MapGen:registerLayerNoiseColor({layerName}, {category}, {color}, {noiseParams})
|
||||
Register the color and the noise parameters that correspond to it.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer for which the color will be registered.
|
||||
{category} (MapGen.Layer.Category) Category indicating what will be generated by noise.
|
||||
{color} (ColorString) Noise color. Must be unique.
|
||||
{noiseParams} (NoiseParams) Fractal noise parameters.
|
||||
|
||||
|
||||
*MapGen:registerStaticLayer*
|
||||
MapGen:registerStaticLayer({name}, {def})
|
||||
Mark the world area between two heights as a `MapGen.StaticLayer`.
|
||||
|
||||
Note: layers must not overlap.
|
||||
|
||||
Parameters: ~
|
||||
{name} (string) The name that will be assigned to the static layer. The name must be unique for each layer.
|
||||
{def} (MapGen.StaticLayerDef) Static layer description table, see details `MapGen.StaticLayerDef`.
|
||||
|
||||
|
||||
*MapGen:registerPeak*
|
||||
MapGen:registerPeak({layerName}, {category}, {def})
|
||||
Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer in which the new peak will be included.
|
||||
{category} (MapGen.Layer.Category) Category indicating what will be generated by peak.
|
||||
{def} (MapGen.PeakDef) Peak description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
*MapGen:register2DPeak*
|
||||
MapGen:register2DPeak({layerName}, {category}, {def})
|
||||
Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer in which the new peak will be included.
|
||||
{category} (MapGen.Layer.Category) Category indicating what will be generated by peak.
|
||||
{def} (MapGen.PeakDef) Peak description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
*MapGen:register2DPeaks*
|
||||
MapGen:register2DPeaks({layerName}, {category}, {defs})
|
||||
Mark the world points as `MapGen.Peak` and assign them all a specific noise that will affect generation.
|
||||
The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer in which the new peaks will be included.
|
||||
{category} (MapGen.Layer.Category) Category indicating what will be generated by peaks.
|
||||
{defs} (MapGen.PeakDef[]) Peaks description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
*MapGen:register2DPeaksFromFile*
|
||||
MapGen:register2DPeaksFromFile({layerName}, {map}, {scale}, {zeroPos}, {category}, {groups?})
|
||||
Extract the `MapGen.Peak` from the image and assign them all a specific color that will affect the generation.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer in which the new peaks will be included.
|
||||
{map} (string) The name of the image from which the peaks will be extracted. It should be located in the `<mod_name>/textures/maps` folder and have the following format `<image_name>.ff`
|
||||
{scale} (number) Multiplier of how many blocks (nodes) will be between image pixels. It is not recommended to set the value below 50 for performance reasons.
|
||||
{zeroPos} (Position2d) The position in pixels where the zero world coordinate will be in the image.
|
||||
{category} (MapGen.Layer.Category) Category indicating what will be generated by peaks.
|
||||
{groups?} (table<string,number>) Groups that will be added to all peaks.
|
||||
|
||||
|
||||
*MapGen:registerBiome*
|
||||
MapGen:registerBiome({layerName}, {biomeName}, {def})
|
||||
Mark a point on the biomes diagram and constrain the world area by height to mark it as `MapGen.Biome`.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer in which the new biome will be included.
|
||||
{biomeName} (string) The name to be assigned to the biome. The name must be unique for each biome.
|
||||
{def} (MapGen.BiomeDef) Biome description table, see details `MapGen.BiomeDef`
|
||||
|
||||
|
||||
*MapGen:registerCavern*
|
||||
MapGen:registerCavern({layerName}, {cavernName}, {def})
|
||||
Mark the world area between two heights as a `MapGen.Cavern` and assign the noise that the cave will be generated from.
|
||||
|
||||
Parameters: ~
|
||||
{layerName} (string) The name of the layer in which the new cavern will be included.
|
||||
{cavernName} (string) The name to be assigned to the cavern. The name must be unique for each cavern.
|
||||
{def} (MapGen.CavernDef) Cavern description table, see details `MapGen.CavernDef`
|
||||
|
||||
|
||||
MapGen:initLayersTriangultaion() *MapGen:initLayersTriangultaion*
|
||||
Divide all layers into triangles whose vertices are the `Mapgen.Peak` belonging to these layers.
|
||||
|
||||
|
||||
MapGen:initLayersNoises() *MapGen:initLayersNoises*
|
||||
Initialize all layer noises. This should be called after the map object is loaded.
|
||||
|
||||
|
||||
MapGen:initBiomesDiagram() *MapGen:initBiomesDiagram*
|
||||
Initialization of the biome diagram using the Voronoi method.
|
||||
|
||||
|
||||
MapGen:initCavernsNoise() *MapGen:initCavernsNoise*
|
||||
Initialize caverns's noises. This should be called after the map object is loaded.
|
||||
|
||||
|
||||
*MapGen:getNoises2dValue*
|
||||
MapGen:getNoises2dValue({category}, {layer}, {x}, {y}, {z})
|
||||
Calculates a smoothed 2D noise value based on a preliminary space partitioning.
|
||||
|
||||
Returns `nil` if the point is not included in any triangle.
|
||||
|
||||
Parameters: ~
|
||||
{category} (MapGen.Layer.Category)
|
||||
{layer} (MapGen.Layer)
|
||||
{x} (integer)
|
||||
{y} (integer)
|
||||
{z} (integer) @return number?
|
||||
|
||||
|
||||
*MapGen:getNoises3dValues*
|
||||
MapGen:getNoises3dValues({layer}, {x}, {y}, {z})
|
||||
Calculates a smoothed 3D noise value based on a preliminary space partitioning.
|
||||
|
||||
Returns `nil` if the point is not included in any tetrahedron.
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{layer} (MapGen.Layer)
|
||||
{x} (number)
|
||||
{y} (number)
|
||||
{z} (number) @return number?
|
||||
|
||||
|
||||
*MapGen:onMapGenerated*
|
||||
MapGen:onMapGenerated({voxelManip}, {minPos}, {maxPos}, {blockseed})
|
||||
Chunk generation handler.
|
||||
|
||||
Parameters: ~
|
||||
{voxelManip} (VoxelManip)
|
||||
{minPos} (Position)
|
||||
{maxPos} (Position)
|
||||
{blockseed} (number)
|
||||
|
||||
|
||||
MapGen:run() *MapGen:run*
|
||||
Run world generation through this mapgen object
|
||||
|
||||
Note: only one instance of a `MapGen` class can be running.
|
||||
|
||||
**FOR MAPGEN ENVIRONMENT ONLY**
|
||||
|
||||
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
54
docs/docs/index.md
Normal file
54
docs/docs/index.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# index
|
||||
|
||||
|
||||
## Types
|
||||
|
||||
- [alias Category](types/MapGen.Layer.Category.md)
|
||||
- [alias CircumCircleEnum](types/MapGen.Triangle.CircumCircleEnum.md)
|
||||
- [alias ColoredDotsTable](types/ColoredDotsTable.md)
|
||||
- [alias Neighbours](types/MapGen.Triangle.Neighbours.md)
|
||||
- [alias PastCalcNoiseValue](types/MapGen.PastCalcNoiseValue.md)
|
||||
- [alias generateFunc](types/generateFunc.md)
|
||||
- [class Biome](types/MapGen.Biome.md)
|
||||
- [class BiomeDef](types/MapGen.BiomeDef.md)
|
||||
- [class Cavern](types/MapGen.Cavern.md)
|
||||
- [class CavernDef](types/MapGen.CavernDef.md)
|
||||
- [class Decoration](types/MapGen.Decoration.md)
|
||||
- [class Edge](types/MapGen.Triangulation.Edge.md)
|
||||
- [class FakePeak](types/MapGen.Triangulation.FakePeak.md)
|
||||
- [class GroundNodes](types/MapGen.Biome.GroundNodes.md)
|
||||
- [class GroundNodesIDs](types/MapGen.Biome.GroundNodesIDs.md)
|
||||
- [class Layer](types/MapGen.Layer.md)
|
||||
- [class LayerDef](types/MapGen.LayerDef.md)
|
||||
- [class MapGen](types/MapGen.md)
|
||||
- [class MapGenDef](types/MapGenDef.md)
|
||||
- [class Peak](types/MapGen.Peak.md)
|
||||
- [class PeakDef](types/MapGen.PeakDef.md)
|
||||
- [class StaticLayer](types/MapGen.StaticLayer.md)
|
||||
- [class StaticLayerDef](types/MapGen.StaticLayerDef.md)
|
||||
- [class Tetrahedron](types/MapGen.Tetrahedron.md)
|
||||
- [class Triangle](types/MapGen.Triangle.md)
|
||||
- [class Triangulation](types/MapGen.Triangulation.md)
|
||||
|
||||
|
||||
|
||||
## Modules
|
||||
- [MapGen](modules/MapGen.md)
|
||||
- [MapGen.Biome](modules/MapGen.Biome.md)
|
||||
- [MapGen.Biome.GroundNodes](modules/MapGen.Biome.GroundNodes.md)
|
||||
- [MapGen.Biome.GroundNodesIds](modules/MapGen.Biome.GroundNodesIds.md)
|
||||
- [MapGen.Cavern](modules/MapGen.Cavern.md)
|
||||
- [MapGen.Decoration](modules/MapGen.Decoration.md)
|
||||
- [MapGen.Layer](modules/MapGen.Layer.md)
|
||||
- [MapGen.Peak](modules/MapGen.Peak.md)
|
||||
- [MapGen.StaticLayer](modules/MapGen.StaticLayer.md)
|
||||
- [MapGen.Tetrahedron](modules/MapGen.Tetrahedron.md)
|
||||
- [MapGen.Triangle](modules/MapGen.Triangle.md)
|
||||
- [MapGen.Triangulation](modules/MapGen.Triangulation.md)
|
||||
- [MapGen.Triangulation.Edge](modules/MapGen.Triangulation.Edge.md)
|
||||
- [MapGen.Triangulation.FakePeak](modules/MapGen.Triangulation.FakePeak.md)
|
||||
- [MapGen.ff2luat](modules/MapGen.ff2luat.md)
|
||||
|
||||
|
||||
|
||||
|
||||
85
docs/docs/modules/MapGen.Biome.GroundNodes.md
Normal file
85
docs/docs/modules/MapGen.Biome.GroundNodes.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# global MapGen.Biome.GroundNodes
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### GroundNodes.turf
|
||||
---
|
||||
```lua
|
||||
GroundNodes.turf : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil covering the surface of the biome
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodes.soil
|
||||
---
|
||||
```lua
|
||||
GroundNodes.soil : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil beneath the turf. The height of this layer depends on `Biome.soilHeight`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodes.rock
|
||||
---
|
||||
```lua
|
||||
GroundNodes.rock : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
The rock found beneath the soil of a biome.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodes.bottom
|
||||
---
|
||||
```lua
|
||||
GroundNodes.bottom : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
Covering the bottom of reservoirs.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
85
docs/docs/modules/MapGen.Biome.GroundNodesIds.md
Normal file
85
docs/docs/modules/MapGen.Biome.GroundNodesIds.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# global MapGen.Biome.GroundNodesIds
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### GroundNodesIDs.turf
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.turf : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil covering the surface of the biome
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodesIDs.soil
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.soil : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil beneath the turf. The height of this layer depends on `Biome.soilHeight`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodesIDs.rock
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.rock : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
The rock found beneath the soil of a biome.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodesIDs.bottom
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.bottom : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
Covering the bottom of reservoirs.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
307
docs/docs/modules/MapGen.Biome.md
Normal file
307
docs/docs/modules/MapGen.Biome.md
Normal file
@@ -0,0 +1,307 @@
|
||||
# global MapGen.Biome
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Biome.new
|
||||
---
|
||||
```lua
|
||||
function Biome.new(
|
||||
name: string,
|
||||
def: MapGen.BiomeDef {
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc?,
|
||||
generateCavernAir = generateFunc?,
|
||||
generateWater = generateFunc?,
|
||||
generateRock = generateFunc?,
|
||||
generateTurf = generateFunc?,
|
||||
generateSoil = generateFunc?,
|
||||
generateBottom = generateFunc?,
|
||||
}
|
||||
) -> MapGen.Biome {
|
||||
name = string,
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
groundNodesIDs = MapGen.Biome.GroundNodesIDs,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc,
|
||||
generateCavernAir = generateFunc,
|
||||
generateWater = generateFunc,
|
||||
generateRock = generateFunc,
|
||||
generateTurf = generateFunc,
|
||||
generateSoil = generateFunc,
|
||||
generateBottom = generateFunc,
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Biome.name
|
||||
---
|
||||
```lua
|
||||
Biome.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.tempPoint
|
||||
---
|
||||
```lua
|
||||
Biome.tempPoint : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.humidityPoint
|
||||
---
|
||||
```lua
|
||||
Biome.humidityPoint : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.minY
|
||||
---
|
||||
```lua
|
||||
Biome.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.maxY
|
||||
---
|
||||
```lua
|
||||
Biome.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.groundNodes
|
||||
---
|
||||
```lua
|
||||
Biome.groundNodes : MapGen.Biome.GroundNodes {
|
||||
turf: string,
|
||||
soil: string,
|
||||
rock: string,
|
||||
bottom: string,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.groundNodesIDs
|
||||
---
|
||||
```lua
|
||||
Biome.groundNodesIDs : MapGen.Biome.GroundNodesIDs {
|
||||
turf: number,
|
||||
soil: number,
|
||||
rock: number,
|
||||
bottom: number,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.soilHeight
|
||||
---
|
||||
```lua
|
||||
Biome.soilHeight : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateAir
|
||||
---
|
||||
```lua
|
||||
Biome.generateAir : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateCavernAir
|
||||
---
|
||||
```lua
|
||||
Biome.generateCavernAir : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateWater
|
||||
---
|
||||
```lua
|
||||
Biome.generateWater : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateRock
|
||||
---
|
||||
```lua
|
||||
Biome.generateRock : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateTurf
|
||||
---
|
||||
```lua
|
||||
Biome.generateTurf : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateSoil
|
||||
---
|
||||
```lua
|
||||
Biome.generateSoil : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateBottom
|
||||
---
|
||||
```lua
|
||||
Biome.generateBottom : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
203
docs/docs/modules/MapGen.Cavern.md
Normal file
203
docs/docs/modules/MapGen.Cavern.md
Normal file
@@ -0,0 +1,203 @@
|
||||
# global MapGen.Cavern
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Cavern.getNoise
|
||||
---
|
||||
```lua
|
||||
function Cavern.getNoise()-> ValueNoise
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.initNoise
|
||||
---
|
||||
```lua
|
||||
function Cavern.initNoise()-> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.getGroups
|
||||
---
|
||||
```lua
|
||||
function Cavern.getGroups()
|
||||
-> table<string,number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.new
|
||||
---
|
||||
```lua
|
||||
function Cavern.new(
|
||||
name: string,
|
||||
def: MapGen.CavernDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
noiseParams = NoiseParams,
|
||||
smoothDistance = number,
|
||||
threshold = number?,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> MapGen.Cavern {
|
||||
name = string,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
smoothDistance = number,
|
||||
threshold = number,
|
||||
getNoise = function,
|
||||
initNoise = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
isCavern = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.isCavern
|
||||
---
|
||||
```lua
|
||||
function Cavern.isCavern(
|
||||
x: integer,
|
||||
y: integer,
|
||||
z: integer
|
||||
) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns `true` if there is a cavern at the specified coordinates.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Cavern.name
|
||||
---
|
||||
```lua
|
||||
Cavern.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.minY
|
||||
---
|
||||
```lua
|
||||
Cavern.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.maxY
|
||||
---
|
||||
```lua
|
||||
Cavern.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.smoothDistance
|
||||
---
|
||||
```lua
|
||||
Cavern.smoothDistance : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.threshold
|
||||
---
|
||||
```lua
|
||||
Cavern.threshold : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
36
docs/docs/modules/MapGen.Decoration.md
Normal file
36
docs/docs/modules/MapGen.Decoration.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# global MapGen.Decoration
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Decoration.new
|
||||
---
|
||||
```lua
|
||||
function Decoration.new() -> MapGen.Decoration {
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
673
docs/docs/modules/MapGen.Layer.md
Normal file
673
docs/docs/modules/MapGen.Layer.md
Normal file
@@ -0,0 +1,673 @@
|
||||
# global MapGen.Layer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Layer.calcTemp
|
||||
---
|
||||
```lua
|
||||
function Layer.calcTemp(
|
||||
self: MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
},
|
||||
value: number,
|
||||
height: number
|
||||
)-> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.calcHumidity
|
||||
---
|
||||
```lua
|
||||
function Layer.calcHumidity(
|
||||
self: MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
},
|
||||
value: number,
|
||||
height: number
|
||||
)-> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.new
|
||||
---
|
||||
```lua
|
||||
function Layer.new(
|
||||
name: string,
|
||||
def: MapGen.LayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
minTemp = number,
|
||||
maxTemp = number,
|
||||
minHumidity = number,
|
||||
maxHumidity = number,
|
||||
waterLevel = number?,
|
||||
calcTemp = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
calcHumidity = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
biomesGorizontalScattering = number?,
|
||||
biomesVerticalScattering = number?,
|
||||
}
|
||||
) -> MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addPeak
|
||||
---
|
||||
```lua
|
||||
function Layer.addPeak(
|
||||
category: MapGen.Layer.Category,
|
||||
peak: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a peak to the `Layer.peaksList`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addNoiseParamsColor
|
||||
---
|
||||
```lua
|
||||
function Layer.addNoiseParamsColor(
|
||||
category: MapGen.Layer.Category,
|
||||
color: ColorString,
|
||||
noiseParams: NoiseParams
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a NoiseParams color to the `Layer.noisesParamsByColor`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.getNoiseByColor
|
||||
---
|
||||
```lua
|
||||
function Layer.getNoiseByColor(
|
||||
category: MapGen.Layer.Category,
|
||||
color: ColorString
|
||||
) -> ValueNoise
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns noise corresponding to a color.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addBiome
|
||||
---
|
||||
```lua
|
||||
function Layer.addBiome(
|
||||
biomeName: string,
|
||||
biome: MapGen.Biome {
|
||||
name = string,
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
groundNodesIDs = MapGen.Biome.GroundNodesIDs,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc,
|
||||
generateCavernAir = generateFunc,
|
||||
generateWater = generateFunc,
|
||||
generateRock = generateFunc,
|
||||
generateTurf = generateFunc,
|
||||
generateSoil = generateFunc,
|
||||
generateBottom = generateFunc,
|
||||
new = function,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a biome to the `Layer.biomesByName` & `Layer.biomesList`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addCavern
|
||||
---
|
||||
```lua
|
||||
function Layer.addCavern(
|
||||
cavernName: string,
|
||||
cavern: MapGen.Cavern {
|
||||
name = string,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
smoothDistance = number,
|
||||
threshold = number,
|
||||
getNoise = function,
|
||||
initNoise = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
isCavern = function,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a cavern to the `Layer.cavernsByName` & `Layer.cavernsList`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.initNoises
|
||||
---
|
||||
```lua
|
||||
function Layer.initNoises() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initializes noise for generation.
|
||||
|
||||
Should only be called after the mapgen object has been loaded.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.initBiomesDiagram
|
||||
---
|
||||
```lua
|
||||
function Layer.initBiomesDiagram() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialization of the biome diagram using the Voronoi method.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Layer.name
|
||||
---
|
||||
```lua
|
||||
Layer.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.minY
|
||||
---
|
||||
```lua
|
||||
Layer.minY : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.maxY
|
||||
---
|
||||
```lua
|
||||
Layer.maxY : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.minTemp
|
||||
---
|
||||
```lua
|
||||
Layer.minTemp : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.maxTemp
|
||||
---
|
||||
```lua
|
||||
Layer.maxTemp : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.minHumidity
|
||||
---
|
||||
```lua
|
||||
Layer.minHumidity : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.maxHumidity
|
||||
---
|
||||
```lua
|
||||
Layer.maxHumidity : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.waterLevel
|
||||
---
|
||||
```lua
|
||||
Layer.waterLevel : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.peaksList
|
||||
---
|
||||
```lua
|
||||
Layer.peaksList : { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.noisesByColor
|
||||
---
|
||||
```lua
|
||||
Layer.noisesByColor : { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.noisesParamsByColor
|
||||
---
|
||||
```lua
|
||||
Layer.noisesParamsByColor : { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesByName
|
||||
---
|
||||
```lua
|
||||
Layer.biomesByName : table<string,MapGen.Biome>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesList
|
||||
---
|
||||
```lua
|
||||
Layer.biomesList : MapGen.Biome[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesDiagram
|
||||
---
|
||||
```lua
|
||||
Layer.biomesDiagram : table
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesGorizontalScattering
|
||||
---
|
||||
```lua
|
||||
Layer.biomesGorizontalScattering : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesVerticalScattering
|
||||
---
|
||||
```lua
|
||||
Layer.biomesVerticalScattering : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.cavernsByName
|
||||
---
|
||||
```lua
|
||||
Layer.cavernsByName : table<string,MapGen.Cavern>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.cavernsList
|
||||
---
|
||||
```lua
|
||||
Layer.cavernsList : MapGen.Cavern[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.trianglesList
|
||||
---
|
||||
```lua
|
||||
Layer.trianglesList : { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.tetrahedronsList
|
||||
---
|
||||
```lua
|
||||
Layer.tetrahedronsList : MapGen.Tetrahedron[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
**Not supported**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
157
docs/docs/modules/MapGen.Peak.md
Normal file
157
docs/docs/modules/MapGen.Peak.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# global MapGen.Peak
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Peak.getPeakPos
|
||||
---
|
||||
```lua
|
||||
function Peak.getPeakPos(self)-> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.getColor
|
||||
---
|
||||
```lua
|
||||
function Peak.getColor(self)-> ColorString
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.getGroups
|
||||
---
|
||||
```lua
|
||||
function Peak.getGroups(self)
|
||||
-> table<string,number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.new
|
||||
---
|
||||
```lua
|
||||
function Peak.new(def: MapGen.PeakDef {
|
||||
pos = vector,
|
||||
color = ColorString,
|
||||
groups = table<string,number>?,
|
||||
}) -> MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.toString
|
||||
---
|
||||
```lua
|
||||
function Peak.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.eq
|
||||
---
|
||||
```lua
|
||||
function Peak.eq(other: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the peaks are equivalent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Peak.id
|
||||
---
|
||||
```lua
|
||||
Peak.id : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
144
docs/docs/modules/MapGen.StaticLayer.md
Normal file
144
docs/docs/modules/MapGen.StaticLayer.md
Normal file
@@ -0,0 +1,144 @@
|
||||
# global MapGen.StaticLayer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### StaticLayer.new
|
||||
---
|
||||
```lua
|
||||
function StaticLayer.new(
|
||||
name: string,
|
||||
def: MapGen.StaticLayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
staticNode = string,
|
||||
generateStaticNode = generateFunc,
|
||||
}
|
||||
) -> MapGen.StaticLayer {
|
||||
name = string,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
staticNode = string,
|
||||
staticNodeID = number,
|
||||
generateStaticNode = generateFunc,
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### StaticLayer.name
|
||||
---
|
||||
```lua
|
||||
StaticLayer.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.minY
|
||||
---
|
||||
```lua
|
||||
StaticLayer.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.maxY
|
||||
---
|
||||
```lua
|
||||
StaticLayer.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.staticNode
|
||||
---
|
||||
```lua
|
||||
StaticLayer.staticNode : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.staticNodeID
|
||||
---
|
||||
```lua
|
||||
StaticLayer.staticNodeID : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.generateStaticNode
|
||||
---
|
||||
```lua
|
||||
StaticLayer.generateStaticNode : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
536
docs/docs/modules/MapGen.Tetrahedron.md
Normal file
536
docs/docs/modules/MapGen.Tetrahedron.md
Normal file
@@ -0,0 +1,536 @@
|
||||
# global MapGen.Tetrahedron
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Tetrahedron.new
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.new(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p4: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Tetrahedron {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
p4 = MapGen.Peak,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
h4 = MapGen.Triangulation.Edge,
|
||||
f1 = MapGen.Triangle,
|
||||
f2 = MapGen.Triangle,
|
||||
f3 = MapGen.Triangle,
|
||||
f4 = MapGen.Triangle,
|
||||
new = function,
|
||||
toString = function,
|
||||
getHeight = function,
|
||||
getCircumSphereCenter = function,
|
||||
getCircumSphereRadius = function,
|
||||
inCircumSphere = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.toString
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.getHeight
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.getHeight(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p4: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.getCircumSphereCenter
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.getCircumSphereCenter() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the center of the circumscribed sphere.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.getCircumSphereRadius
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.getCircumSphereRadius() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the radius of the circumscribed sphere.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.inCircumSphere
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.inCircumSphere(p: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Checks whether a given point lies within the circumscribed sphere of a tetrahedron.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Tetrahedron.p1
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p1 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.p2
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p2 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.p3
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p3 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.p4
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p4 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h1
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h1 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h2
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h2 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h3
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h3 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h4
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h4 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f1
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f1 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f2
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f2 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f3
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f3 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f4
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f4 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
745
docs/docs/modules/MapGen.Triangle.md
Normal file
745
docs/docs/modules/MapGen.Triangle.md
Normal file
@@ -0,0 +1,745 @@
|
||||
# global MapGen.Triangle
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Triangle.new
|
||||
---
|
||||
```lua
|
||||
function Triangle.new(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangle {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
e1 = MapGen.Triangulation.Edge,
|
||||
e2 = MapGen.Triangulation.Edge,
|
||||
e3 = MapGen.Triangulation.Edge,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
neighbours = MapGen.Triangle.Neighbours,
|
||||
color = ColorString?,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
getCenter = function,
|
||||
getArea = function,
|
||||
getHeight = function,
|
||||
getHeight2D = function,
|
||||
getSidesLength = function,
|
||||
getSidesLength2D = function,
|
||||
getCircumCenter2D = function,
|
||||
getCircumRadius2D = function,
|
||||
getCircumCircle2D = function,
|
||||
inCircumCircle2D = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.toString
|
||||
---
|
||||
```lua
|
||||
function Triangle.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.eq
|
||||
---
|
||||
```lua
|
||||
function Triangle.eq(other: MapGen.Triangle {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
e1 = MapGen.Triangulation.Edge,
|
||||
e2 = MapGen.Triangulation.Edge,
|
||||
e3 = MapGen.Triangulation.Edge,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
neighbours = MapGen.Triangle.Neighbours,
|
||||
color = ColorString?,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
getCenter = function,
|
||||
getArea = function,
|
||||
getHeight = function,
|
||||
getHeight2D = function,
|
||||
getSidesLength = function,
|
||||
getSidesLength2D = function,
|
||||
getCircumCenter2D = function,
|
||||
getCircumRadius2D = function,
|
||||
getCircumCircle2D = function,
|
||||
inCircumCircle2D = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the triangles are equivalent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.same
|
||||
---
|
||||
```lua
|
||||
function Triangle.same(other: MapGen.Triangle {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
e1 = MapGen.Triangulation.Edge,
|
||||
e2 = MapGen.Triangulation.Edge,
|
||||
e3 = MapGen.Triangulation.Edge,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
neighbours = MapGen.Triangle.Neighbours,
|
||||
color = ColorString?,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
getCenter = function,
|
||||
getArea = function,
|
||||
getHeight = function,
|
||||
getHeight2D = function,
|
||||
getSidesLength = function,
|
||||
getSidesLength2D = function,
|
||||
getCircumCenter2D = function,
|
||||
getCircumRadius2D = function,
|
||||
getCircumCircle2D = function,
|
||||
inCircumCircle2D = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the triangles are similar.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCenter
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCenter() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the coordinates of the triangle's center.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getArea
|
||||
---
|
||||
```lua
|
||||
function Triangle.getArea() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the area of a triangle.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getHeight
|
||||
---
|
||||
```lua
|
||||
function Triangle.getHeight(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the perpendicular from the vertex Peak1 to the line Peak2-Peak3.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getHeight2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getHeight2D(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the perpendicular from the vertex Peak1 to the line Peak2-Peak3.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getSidesLength
|
||||
---
|
||||
```lua
|
||||
function Triangle.getSidesLength()
|
||||
-> number
|
||||
-> number
|
||||
-> number
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the length of the edges
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getSidesLength2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getSidesLength2D()
|
||||
-> number
|
||||
-> number
|
||||
-> number
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the length of the edges.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCircumCenter2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCircumCenter2D() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the coordinates of the circumcircle center.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCircumRadius2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCircumRadius2D() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the radius of the circumcircle.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCircumCircle2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCircumCircle2D()
|
||||
-> vector
|
||||
-> number
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the coordinates of the circumcircle center and its radius.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.inCircumCircle2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.inCircumCircle2D(p: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Checks if a given point lies into the triangle circumcircle.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Triangle.p1
|
||||
---
|
||||
```lua
|
||||
Triangle.p1 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.p2
|
||||
---
|
||||
```lua
|
||||
Triangle.p2 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.p3
|
||||
---
|
||||
```lua
|
||||
Triangle.p3 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.e1
|
||||
---
|
||||
```lua
|
||||
Triangle.e1 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.e2
|
||||
---
|
||||
```lua
|
||||
Triangle.e2 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.e3
|
||||
---
|
||||
```lua
|
||||
Triangle.e3 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.h1
|
||||
---
|
||||
```lua
|
||||
Triangle.h1 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.h2
|
||||
---
|
||||
```lua
|
||||
Triangle.h2 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.h3
|
||||
---
|
||||
```lua
|
||||
Triangle.h3 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.neighbours
|
||||
---
|
||||
```lua
|
||||
Triangle.neighbours : MapGen.Triangle.Neighbours
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.color
|
||||
---
|
||||
```lua
|
||||
Triangle.color : ColorString?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
225
docs/docs/modules/MapGen.Triangulation.Edge.md
Normal file
225
docs/docs/modules/MapGen.Triangulation.Edge.md
Normal file
@@ -0,0 +1,225 @@
|
||||
# global MapGen.Triangulation.Edge
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Edge.new
|
||||
---
|
||||
```lua
|
||||
function Edge.new(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.toString
|
||||
---
|
||||
```lua
|
||||
function Edge.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.eq
|
||||
---
|
||||
```lua
|
||||
function Edge.eq(other: MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the edges are equivalent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.same
|
||||
---
|
||||
```lua
|
||||
function Edge.same(other: MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the edges are similar.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.length
|
||||
---
|
||||
```lua
|
||||
function Edge.length() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the length of an edge.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.getMidPoint
|
||||
---
|
||||
```lua
|
||||
function Edge.getMidPoint() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the vector of the point located in the middle of the edge.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Edge.p1
|
||||
---
|
||||
```lua
|
||||
Edge.p1 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.p2
|
||||
---
|
||||
```lua
|
||||
Edge.p2 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
79
docs/docs/modules/MapGen.Triangulation.FakePeak.md
Normal file
79
docs/docs/modules/MapGen.Triangulation.FakePeak.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# global MapGen.Triangulation.FakePeak
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### FakePeak.getPeakPos
|
||||
---
|
||||
```lua
|
||||
function FakePeak.getPeakPos()-> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### FakePeak.new
|
||||
---
|
||||
```lua
|
||||
function FakePeak.new(peakPos: vector) -> MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a fake `MapGen.Peak` that has no noise parameters.
|
||||
Note that the initialized peak should not be used in generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### FakePeak.id
|
||||
---
|
||||
```lua
|
||||
FakePeak.id : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
81
docs/docs/modules/MapGen.Triangulation.md
Normal file
81
docs/docs/modules/MapGen.Triangulation.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# global MapGen.Triangulation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Triangulation.triangulate
|
||||
---
|
||||
```lua
|
||||
function Triangulation.triangulate(vertices: table<integer,MapGen.Peak>) -> ((MapGen.Triangle)|MapGen.Triangle[])
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The Delaunay method divides a plane into triangles based on a list of their vertices.
|
||||
|
||||
Doesn't take into account the Y coordinate of the vertices.
|
||||
That is, all triangles that don't lie in the XZ plane will be projected onto it.
|
||||
|
||||
Vertices that do not have a `is2d` group will not participate in the triangulation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangulation.tetrahedralize
|
||||
---
|
||||
```lua
|
||||
function Triangulation.tetrahedralize(vertices: table<integer,MapGen.Peak>) -> ((MapGen.Tetrahedron)|MapGen.Tetrahedron[])
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The Delaunay method divides space into tetrahedra based on a list of their vertices.
|
||||
|
||||
Vertices that do not have a `is3d` group will not participate in the triangulation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Triangulation.convexMultiplier
|
||||
---
|
||||
```lua
|
||||
Triangulation.convexMultiplier : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
30
docs/docs/modules/MapGen.ff2luat.md
Normal file
30
docs/docs/modules/MapGen.ff2luat.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# global MapGen.ff2luat
|
||||
|
||||
|
||||
Converts given farbfeld image to ColoredDotsTable.
|
||||
Farbfeld format:
|
||||
```
|
||||
╔════════╤═════════════════════════════════════════════════════════╗
|
||||
║ Bytes │ Description ║
|
||||
╠════════╪═════════════════════════════════════════════════════════╣
|
||||
║ 8 │ 'farbfeld' magic value ║
|
||||
╟────────┼─────────────────────────────────────────────────────────╢
|
||||
║ 4 │ 32-Bit BE unsigned integer (width) ║
|
||||
╟────────┼─────────────────────────────────────────────────────────╢
|
||||
║ 4 │ 32-Bit BE unsigned integer (height) ║
|
||||
╟────────┼─────────────────────────────────────────────────────────╢
|
||||
║ [2222] │ 4x16-Bit BE unsigned integers [RGBA] / pixel, row-major ║
|
||||
╚════════╧═════════════════════════════════════════════════════════╝
|
||||
```
|
||||
[tools/farbfeld | suckless.org software that sucks less](https://tools.suckless.org/farbfeld/)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
738
docs/docs/modules/MapGen.md
Normal file
738
docs/docs/modules/MapGen.md
Normal file
@@ -0,0 +1,738 @@
|
||||
# global MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### MapGen.new
|
||||
---
|
||||
```lua
|
||||
function MapGen.new(def: MapGenDef {
|
||||
nodes = table<string,string>,
|
||||
}) -> MapGen {
|
||||
layersByName = table<string,MapGen.Layer>,
|
||||
layersList = MapGen.Layer[],
|
||||
staticsByName = table<string,MapGen.StaticLayer>,
|
||||
staticsList = MapGen.StaticLayer[],
|
||||
layersNoisesInitialized = boolean,
|
||||
cavernsNoiseInitialized = boolean,
|
||||
isRunning = boolean,
|
||||
nodeIDs = table<string,number>,
|
||||
new = function,
|
||||
getLayerByHeight = function,
|
||||
getStaticByHeight = function,
|
||||
registerLayer = function,
|
||||
registerLayerNoiseColor = function,
|
||||
registerStaticLayer = function,
|
||||
registerPeak = function,
|
||||
register2DPeak = function,
|
||||
register2DPeaks = function,
|
||||
register2DPeaksFromFile = function,
|
||||
registerBiome = function,
|
||||
registerCavern = function,
|
||||
initLayersTriangultaion = function,
|
||||
initLayersNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
initCavernsNoise = function,
|
||||
getNoises2dValue = function,
|
||||
onMapGenerated = function,
|
||||
run = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.getLayerByHeight
|
||||
---
|
||||
```lua
|
||||
function MapGen.getLayerByHeight(yPos: number) -> MapGen.Layer?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Determines which layer a node belongs to based on its height coordinate.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.getStaticByHeight
|
||||
---
|
||||
```lua
|
||||
function MapGen.getStaticByHeight(yPos: number) -> MapGen.StaticLayer?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Determines which statics layer a node belongs to based on its height coordinate.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerLayer
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerLayer(
|
||||
name: string,
|
||||
def: MapGen.LayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
minTemp = number,
|
||||
maxTemp = number,
|
||||
minHumidity = number,
|
||||
maxHumidity = number,
|
||||
waterLevel = number?,
|
||||
calcTemp = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
calcHumidity = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
biomesGorizontalScattering = number?,
|
||||
biomesVerticalScattering = number?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `name` - The name that will be assigned to the layer. The name must be unique for each layer.
|
||||
|
||||
@param `def` - Layer description table, see details `MapGen.LayerDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world area between two heights as a `MapGen.Layer`.
|
||||
|
||||
Note: layers must not overlap.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerLayerNoiseColor
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerLayerNoiseColor(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
color: ColorString,
|
||||
noiseParams: NoiseParams
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer for which the color will be registered.
|
||||
|
||||
@param `category` - Category indicating what will be generated by noise.
|
||||
|
||||
@param `color` - Noise color. Must be unique.
|
||||
|
||||
@param `noiseParams` - Fractal noise parameters.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Register the color and the noise parameters that correspond to it.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerStaticLayer
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerStaticLayer(
|
||||
name: string,
|
||||
def: MapGen.StaticLayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
staticNode = string,
|
||||
generateStaticNode = generateFunc,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `name` - The name that will be assigned to the static layer. The name must be unique for each layer.
|
||||
|
||||
@param `def` - Static layer description table, see details `MapGen.StaticLayerDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world area between two heights as a `MapGen.StaticLayer`.
|
||||
|
||||
Note: layers must not overlap.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerPeak
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerPeak(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
def: MapGen.PeakDef {
|
||||
pos = vector,
|
||||
color = ColorString,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peak will be included.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peak.
|
||||
|
||||
@param `def` - Peak description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.register2DPeak
|
||||
---
|
||||
```lua
|
||||
function MapGen.register2DPeak(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
def: MapGen.PeakDef {
|
||||
pos = vector,
|
||||
color = ColorString,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peak will be included.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peak.
|
||||
|
||||
@param `def` - Peak description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.register2DPeaks
|
||||
---
|
||||
```lua
|
||||
function MapGen.register2DPeaks(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
defs: MapGen.PeakDef[]
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peaks will be included.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peaks.
|
||||
|
||||
@param `defs` - Peaks description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world points as `MapGen.Peak` and assign them all a specific noise that will affect generation.
|
||||
The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.register2DPeaksFromFile
|
||||
---
|
||||
```lua
|
||||
function MapGen.register2DPeaksFromFile(
|
||||
layerName: string,
|
||||
map: string,
|
||||
scale: number,
|
||||
zeroPos: Position2d,
|
||||
category: MapGen.Layer.Category,
|
||||
groups: table<string,number>?
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peaks will be included.
|
||||
|
||||
@param `map` - The name of the image from which the peaks will be extracted. It should be located in the `<mod_name>/textures/maps` folder and have the following format `<image_name>.ff`
|
||||
|
||||
@param `scale` - Multiplier of how many blocks (nodes) will be between image pixels. It is not recommended to set the value below 50 for performance reasons.
|
||||
|
||||
@param `zeroPos` - The position in pixels where the zero world coordinate will be in the image.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peaks.
|
||||
|
||||
@param `groups` - Groups that will be added to all peaks.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Extract the `MapGen.Peak` from the image and assign them all a specific color that will affect the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerBiome
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerBiome(
|
||||
layerName: string,
|
||||
biomeName: string,
|
||||
def: MapGen.BiomeDef {
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc?,
|
||||
generateCavernAir = generateFunc?,
|
||||
generateWater = generateFunc?,
|
||||
generateRock = generateFunc?,
|
||||
generateTurf = generateFunc?,
|
||||
generateSoil = generateFunc?,
|
||||
generateBottom = generateFunc?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new biome will be included.
|
||||
|
||||
@param `biomeName` - The name to be assigned to the biome. The name must be unique for each biome.
|
||||
|
||||
@param `def` - Biome description table, see details `MapGen.BiomeDef`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark a point on the biomes diagram and constrain the world area by height to mark it as `MapGen.Biome`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerCavern
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerCavern(
|
||||
layerName: string,
|
||||
cavernName: string,
|
||||
def: MapGen.CavernDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
noiseParams = NoiseParams,
|
||||
smoothDistance = number,
|
||||
threshold = number?,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new cavern will be included.
|
||||
|
||||
@param `cavernName` - The name to be assigned to the cavern. The name must be unique for each cavern.
|
||||
|
||||
@param `def` - Cavern description table, see details `MapGen.CavernDef`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world area between two heights as a `MapGen.Cavern` and assign the noise that the cave will be generated from.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initLayersTriangultaion
|
||||
---
|
||||
```lua
|
||||
function MapGen.initLayersTriangultaion() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Divide all layers into triangles whose vertices are the `Mapgen.Peak` belonging to these layers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initLayersNoises
|
||||
---
|
||||
```lua
|
||||
function MapGen.initLayersNoises() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialize all layer noises. This should be called after the map object is loaded.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initBiomesDiagram
|
||||
---
|
||||
```lua
|
||||
function MapGen.initBiomesDiagram() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialization of the biome diagram using the Voronoi method.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initCavernsNoise
|
||||
---
|
||||
```lua
|
||||
function MapGen.initCavernsNoise() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialize caverns's noises. This should be called after the map object is loaded.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.getNoises2dValue
|
||||
---
|
||||
```lua
|
||||
function MapGen.getNoises2dValue(
|
||||
category: MapGen.Layer.Category,
|
||||
layer: MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
},
|
||||
x: integer,
|
||||
y: integer,
|
||||
z: integer
|
||||
) -> number?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Calculates a smoothed 2D noise value based on a preliminary space partitioning.
|
||||
|
||||
Returns `nil` if the point is not included in any triangle.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.onMapGenerated
|
||||
---
|
||||
```lua
|
||||
function MapGen.onMapGenerated(
|
||||
voxelManip: VoxelManip,
|
||||
minPos: Position,
|
||||
maxPos: Position,
|
||||
blockseed: number
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Chunk generation handler.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.run
|
||||
---
|
||||
```lua
|
||||
function MapGen.run() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Run world generation through this mapgen object
|
||||
|
||||
Note: only one instance of a `MapGen` class can be running.
|
||||
|
||||
**FOR MAPGEN ENVIRONMENT ONLY**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### MapGen.layersByName
|
||||
---
|
||||
```lua
|
||||
MapGen.layersByName : table<string,MapGen.Layer>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.layersList
|
||||
---
|
||||
```lua
|
||||
MapGen.layersList : MapGen.Layer[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.staticsByName
|
||||
---
|
||||
```lua
|
||||
MapGen.staticsByName : table<string,MapGen.StaticLayer>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.staticsList
|
||||
---
|
||||
```lua
|
||||
MapGen.staticsList : MapGen.StaticLayer[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.layersNoisesInitialized
|
||||
---
|
||||
```lua
|
||||
MapGen.layersNoisesInitialized : boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.cavernsNoiseInitialized
|
||||
---
|
||||
```lua
|
||||
MapGen.cavernsNoiseInitialized : boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.isRunning
|
||||
---
|
||||
```lua
|
||||
MapGen.isRunning : boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.nodeIDs
|
||||
---
|
||||
```lua
|
||||
MapGen.nodeIDs : table<string,number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
23
docs/docs/types/ColoredDotsTable.md
Normal file
23
docs/docs/types/ColoredDotsTable.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# alias ColoredDotsTable
|
||||
---
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) ColoredDotsTable = table<string,table>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Table with color as key and value is table with coordinates of dots. Note: coords begin from 1,1 (not 0,0).
|
||||
Example of table:
|
||||
```lua
|
||||
{
|
||||
'size': { h=256, w=256 },
|
||||
'#fff': { {x=1,y=1}, {x=2,y=2}, ... },
|
||||
'#ff0': { {x=3,y=3}, {x=4,y=4}, ... },
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
92
docs/docs/types/MapGen.Biome.GroundNodes.md
Normal file
92
docs/docs/types/MapGen.Biome.GroundNodes.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# class GroundNodes
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen.Biome
|
||||
|
||||
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### GroundNodes.turf
|
||||
---
|
||||
```lua
|
||||
GroundNodes.turf : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil covering the surface of the biome
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodes.soil
|
||||
---
|
||||
```lua
|
||||
GroundNodes.soil : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil beneath the turf. The height of this layer depends on `Biome.soilHeight`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodes.rock
|
||||
---
|
||||
```lua
|
||||
GroundNodes.rock : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
The rock found beneath the soil of a biome.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodes.bottom
|
||||
---
|
||||
```lua
|
||||
GroundNodes.bottom : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
Covering the bottom of reservoirs.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
92
docs/docs/types/MapGen.Biome.GroundNodesIDs.md
Normal file
92
docs/docs/types/MapGen.Biome.GroundNodesIDs.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# class GroundNodesIDs
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen.Biome
|
||||
|
||||
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### GroundNodesIDs.turf
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.turf : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil covering the surface of the biome
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodesIDs.soil
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.soil : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
The soil beneath the turf. The height of this layer depends on `Biome.soilHeight`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodesIDs.rock
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.rock : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
The rock found beneath the soil of a biome.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### GroundNodesIDs.bottom
|
||||
---
|
||||
```lua
|
||||
GroundNodesIDs.bottom : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
Covering the bottom of reservoirs.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
312
docs/docs/types/MapGen.Biome.md
Normal file
312
docs/docs/types/MapGen.Biome.md
Normal file
@@ -0,0 +1,312 @@
|
||||
# class Biome
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Biome.new
|
||||
---
|
||||
```lua
|
||||
function Biome.new(
|
||||
name: string,
|
||||
def: MapGen.BiomeDef {
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc?,
|
||||
generateCavernAir = generateFunc?,
|
||||
generateWater = generateFunc?,
|
||||
generateRock = generateFunc?,
|
||||
generateTurf = generateFunc?,
|
||||
generateSoil = generateFunc?,
|
||||
generateBottom = generateFunc?,
|
||||
}
|
||||
) -> MapGen.Biome {
|
||||
name = string,
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
groundNodesIDs = MapGen.Biome.GroundNodesIDs,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc,
|
||||
generateCavernAir = generateFunc,
|
||||
generateWater = generateFunc,
|
||||
generateRock = generateFunc,
|
||||
generateTurf = generateFunc,
|
||||
generateSoil = generateFunc,
|
||||
generateBottom = generateFunc,
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Biome.name
|
||||
---
|
||||
```lua
|
||||
Biome.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.tempPoint
|
||||
---
|
||||
```lua
|
||||
Biome.tempPoint : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.humidityPoint
|
||||
---
|
||||
```lua
|
||||
Biome.humidityPoint : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.minY
|
||||
---
|
||||
```lua
|
||||
Biome.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.maxY
|
||||
---
|
||||
```lua
|
||||
Biome.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.groundNodes
|
||||
---
|
||||
```lua
|
||||
Biome.groundNodes : MapGen.Biome.GroundNodes {
|
||||
turf: string,
|
||||
soil: string,
|
||||
rock: string,
|
||||
bottom: string,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.groundNodesIDs
|
||||
---
|
||||
```lua
|
||||
Biome.groundNodesIDs : MapGen.Biome.GroundNodesIDs {
|
||||
turf: number,
|
||||
soil: number,
|
||||
rock: number,
|
||||
bottom: number,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.soilHeight
|
||||
---
|
||||
```lua
|
||||
Biome.soilHeight : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateAir
|
||||
---
|
||||
```lua
|
||||
Biome.generateAir : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateCavernAir
|
||||
---
|
||||
```lua
|
||||
Biome.generateCavernAir : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateWater
|
||||
---
|
||||
```lua
|
||||
Biome.generateWater : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateRock
|
||||
---
|
||||
```lua
|
||||
Biome.generateRock : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateTurf
|
||||
---
|
||||
```lua
|
||||
Biome.generateTurf : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateSoil
|
||||
---
|
||||
```lua
|
||||
Biome.generateSoil : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Biome.generateBottom
|
||||
---
|
||||
```lua
|
||||
Biome.generateBottom : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
226
docs/docs/types/MapGen.BiomeDef.md
Normal file
226
docs/docs/types/MapGen.BiomeDef.md
Normal file
@@ -0,0 +1,226 @@
|
||||
# class BiomeDef
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen.Biome`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### BiomeDef.tempPoint
|
||||
---
|
||||
```lua
|
||||
BiomeDef.tempPoint : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.humidityPoint
|
||||
---
|
||||
```lua
|
||||
BiomeDef.humidityPoint : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.minY
|
||||
---
|
||||
```lua
|
||||
BiomeDef.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.maxY
|
||||
---
|
||||
```lua
|
||||
BiomeDef.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.groundNodes
|
||||
---
|
||||
```lua
|
||||
BiomeDef.groundNodes : MapGen.Biome.GroundNodes {
|
||||
turf: string,
|
||||
soil: string,
|
||||
rock: string,
|
||||
bottom: string,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.soilHeight
|
||||
---
|
||||
```lua
|
||||
BiomeDef.soilHeight : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateAir
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateAir : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateCavernAir
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateCavernAir : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateWater
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateWater : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateRock
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateRock : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateTurf
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateTurf : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateSoil
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateSoil : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### BiomeDef.generateBottom
|
||||
---
|
||||
```lua
|
||||
BiomeDef.generateBottom : generateFunc?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
208
docs/docs/types/MapGen.Cavern.md
Normal file
208
docs/docs/types/MapGen.Cavern.md
Normal file
@@ -0,0 +1,208 @@
|
||||
# class Cavern
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Cavern.getNoise
|
||||
---
|
||||
```lua
|
||||
function Cavern.getNoise()-> ValueNoise
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.initNoise
|
||||
---
|
||||
```lua
|
||||
function Cavern.initNoise()-> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.getGroups
|
||||
---
|
||||
```lua
|
||||
function Cavern.getGroups()
|
||||
-> table<string,number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.new
|
||||
---
|
||||
```lua
|
||||
function Cavern.new(
|
||||
name: string,
|
||||
def: MapGen.CavernDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
noiseParams = NoiseParams,
|
||||
smoothDistance = number,
|
||||
threshold = number?,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> MapGen.Cavern {
|
||||
name = string,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
smoothDistance = number,
|
||||
threshold = number,
|
||||
getNoise = function,
|
||||
initNoise = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
isCavern = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.isCavern
|
||||
---
|
||||
```lua
|
||||
function Cavern.isCavern(
|
||||
x: integer,
|
||||
y: integer,
|
||||
z: integer
|
||||
) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns `true` if there is a cavern at the specified coordinates.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Cavern.name
|
||||
---
|
||||
```lua
|
||||
Cavern.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.minY
|
||||
---
|
||||
```lua
|
||||
Cavern.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.maxY
|
||||
---
|
||||
```lua
|
||||
Cavern.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.smoothDistance
|
||||
---
|
||||
```lua
|
||||
Cavern.smoothDistance : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Cavern.threshold
|
||||
---
|
||||
```lua
|
||||
Cavern.threshold : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
116
docs/docs/types/MapGen.CavernDef.md
Normal file
116
docs/docs/types/MapGen.CavernDef.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# class CavernDef
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen.Cavern`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### CavernDef.minY
|
||||
---
|
||||
```lua
|
||||
CavernDef.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### CavernDef.maxY
|
||||
---
|
||||
```lua
|
||||
CavernDef.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### CavernDef.noiseParams
|
||||
---
|
||||
```lua
|
||||
CavernDef.noiseParams : NoiseParams
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### CavernDef.smoothDistance
|
||||
---
|
||||
```lua
|
||||
CavernDef.smoothDistance : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### CavernDef.threshold
|
||||
---
|
||||
```lua
|
||||
CavernDef.threshold : number?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### CavernDef.groups
|
||||
---
|
||||
```lua
|
||||
CavernDef.groups : table<string,number>?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
43
docs/docs/types/MapGen.Decoration.md
Normal file
43
docs/docs/types/MapGen.Decoration.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# class Decoration
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
**NOT IMPLEMENTED**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Decoration.new
|
||||
---
|
||||
```lua
|
||||
function Decoration.new() -> MapGen.Decoration {
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
docs/docs/types/MapGen.Layer.Category.md
Normal file
16
docs/docs/types/MapGen.Layer.Category.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# alias Category
|
||||
---
|
||||
|
||||
- namespace: MapGen.Layer
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) Category = ("landscape"|"temp"|"humidity")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
A category of noise that affects specific map generation objects.
|
||||
|
||||
678
docs/docs/types/MapGen.Layer.md
Normal file
678
docs/docs/types/MapGen.Layer.md
Normal file
@@ -0,0 +1,678 @@
|
||||
# class Layer
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Layer.calcTemp
|
||||
---
|
||||
```lua
|
||||
function Layer.calcTemp(
|
||||
self: MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
},
|
||||
value: number,
|
||||
height: number
|
||||
)-> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.calcHumidity
|
||||
---
|
||||
```lua
|
||||
function Layer.calcHumidity(
|
||||
self: MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
},
|
||||
value: number,
|
||||
height: number
|
||||
)-> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.new
|
||||
---
|
||||
```lua
|
||||
function Layer.new(
|
||||
name: string,
|
||||
def: MapGen.LayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
minTemp = number,
|
||||
maxTemp = number,
|
||||
minHumidity = number,
|
||||
maxHumidity = number,
|
||||
waterLevel = number?,
|
||||
calcTemp = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
calcHumidity = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
biomesGorizontalScattering = number?,
|
||||
biomesVerticalScattering = number?,
|
||||
}
|
||||
) -> MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addPeak
|
||||
---
|
||||
```lua
|
||||
function Layer.addPeak(
|
||||
category: MapGen.Layer.Category,
|
||||
peak: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a peak to the `Layer.peaksList`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addNoiseParamsColor
|
||||
---
|
||||
```lua
|
||||
function Layer.addNoiseParamsColor(
|
||||
category: MapGen.Layer.Category,
|
||||
color: ColorString,
|
||||
noiseParams: NoiseParams
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a NoiseParams color to the `Layer.noisesParamsByColor`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.getNoiseByColor
|
||||
---
|
||||
```lua
|
||||
function Layer.getNoiseByColor(
|
||||
category: MapGen.Layer.Category,
|
||||
color: ColorString
|
||||
) -> ValueNoise
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns noise corresponding to a color.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addBiome
|
||||
---
|
||||
```lua
|
||||
function Layer.addBiome(
|
||||
biomeName: string,
|
||||
biome: MapGen.Biome {
|
||||
name = string,
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
groundNodesIDs = MapGen.Biome.GroundNodesIDs,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc,
|
||||
generateCavernAir = generateFunc,
|
||||
generateWater = generateFunc,
|
||||
generateRock = generateFunc,
|
||||
generateTurf = generateFunc,
|
||||
generateSoil = generateFunc,
|
||||
generateBottom = generateFunc,
|
||||
new = function,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a biome to the `Layer.biomesByName` & `Layer.biomesList`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.addCavern
|
||||
---
|
||||
```lua
|
||||
function Layer.addCavern(
|
||||
cavernName: string,
|
||||
cavern: MapGen.Cavern {
|
||||
name = string,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
smoothDistance = number,
|
||||
threshold = number,
|
||||
getNoise = function,
|
||||
initNoise = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
isCavern = function,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Adds a cavern to the `Layer.cavernsByName` & `Layer.cavernsList`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.initNoises
|
||||
---
|
||||
```lua
|
||||
function Layer.initNoises() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initializes noise for generation.
|
||||
|
||||
Should only be called after the mapgen object has been loaded.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.initBiomesDiagram
|
||||
---
|
||||
```lua
|
||||
function Layer.initBiomesDiagram() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialization of the biome diagram using the Voronoi method.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Layer.name
|
||||
---
|
||||
```lua
|
||||
Layer.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.minY
|
||||
---
|
||||
```lua
|
||||
Layer.minY : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.maxY
|
||||
---
|
||||
```lua
|
||||
Layer.maxY : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.minTemp
|
||||
---
|
||||
```lua
|
||||
Layer.minTemp : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.maxTemp
|
||||
---
|
||||
```lua
|
||||
Layer.maxTemp : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.minHumidity
|
||||
---
|
||||
```lua
|
||||
Layer.minHumidity : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.maxHumidity
|
||||
---
|
||||
```lua
|
||||
Layer.maxHumidity : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.waterLevel
|
||||
---
|
||||
```lua
|
||||
Layer.waterLevel : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.peaksList
|
||||
---
|
||||
```lua
|
||||
Layer.peaksList : { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.noisesByColor
|
||||
---
|
||||
```lua
|
||||
Layer.noisesByColor : { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.noisesParamsByColor
|
||||
---
|
||||
```lua
|
||||
Layer.noisesParamsByColor : { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesByName
|
||||
---
|
||||
```lua
|
||||
Layer.biomesByName : table<string,MapGen.Biome>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesList
|
||||
---
|
||||
```lua
|
||||
Layer.biomesList : MapGen.Biome[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesDiagram
|
||||
---
|
||||
```lua
|
||||
Layer.biomesDiagram : table
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesGorizontalScattering
|
||||
---
|
||||
```lua
|
||||
Layer.biomesGorizontalScattering : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.biomesVerticalScattering
|
||||
---
|
||||
```lua
|
||||
Layer.biomesVerticalScattering : integer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.cavernsByName
|
||||
---
|
||||
```lua
|
||||
Layer.cavernsByName : table<string,MapGen.Cavern>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.cavernsList
|
||||
---
|
||||
```lua
|
||||
Layer.cavernsList : MapGen.Cavern[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.trianglesList
|
||||
---
|
||||
```lua
|
||||
Layer.trianglesList : { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Layer.tetrahedronsList
|
||||
---
|
||||
```lua
|
||||
Layer.tetrahedronsList : MapGen.Tetrahedron[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
**Not supported**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
191
docs/docs/types/MapGen.LayerDef.md
Normal file
191
docs/docs/types/MapGen.LayerDef.md
Normal file
@@ -0,0 +1,191 @@
|
||||
# class LayerDef
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen.Layer`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### LayerDef.minY
|
||||
---
|
||||
```lua
|
||||
LayerDef.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.maxY
|
||||
---
|
||||
```lua
|
||||
LayerDef.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.minTemp
|
||||
---
|
||||
```lua
|
||||
LayerDef.minTemp : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.maxTemp
|
||||
---
|
||||
```lua
|
||||
LayerDef.maxTemp : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.minHumidity
|
||||
---
|
||||
```lua
|
||||
LayerDef.minHumidity : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.maxHumidity
|
||||
---
|
||||
```lua
|
||||
LayerDef.maxHumidity : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.waterLevel
|
||||
---
|
||||
```lua
|
||||
LayerDef.waterLevel : number?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.calcTemp
|
||||
---
|
||||
```lua
|
||||
LayerDef.calcTemp : (fun(self: MapGen.Layer, value: number, height: number) -> number)?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.calcHumidity
|
||||
---
|
||||
```lua
|
||||
LayerDef.calcHumidity : (fun(self: MapGen.Layer, value: number, height: number) -> number)?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.biomesGorizontalScattering
|
||||
---
|
||||
```lua
|
||||
LayerDef.biomesGorizontalScattering : number?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### LayerDef.biomesVerticalScattering
|
||||
---
|
||||
```lua
|
||||
LayerDef.biomesVerticalScattering : number?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14
docs/docs/types/MapGen.PastCalcNoiseValue.md
Normal file
14
docs/docs/types/MapGen.PastCalcNoiseValue.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# alias PastCalcNoiseValue
|
||||
---
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) PastCalcNoiseValue = { noiseValue: number?, triangle: MapGen.Triangle?, x: integer?, z: integer? }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
162
docs/docs/types/MapGen.Peak.md
Normal file
162
docs/docs/types/MapGen.Peak.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# class Peak
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Peak.getPeakPos
|
||||
---
|
||||
```lua
|
||||
function Peak.getPeakPos(self)-> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.getColor
|
||||
---
|
||||
```lua
|
||||
function Peak.getColor(self)-> ColorString
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.getGroups
|
||||
---
|
||||
```lua
|
||||
function Peak.getGroups(self)
|
||||
-> table<string,number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.new
|
||||
---
|
||||
```lua
|
||||
function Peak.new(def: MapGen.PeakDef {
|
||||
pos = vector,
|
||||
color = ColorString,
|
||||
groups = table<string,number>?,
|
||||
}) -> MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.toString
|
||||
---
|
||||
```lua
|
||||
function Peak.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Peak.eq
|
||||
---
|
||||
```lua
|
||||
function Peak.eq(other: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the peaks are equivalent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Peak.id
|
||||
---
|
||||
```lua
|
||||
Peak.id : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
71
docs/docs/types/MapGen.PeakDef.md
Normal file
71
docs/docs/types/MapGen.PeakDef.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# class PeakDef
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen.Peak`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### PeakDef.pos
|
||||
---
|
||||
```lua
|
||||
PeakDef.pos : vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### PeakDef.color
|
||||
---
|
||||
```lua
|
||||
PeakDef.color : ColorString
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### PeakDef.groups
|
||||
---
|
||||
```lua
|
||||
PeakDef.groups : table<string,number>?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
149
docs/docs/types/MapGen.StaticLayer.md
Normal file
149
docs/docs/types/MapGen.StaticLayer.md
Normal file
@@ -0,0 +1,149 @@
|
||||
# class StaticLayer
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### StaticLayer.new
|
||||
---
|
||||
```lua
|
||||
function StaticLayer.new(
|
||||
name: string,
|
||||
def: MapGen.StaticLayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
staticNode = string,
|
||||
generateStaticNode = generateFunc,
|
||||
}
|
||||
) -> MapGen.StaticLayer {
|
||||
name = string,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
staticNode = string,
|
||||
staticNodeID = number,
|
||||
generateStaticNode = generateFunc,
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### StaticLayer.name
|
||||
---
|
||||
```lua
|
||||
StaticLayer.name : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.minY
|
||||
---
|
||||
```lua
|
||||
StaticLayer.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.maxY
|
||||
---
|
||||
```lua
|
||||
StaticLayer.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.staticNode
|
||||
---
|
||||
```lua
|
||||
StaticLayer.staticNode : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.staticNodeID
|
||||
---
|
||||
```lua
|
||||
StaticLayer.staticNodeID : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayer.generateStaticNode
|
||||
---
|
||||
```lua
|
||||
StaticLayer.generateStaticNode : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
86
docs/docs/types/MapGen.StaticLayerDef.md
Normal file
86
docs/docs/types/MapGen.StaticLayerDef.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# class StaticLayerDef
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen.StaticLayer`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### StaticLayerDef.minY
|
||||
---
|
||||
```lua
|
||||
StaticLayerDef.minY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayerDef.maxY
|
||||
---
|
||||
```lua
|
||||
StaticLayerDef.maxY : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayerDef.staticNode
|
||||
---
|
||||
```lua
|
||||
StaticLayerDef.staticNode : string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### StaticLayerDef.generateStaticNode
|
||||
---
|
||||
```lua
|
||||
StaticLayerDef.generateStaticNode : generateFunc
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
541
docs/docs/types/MapGen.Tetrahedron.md
Normal file
541
docs/docs/types/MapGen.Tetrahedron.md
Normal file
@@ -0,0 +1,541 @@
|
||||
# class Tetrahedron
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Tetrahedron.new
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.new(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p4: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Tetrahedron {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
p4 = MapGen.Peak,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
h4 = MapGen.Triangulation.Edge,
|
||||
f1 = MapGen.Triangle,
|
||||
f2 = MapGen.Triangle,
|
||||
f3 = MapGen.Triangle,
|
||||
f4 = MapGen.Triangle,
|
||||
new = function,
|
||||
toString = function,
|
||||
getHeight = function,
|
||||
getCircumSphereCenter = function,
|
||||
getCircumSphereRadius = function,
|
||||
inCircumSphere = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.toString
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.getHeight
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.getHeight(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p4: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.getCircumSphereCenter
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.getCircumSphereCenter() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the center of the circumscribed sphere.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.getCircumSphereRadius
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.getCircumSphereRadius() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the radius of the circumscribed sphere.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.inCircumSphere
|
||||
---
|
||||
```lua
|
||||
function Tetrahedron.inCircumSphere(p: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Checks whether a given point lies within the circumscribed sphere of a tetrahedron.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Tetrahedron.p1
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p1 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.p2
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p2 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.p3
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p3 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.p4
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.p4 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h1
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h1 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h2
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h2 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h3
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h3 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.h4
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.h4 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f1
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f1 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f2
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f2 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f3
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f3 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tetrahedron.f4
|
||||
---
|
||||
```lua
|
||||
Tetrahedron.f4 : MapGen.Triangle {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
p3: MapGen.Peak,
|
||||
e1: MapGen.Triangulation.Edge,
|
||||
e2: MapGen.Triangulation.Edge,
|
||||
e3: MapGen.Triangulation.Edge,
|
||||
h1: MapGen.Triangulation.Edge,
|
||||
h2: MapGen.Triangulation.Edge,
|
||||
h3: MapGen.Triangulation.Edge,
|
||||
neighbours: MapGen.Triangle.Neighbours,
|
||||
color: ColorString?,
|
||||
new: function,
|
||||
...(+13)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14
docs/docs/types/MapGen.Triangle.CircumCircleEnum.md
Normal file
14
docs/docs/types/MapGen.Triangle.CircumCircleEnum.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# alias CircumCircleEnum
|
||||
---
|
||||
|
||||
- namespace: MapGen.Triangle
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) CircumCircleEnum = ("IN"|"BEHIND"|"ON")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
19
docs/docs/types/MapGen.Triangle.Neighbours.md
Normal file
19
docs/docs/types/MapGen.Triangle.Neighbours.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# alias Neighbours
|
||||
---
|
||||
|
||||
- namespace: MapGen.Triangle
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) Neighbours = { t1: MapGen.Triangle?, t2: MapGen.Triangle?, t3: MapGen.Triangle? }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Adjacent triangles:
|
||||
* `t1` with a common side p1-p2
|
||||
* `t2` with a common side p2-p3
|
||||
* `t3` with a common side p3-p1
|
||||
|
||||
750
docs/docs/types/MapGen.Triangle.md
Normal file
750
docs/docs/types/MapGen.Triangle.md
Normal file
@@ -0,0 +1,750 @@
|
||||
# class Triangle
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Triangle.new
|
||||
---
|
||||
```lua
|
||||
function Triangle.new(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangle {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
e1 = MapGen.Triangulation.Edge,
|
||||
e2 = MapGen.Triangulation.Edge,
|
||||
e3 = MapGen.Triangulation.Edge,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
neighbours = MapGen.Triangle.Neighbours,
|
||||
color = ColorString?,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
getCenter = function,
|
||||
getArea = function,
|
||||
getHeight = function,
|
||||
getHeight2D = function,
|
||||
getSidesLength = function,
|
||||
getSidesLength2D = function,
|
||||
getCircumCenter2D = function,
|
||||
getCircumRadius2D = function,
|
||||
getCircumCircle2D = function,
|
||||
inCircumCircle2D = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.toString
|
||||
---
|
||||
```lua
|
||||
function Triangle.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.eq
|
||||
---
|
||||
```lua
|
||||
function Triangle.eq(other: MapGen.Triangle {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
e1 = MapGen.Triangulation.Edge,
|
||||
e2 = MapGen.Triangulation.Edge,
|
||||
e3 = MapGen.Triangulation.Edge,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
neighbours = MapGen.Triangle.Neighbours,
|
||||
color = ColorString?,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
getCenter = function,
|
||||
getArea = function,
|
||||
getHeight = function,
|
||||
getHeight2D = function,
|
||||
getSidesLength = function,
|
||||
getSidesLength2D = function,
|
||||
getCircumCenter2D = function,
|
||||
getCircumRadius2D = function,
|
||||
getCircumCircle2D = function,
|
||||
inCircumCircle2D = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the triangles are equivalent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.same
|
||||
---
|
||||
```lua
|
||||
function Triangle.same(other: MapGen.Triangle {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
p3 = MapGen.Peak,
|
||||
e1 = MapGen.Triangulation.Edge,
|
||||
e2 = MapGen.Triangulation.Edge,
|
||||
e3 = MapGen.Triangulation.Edge,
|
||||
h1 = MapGen.Triangulation.Edge,
|
||||
h2 = MapGen.Triangulation.Edge,
|
||||
h3 = MapGen.Triangulation.Edge,
|
||||
neighbours = MapGen.Triangle.Neighbours,
|
||||
color = ColorString?,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
getCenter = function,
|
||||
getArea = function,
|
||||
getHeight = function,
|
||||
getHeight2D = function,
|
||||
getSidesLength = function,
|
||||
getSidesLength2D = function,
|
||||
getCircumCenter2D = function,
|
||||
getCircumRadius2D = function,
|
||||
getCircumCircle2D = function,
|
||||
inCircumCircle2D = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the triangles are similar.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCenter
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCenter() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the coordinates of the triangle's center.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getArea
|
||||
---
|
||||
```lua
|
||||
function Triangle.getArea() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the area of a triangle.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getHeight
|
||||
---
|
||||
```lua
|
||||
function Triangle.getHeight(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the perpendicular from the vertex Peak1 to the line Peak2-Peak3.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getHeight2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getHeight2D(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p3: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the perpendicular from the vertex Peak1 to the line Peak2-Peak3.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getSidesLength
|
||||
---
|
||||
```lua
|
||||
function Triangle.getSidesLength()
|
||||
-> number
|
||||
-> number
|
||||
-> number
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the length of the edges
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getSidesLength2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getSidesLength2D()
|
||||
-> number
|
||||
-> number
|
||||
-> number
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the length of the edges.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCircumCenter2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCircumCenter2D() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the coordinates of the circumcircle center.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCircumRadius2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCircumRadius2D() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the radius of the circumcircle.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.getCircumCircle2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.getCircumCircle2D()
|
||||
-> vector
|
||||
-> number
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the coordinates of the circumcircle center and its radius.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.inCircumCircle2D
|
||||
---
|
||||
```lua
|
||||
function Triangle.inCircumCircle2D(p: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Checks if a given point lies into the triangle circumcircle.
|
||||
|
||||
Note: This function does not take into account the Y-coordinate,
|
||||
that is, the calculation is performed on the projection of the triangle XZ.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Triangle.p1
|
||||
---
|
||||
```lua
|
||||
Triangle.p1 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.p2
|
||||
---
|
||||
```lua
|
||||
Triangle.p2 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.p3
|
||||
---
|
||||
```lua
|
||||
Triangle.p3 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.e1
|
||||
---
|
||||
```lua
|
||||
Triangle.e1 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.e2
|
||||
---
|
||||
```lua
|
||||
Triangle.e2 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.e3
|
||||
---
|
||||
```lua
|
||||
Triangle.e3 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.h1
|
||||
---
|
||||
```lua
|
||||
Triangle.h1 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.h2
|
||||
---
|
||||
```lua
|
||||
Triangle.h2 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.h3
|
||||
---
|
||||
```lua
|
||||
Triangle.h3 : MapGen.Triangulation.Edge {
|
||||
p1: MapGen.Peak,
|
||||
p2: MapGen.Peak,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
same: function,
|
||||
length: function,
|
||||
getMidPoint: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.neighbours
|
||||
---
|
||||
```lua
|
||||
Triangle.neighbours : MapGen.Triangle.Neighbours
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangle.color
|
||||
---
|
||||
```lua
|
||||
Triangle.color : ColorString?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
230
docs/docs/types/MapGen.Triangulation.Edge.md
Normal file
230
docs/docs/types/MapGen.Triangulation.Edge.md
Normal file
@@ -0,0 +1,230 @@
|
||||
# class Edge
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen.Triangulation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Edge.new
|
||||
---
|
||||
```lua
|
||||
function Edge.new(
|
||||
p1: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
},
|
||||
p2: MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
) -> MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.toString
|
||||
---
|
||||
```lua
|
||||
function Edge.toString() -> string
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a string describing the object in a readable form.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.eq
|
||||
---
|
||||
```lua
|
||||
function Edge.eq(other: MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the edges are equivalent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.same
|
||||
---
|
||||
```lua
|
||||
function Edge.same(other: MapGen.Triangulation.Edge {
|
||||
p1 = MapGen.Peak,
|
||||
p2 = MapGen.Peak,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
same = function,
|
||||
length = function,
|
||||
getMidPoint = function,
|
||||
}) -> boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns true if the edges are similar.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.length
|
||||
---
|
||||
```lua
|
||||
function Edge.length() -> number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the length of an edge.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.getMidPoint
|
||||
---
|
||||
```lua
|
||||
function Edge.getMidPoint() -> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns the vector of the point located in the middle of the edge.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Edge.p1
|
||||
---
|
||||
```lua
|
||||
Edge.p1 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Edge.p2
|
||||
---
|
||||
```lua
|
||||
Edge.p2 : MapGen.Peak {
|
||||
id: number,
|
||||
getPeakPos: function,
|
||||
getColor: function,
|
||||
getGroups: function,
|
||||
new: function,
|
||||
toString: function,
|
||||
eq: function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
90
docs/docs/types/MapGen.Triangulation.FakePeak.md
Normal file
90
docs/docs/types/MapGen.Triangulation.FakePeak.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# class FakePeak
|
||||
|
||||
|
||||
- supers: MapGen.Peak
|
||||
|
||||
|
||||
- namespace: MapGen.Triangulation
|
||||
|
||||
|
||||
|
||||
Allows you to create a `MapGen.Peak` without specifying a noise parameter.
|
||||
|
||||
**WARNING: MUST NOT BE PARTICIPATED IN GENERATION**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### FakePeak.getPeakPos
|
||||
---
|
||||
```lua
|
||||
function FakePeak.getPeakPos()-> vector
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### FakePeak.new
|
||||
---
|
||||
```lua
|
||||
function FakePeak.new(peakPos: vector) -> MapGen.Peak {
|
||||
id = number,
|
||||
getPeakPos = function,
|
||||
getColor = function,
|
||||
getGroups = function,
|
||||
new = function,
|
||||
toString = function,
|
||||
eq = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a fake `MapGen.Peak` that has no noise parameters.
|
||||
Note that the initialized peak should not be used in generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### FakePeak.id
|
||||
---
|
||||
```lua
|
||||
FakePeak.id : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
86
docs/docs/types/MapGen.Triangulation.md
Normal file
86
docs/docs/types/MapGen.Triangulation.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# class Triangulation
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Triangulation.triangulate
|
||||
---
|
||||
```lua
|
||||
function Triangulation.triangulate(vertices: table<integer,MapGen.Peak>) -> ((MapGen.Triangle)|MapGen.Triangle[])
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The Delaunay method divides a plane into triangles based on a list of their vertices.
|
||||
|
||||
Doesn't take into account the Y coordinate of the vertices.
|
||||
That is, all triangles that don't lie in the XZ plane will be projected onto it.
|
||||
|
||||
Vertices that do not have a `is2d` group will not participate in the triangulation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Triangulation.tetrahedralize
|
||||
---
|
||||
```lua
|
||||
function Triangulation.tetrahedralize(vertices: table<integer,MapGen.Peak>) -> ((MapGen.Tetrahedron)|MapGen.Tetrahedron[])
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The Delaunay method divides space into tetrahedra based on a list of their vertices.
|
||||
|
||||
Vertices that do not have a `is3d` group will not participate in the triangulation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### Triangulation.convexMultiplier
|
||||
---
|
||||
```lua
|
||||
Triangulation.convexMultiplier : number
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
741
docs/docs/types/MapGen.md
Normal file
741
docs/docs/types/MapGen.md
Normal file
@@ -0,0 +1,741 @@
|
||||
# class MapGen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### MapGen.new
|
||||
---
|
||||
```lua
|
||||
function MapGen.new(def: MapGenDef {
|
||||
nodes = table<string,string>,
|
||||
}) -> MapGen {
|
||||
layersByName = table<string,MapGen.Layer>,
|
||||
layersList = MapGen.Layer[],
|
||||
staticsByName = table<string,MapGen.StaticLayer>,
|
||||
staticsList = MapGen.StaticLayer[],
|
||||
layersNoisesInitialized = boolean,
|
||||
cavernsNoiseInitialized = boolean,
|
||||
isRunning = boolean,
|
||||
nodeIDs = table<string,number>,
|
||||
new = function,
|
||||
getLayerByHeight = function,
|
||||
getStaticByHeight = function,
|
||||
registerLayer = function,
|
||||
registerLayerNoiseColor = function,
|
||||
registerStaticLayer = function,
|
||||
registerPeak = function,
|
||||
register2DPeak = function,
|
||||
register2DPeaks = function,
|
||||
register2DPeaksFromFile = function,
|
||||
registerBiome = function,
|
||||
registerCavern = function,
|
||||
initLayersTriangultaion = function,
|
||||
initLayersNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
initCavernsNoise = function,
|
||||
getNoises2dValue = function,
|
||||
onMapGenerated = function,
|
||||
run = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.getLayerByHeight
|
||||
---
|
||||
```lua
|
||||
function MapGen.getLayerByHeight(yPos: number) -> MapGen.Layer?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Determines which layer a node belongs to based on its height coordinate.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.getStaticByHeight
|
||||
---
|
||||
```lua
|
||||
function MapGen.getStaticByHeight(yPos: number) -> MapGen.StaticLayer?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Determines which statics layer a node belongs to based on its height coordinate.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerLayer
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerLayer(
|
||||
name: string,
|
||||
def: MapGen.LayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
minTemp = number,
|
||||
maxTemp = number,
|
||||
minHumidity = number,
|
||||
maxHumidity = number,
|
||||
waterLevel = number?,
|
||||
calcTemp = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
calcHumidity = (fun(self: MapGen.Layer, value: number, height: number) -> number)?,
|
||||
biomesGorizontalScattering = number?,
|
||||
biomesVerticalScattering = number?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `name` - The name that will be assigned to the layer. The name must be unique for each layer.
|
||||
|
||||
@param `def` - Layer description table, see details `MapGen.LayerDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world area between two heights as a `MapGen.Layer`.
|
||||
|
||||
Note: layers must not overlap.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerLayerNoiseColor
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerLayerNoiseColor(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
color: ColorString,
|
||||
noiseParams: NoiseParams
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer for which the color will be registered.
|
||||
|
||||
@param `category` - Category indicating what will be generated by noise.
|
||||
|
||||
@param `color` - Noise color. Must be unique.
|
||||
|
||||
@param `noiseParams` - Fractal noise parameters.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Register the color and the noise parameters that correspond to it.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerStaticLayer
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerStaticLayer(
|
||||
name: string,
|
||||
def: MapGen.StaticLayerDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
staticNode = string,
|
||||
generateStaticNode = generateFunc,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `name` - The name that will be assigned to the static layer. The name must be unique for each layer.
|
||||
|
||||
@param `def` - Static layer description table, see details `MapGen.StaticLayerDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world area between two heights as a `MapGen.StaticLayer`.
|
||||
|
||||
Note: layers must not overlap.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerPeak
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerPeak(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
def: MapGen.PeakDef {
|
||||
pos = vector,
|
||||
color = ColorString,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peak will be included.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peak.
|
||||
|
||||
@param `def` - Peak description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.register2DPeak
|
||||
---
|
||||
```lua
|
||||
function MapGen.register2DPeak(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
def: MapGen.PeakDef {
|
||||
pos = vector,
|
||||
color = ColorString,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peak will be included.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peak.
|
||||
|
||||
@param `def` - Peak description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.register2DPeaks
|
||||
---
|
||||
```lua
|
||||
function MapGen.register2DPeaks(
|
||||
layerName: string,
|
||||
category: MapGen.Layer.Category,
|
||||
defs: MapGen.PeakDef[]
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peaks will be included.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peaks.
|
||||
|
||||
@param `defs` - Peaks description table, see details `MapGen.PeakDef`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world points as `MapGen.Peak` and assign them all a specific noise that will affect generation.
|
||||
The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
|
||||
Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.register2DPeaksFromFile
|
||||
---
|
||||
```lua
|
||||
function MapGen.register2DPeaksFromFile(
|
||||
layerName: string,
|
||||
map: string,
|
||||
scale: number,
|
||||
zeroPos: Position2d,
|
||||
category: MapGen.Layer.Category,
|
||||
groups: table<string,number>?
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new peaks will be included.
|
||||
|
||||
@param `map` - The name of the image from which the peaks will be extracted. It should be located in the `<mod_name>/textures/maps` folder and have the following format `<image_name>.ff`
|
||||
|
||||
@param `scale` - Multiplier of how many blocks (nodes) will be between image pixels. It is not recommended to set the value below 50 for performance reasons.
|
||||
|
||||
@param `zeroPos` - The position in pixels where the zero world coordinate will be in the image.
|
||||
|
||||
@param `category` - Category indicating what will be generated by peaks.
|
||||
|
||||
@param `groups` - Groups that will be added to all peaks.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Extract the `MapGen.Peak` from the image and assign them all a specific color that will affect the generation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerBiome
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerBiome(
|
||||
layerName: string,
|
||||
biomeName: string,
|
||||
def: MapGen.BiomeDef {
|
||||
tempPoint = number,
|
||||
humidityPoint = number,
|
||||
minY = number,
|
||||
maxY = number,
|
||||
groundNodes = MapGen.Biome.GroundNodes,
|
||||
soilHeight = number,
|
||||
generateAir = generateFunc?,
|
||||
generateCavernAir = generateFunc?,
|
||||
generateWater = generateFunc?,
|
||||
generateRock = generateFunc?,
|
||||
generateTurf = generateFunc?,
|
||||
generateSoil = generateFunc?,
|
||||
generateBottom = generateFunc?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new biome will be included.
|
||||
|
||||
@param `biomeName` - The name to be assigned to the biome. The name must be unique for each biome.
|
||||
|
||||
@param `def` - Biome description table, see details `MapGen.BiomeDef`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark a point on the biomes diagram and constrain the world area by height to mark it as `MapGen.Biome`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.registerCavern
|
||||
---
|
||||
```lua
|
||||
function MapGen.registerCavern(
|
||||
layerName: string,
|
||||
cavernName: string,
|
||||
def: MapGen.CavernDef {
|
||||
minY = number,
|
||||
maxY = number,
|
||||
noiseParams = NoiseParams,
|
||||
smoothDistance = number,
|
||||
threshold = number?,
|
||||
groups = table<string,number>?,
|
||||
}
|
||||
) -> nil
|
||||
```
|
||||
@param `layerName` - The name of the layer in which the new cavern will be included.
|
||||
|
||||
@param `cavernName` - The name to be assigned to the cavern. The name must be unique for each cavern.
|
||||
|
||||
@param `def` - Cavern description table, see details `MapGen.CavernDef`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Mark the world area between two heights as a `MapGen.Cavern` and assign the noise that the cave will be generated from.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initLayersTriangultaion
|
||||
---
|
||||
```lua
|
||||
function MapGen.initLayersTriangultaion() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Divide all layers into triangles whose vertices are the `Mapgen.Peak` belonging to these layers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initLayersNoises
|
||||
---
|
||||
```lua
|
||||
function MapGen.initLayersNoises() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialize all layer noises. This should be called after the map object is loaded.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initBiomesDiagram
|
||||
---
|
||||
```lua
|
||||
function MapGen.initBiomesDiagram() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialization of the biome diagram using the Voronoi method.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.initCavernsNoise
|
||||
---
|
||||
```lua
|
||||
function MapGen.initCavernsNoise() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Initialize caverns's noises. This should be called after the map object is loaded.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.getNoises2dValue
|
||||
---
|
||||
```lua
|
||||
function MapGen.getNoises2dValue(
|
||||
category: MapGen.Layer.Category,
|
||||
layer: MapGen.Layer {
|
||||
name = string,
|
||||
minY = integer,
|
||||
maxY = integer,
|
||||
minTemp = integer,
|
||||
maxTemp = integer,
|
||||
minHumidity = integer,
|
||||
maxHumidity = integer,
|
||||
waterLevel = integer,
|
||||
peaksList = { humidity: MapGen.Peak[], landscape: MapGen.Peak[], temp: MapGen.Peak[] },
|
||||
noisesByColor = { humidity: table<ColorString,ValueNoise>, landscape: table<ColorString,ValueNoise>, temp: table<ColorString,ValueNoise> },
|
||||
noisesParamsByColor = { humidity: table<ColorString,NoiseParams>, landscape: table<ColorString,NoiseParams>, temp: table<ColorString,NoiseParams> },
|
||||
biomesByName = table<string,MapGen.Biome>,
|
||||
biomesList = MapGen.Biome[],
|
||||
biomesDiagram = table,
|
||||
biomesGorizontalScattering = integer,
|
||||
biomesVerticalScattering = integer,
|
||||
cavernsByName = table<string,MapGen.Cavern>,
|
||||
cavernsList = MapGen.Cavern[],
|
||||
trianglesList = { humidity: MapGen.Triangle[], landscape: MapGen.Triangle[], temp: MapGen.Triangle[] },
|
||||
tetrahedronsList = MapGen.Tetrahedron[],
|
||||
calcTemp = function,
|
||||
calcHumidity = function,
|
||||
new = function,
|
||||
addPeak = function,
|
||||
addNoiseParamsColor = function,
|
||||
getNoiseByColor = function,
|
||||
addBiome = function,
|
||||
addCavern = function,
|
||||
initNoises = function,
|
||||
initBiomesDiagram = function,
|
||||
},
|
||||
x: integer,
|
||||
y: integer,
|
||||
z: integer
|
||||
) -> number?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Calculates a smoothed 2D noise value based on a preliminary space partitioning.
|
||||
|
||||
Returns `nil` if the point is not included in any triangle.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.onMapGenerated
|
||||
---
|
||||
```lua
|
||||
function MapGen.onMapGenerated(
|
||||
voxelManip: VoxelManip,
|
||||
minPos: Position,
|
||||
maxPos: Position,
|
||||
blockseed: number
|
||||
) -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Chunk generation handler.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.run
|
||||
---
|
||||
```lua
|
||||
function MapGen.run() -> nil
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Run world generation through this mapgen object
|
||||
|
||||
Note: only one instance of a `MapGen` class can be running.
|
||||
|
||||
**FOR MAPGEN ENVIRONMENT ONLY**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### MapGen.layersByName
|
||||
---
|
||||
```lua
|
||||
MapGen.layersByName : table<string,MapGen.Layer>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.layersList
|
||||
---
|
||||
```lua
|
||||
MapGen.layersList : MapGen.Layer[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.staticsByName
|
||||
---
|
||||
```lua
|
||||
MapGen.staticsByName : table<string,MapGen.StaticLayer>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.staticsList
|
||||
---
|
||||
```lua
|
||||
MapGen.staticsList : MapGen.StaticLayer[]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.layersNoisesInitialized
|
||||
---
|
||||
```lua
|
||||
MapGen.layersNoisesInitialized : boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.cavernsNoiseInitialized
|
||||
---
|
||||
```lua
|
||||
MapGen.cavernsNoiseInitialized : boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.isRunning
|
||||
---
|
||||
```lua
|
||||
MapGen.isRunning : boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### MapGen.nodeIDs
|
||||
---
|
||||
```lua
|
||||
MapGen.nodeIDs : table<string,number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
39
docs/docs/types/MapGenDef.md
Normal file
39
docs/docs/types/MapGenDef.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# class MapGenDef
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### MapGenDef.nodes
|
||||
---
|
||||
```lua
|
||||
MapGenDef.nodes : table<string,string>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
12
docs/docs/types/generateFunc.md
Normal file
12
docs/docs/types/generateFunc.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# alias generateFunc
|
||||
---
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) generateFunc = fun(self, mapGenerator: MapGen, data: number[], index: number, x: number, y: number, z: number)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
80
docs/mkdocs.yml
Normal file
80
docs/mkdocs.yml
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
site_name: Docs
|
||||
|
||||
|
||||
theme:
|
||||
name: material
|
||||
font:
|
||||
text: Roboto
|
||||
code: Roboto Mono
|
||||
search: true
|
||||
features:
|
||||
- quick-links
|
||||
- navigation
|
||||
- search
|
||||
- toc
|
||||
- fullscreen
|
||||
- bookmarks
|
||||
- tabs
|
||||
- code
|
||||
- edit-on-github
|
||||
- language-selector
|
||||
- code
|
||||
- cover
|
||||
- footer
|
||||
- social-share
|
||||
- theme-switcher
|
||||
nav:
|
||||
- Home: index.md
|
||||
|
||||
- Types:
|
||||
- alias Category : types/MapGen.Layer.Category.md
|
||||
- alias CircumCircleEnum : types/MapGen.Triangle.CircumCircleEnum.md
|
||||
- alias ColoredDotsTable : types/ColoredDotsTable.md
|
||||
- alias Neighbours : types/MapGen.Triangle.Neighbours.md
|
||||
- alias PastCalcNoiseValue : types/MapGen.PastCalcNoiseValue.md
|
||||
- alias generateFunc : types/generateFunc.md
|
||||
- class Biome : types/MapGen.Biome.md
|
||||
- class BiomeDef : types/MapGen.BiomeDef.md
|
||||
- class Cavern : types/MapGen.Cavern.md
|
||||
- class CavernDef : types/MapGen.CavernDef.md
|
||||
- class Decoration : types/MapGen.Decoration.md
|
||||
- class Edge : types/MapGen.Triangulation.Edge.md
|
||||
- class FakePeak : types/MapGen.Triangulation.FakePeak.md
|
||||
- class GroundNodes : types/MapGen.Biome.GroundNodes.md
|
||||
- class GroundNodesIDs : types/MapGen.Biome.GroundNodesIDs.md
|
||||
- class Layer : types/MapGen.Layer.md
|
||||
- class LayerDef : types/MapGen.LayerDef.md
|
||||
- class MapGen : types/MapGen.md
|
||||
- class MapGenDef : types/MapGenDef.md
|
||||
- class Peak : types/MapGen.Peak.md
|
||||
- class PeakDef : types/MapGen.PeakDef.md
|
||||
- class StaticLayer : types/MapGen.StaticLayer.md
|
||||
- class StaticLayerDef : types/MapGen.StaticLayerDef.md
|
||||
- class Tetrahedron : types/MapGen.Tetrahedron.md
|
||||
- class Triangle : types/MapGen.Triangle.md
|
||||
- class Triangulation : types/MapGen.Triangulation.md
|
||||
|
||||
|
||||
|
||||
- Modules:
|
||||
- MapGen : modules/MapGen.md
|
||||
- MapGen.Biome : modules/MapGen.Biome.md
|
||||
- MapGen.Biome.GroundNodes : modules/MapGen.Biome.GroundNodes.md
|
||||
- MapGen.Biome.GroundNodesIds : modules/MapGen.Biome.GroundNodesIds.md
|
||||
- MapGen.Cavern : modules/MapGen.Cavern.md
|
||||
- MapGen.Decoration : modules/MapGen.Decoration.md
|
||||
- MapGen.Layer : modules/MapGen.Layer.md
|
||||
- MapGen.Peak : modules/MapGen.Peak.md
|
||||
- MapGen.StaticLayer : modules/MapGen.StaticLayer.md
|
||||
- MapGen.Tetrahedron : modules/MapGen.Tetrahedron.md
|
||||
- MapGen.Triangle : modules/MapGen.Triangle.md
|
||||
- MapGen.Triangulation : modules/MapGen.Triangulation.md
|
||||
- MapGen.Triangulation.Edge : modules/MapGen.Triangulation.Edge.md
|
||||
- MapGen.Triangulation.FakePeak : modules/MapGen.Triangulation.FakePeak.md
|
||||
- MapGen.ff2luat : modules/MapGen.ff2luat.md
|
||||
|
||||
|
||||
|
||||
extra:
|
||||
footer: ""
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
local modInfo = Mod.getInfo('smc__core__item')
|
||||
local require = modInfo.require
|
||||
|
||||
@@ -96,7 +98,7 @@ function Item:new(itemDef)
|
||||
itemDef = defMerge(itemDef, self.defaultDef, true)
|
||||
|
||||
---@type Item
|
||||
local instance = setmetatable({}, {__index = self})
|
||||
local instance = getInstance(self, {})
|
||||
|
||||
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||
local visual = itemDef.settings.visual
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class ItemFactory
|
||||
---@field defaultDef Item.ItemDefinition|Node.NodeDefinition
|
||||
---@field itemClass Item|Node
|
||||
@@ -8,10 +10,10 @@ local ItemFactory = {}
|
||||
---@return ItemFactory
|
||||
function ItemFactory:new(itemClass, defaultDef)
|
||||
---@type ItemFactory
|
||||
local instance = setmetatable({
|
||||
local instance =getInstance(self, {
|
||||
defaultDef = defaultDef,
|
||||
itemClass = itemClass,
|
||||
}, {__index = self})
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
local mathAbs, mathRound, mathMin, mathMax, id
|
||||
= math.abs, math.round, math.min, math.max, core.get_content_id
|
||||
|
||||
---@class MapGen.PastCalcNoiseValue
|
||||
local pastCalcNoiseValue = {
|
||||
---@type MapGen.Triangle?
|
||||
triangle = nil,
|
||||
---@type number?
|
||||
x = nil,
|
||||
---@type number?
|
||||
z = nil,
|
||||
---@type number?
|
||||
noiseValue = nil,
|
||||
}
|
||||
|
||||
---@type table<MapGen.Layer.Category, MapGen.PastCalcNoiseValue>
|
||||
local pastNoise2DCalc = {
|
||||
landscape = pastCalcNoiseValue,
|
||||
temp = pastCalcNoiseValue,
|
||||
humidity = pastCalcNoiseValue
|
||||
}
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||
local require = modInfo.require
|
||||
|
||||
---@alias MapGen.PastCalcNoiseValue {triangle:MapGen.Triangle?, x:integer?, z:integer?, noiseValue:number?}
|
||||
|
||||
---@type table<MapGen.Layer.Category, MapGen.PastCalcNoiseValue>
|
||||
local pastNoise2DCalc = {
|
||||
landscape = {},
|
||||
temp = {},
|
||||
humidity = {}
|
||||
}
|
||||
|
||||
---@type MapGen.Layer
|
||||
local Layer = require('MapGen.Layer')
|
||||
|
||||
@@ -41,32 +33,35 @@ local Triangulation = require('MapGen.Triangulation')
|
||||
---@type MapGen.Cavern
|
||||
local Cavern = require('MapGen.Cavern')
|
||||
|
||||
---@type MapGen.Region
|
||||
local Region = require('MapGen.Region')
|
||||
|
||||
local ff2luat = require('MapGen.ff2luat')
|
||||
|
||||
---@class MapGen
|
||||
---@field layersByName table<string, MapGen.Layer>
|
||||
---@field layersList MapGen.Layer[]
|
||||
---@field staticsByName table<string, MapGen.StaticLayer>
|
||||
---@field staticsList MapGen.StaticLayer[]
|
||||
---@field layersNoisesInitialized boolean Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
||||
---@field cavernsNoiseInitialized boolean Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
||||
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||
---@field nodeIDs table<string, number>
|
||||
---@field layersByName table<string, MapGen.Layer>
|
||||
---@field layersList MapGen.Layer[]
|
||||
---@field staticsByName table<string, MapGen.StaticLayer>
|
||||
---@field staticsList MapGen.StaticLayer[]
|
||||
---@field isLayersNoisesInitialized boolean Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
||||
---@field isCavernsNoiseInitialized boolean Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
||||
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||
---@field nodeIDs table<string, number>
|
||||
local MapGen = {
|
||||
layersByName = {},
|
||||
layersList = {},
|
||||
staticsByName = {},
|
||||
staticsList = {},
|
||||
layersNoisesInitialized = false,
|
||||
cavernsNoiseInitialized = false,
|
||||
isRunning = false,
|
||||
isLayersNoisesInitialized = false,
|
||||
isCavernsNoiseInitialized = false,
|
||||
isRunning = false,
|
||||
}
|
||||
|
||||
---Definition table for the `MapGen`.
|
||||
---
|
||||
---**Only for EmmyLua.**
|
||||
---@class MapGenDef
|
||||
---@field nodes table<string, string>
|
||||
---@field nodes table<string, string>
|
||||
|
||||
---@param def MapGenDef
|
||||
---@return MapGen
|
||||
@@ -78,14 +73,25 @@ function MapGen:new(def)
|
||||
end
|
||||
|
||||
---@type MapGen
|
||||
local instance = setmetatable({
|
||||
nodes = def.nodes,
|
||||
nodeIDs = nodesIDs,
|
||||
}, {__index = self})
|
||||
local instance = getInstance(self, {
|
||||
nodes = def.nodes,
|
||||
nodeIDs = nodesIDs,
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
---Returns a layer by name. If such a layer does not exist, an error will be raised.
|
||||
---@param layerName string The name of the layer to be retrieved.
|
||||
---@return MapGen.Layer
|
||||
function MapGen:getLayerByName(layerName)
|
||||
local layer = self.layersByName[layerName]
|
||||
|
||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
---Determines which layer a node belongs to based on its height coordinate.
|
||||
---@param yPos number
|
||||
---@return MapGen.Layer?
|
||||
@@ -124,6 +130,229 @@ function MapGen:getStaticByHeight(yPos)
|
||||
end
|
||||
end
|
||||
|
||||
---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`.
|
||||
---@param layer string|MapGen.Layer The layer or name of the layer in which the peak is located.
|
||||
---@param category MapGen.Layer.Category The category in which the peak is located.
|
||||
---@param pos Position Coordinate of the desired peak.
|
||||
---@return MapGen.Peak?
|
||||
function MapGen:getPeakByPos(layer, category, pos)
|
||||
if type(layer) == 'string' then
|
||||
local layerName = layer
|
||||
layer = self:getLayerByName(layerName)
|
||||
end
|
||||
|
||||
return layer:getPeakByPos(category, pos)
|
||||
end
|
||||
|
||||
---Returns `true` if the point is within the triangle's region.
|
||||
---The barycentric coordinate method is used.
|
||||
---@param px integer
|
||||
---@param pz integer
|
||||
---@param triangle MapGen.Triangle
|
||||
local function pointInTriangle2D(px, pz, triangle)
|
||||
local posP = vector.new(px, 0, pz)
|
||||
local pos1 = triangle.p1.getPeakPos()
|
||||
local pos2 = triangle.p2.getPeakPos()
|
||||
local pos3 = triangle.p3.getPeakPos()
|
||||
|
||||
local v0 = pos3 - pos1
|
||||
local v1 = pos2 - pos1
|
||||
local v2 = posP - pos1
|
||||
|
||||
local dot00 = vector.dot(v0, v0)
|
||||
local dot01 = vector.dot(v0, v1)
|
||||
local dot02 = vector.dot(v0, v2)
|
||||
local dot11 = vector.dot(v1, v1)
|
||||
local dot12 = vector.dot(v1, v2)
|
||||
|
||||
local invDenom = 1 / (dot00 * dot11 - dot01 * dot01)
|
||||
local u = (dot11 * dot02 - dot01 * dot12) * invDenom
|
||||
local v = (dot00 * dot12 - dot01 * dot02) * invDenom
|
||||
|
||||
return (u >= 0) and (v >= 0) and (u + v <= 1)
|
||||
end
|
||||
|
||||
---Returns the `MapGen.Triangle` at the coordinates. If there is no triangle at these coordinates, it returns `nil`.
|
||||
---
|
||||
---**Important:** works only in the XZ plane.
|
||||
---@param layer string|MapGen.Layer The layer or name of the layer the triangle is in.
|
||||
---@param category MapGen.Layer.Category The category in which the triangle is in.
|
||||
---@param pos Position Coordinate of the desired peak.
|
||||
---@return MapGen.Triangle?
|
||||
function MapGen:getTriangleByPos2D(layer, category, pos)
|
||||
if type(layer) == 'string' then
|
||||
local layerName = layer
|
||||
layer = self:getLayerByName(layerName)
|
||||
end
|
||||
|
||||
for _, triangle in ipairs(layer.trianglesList[category]) do
|
||||
if pointInTriangle2D(pos.x, pos.z, triangle) then
|
||||
return triangle
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Checks if a point is inside a region.
|
||||
---If the point is inside the region, it will also return the distance to the nearest border.
|
||||
---@param layer MapGen.Layer The name of the layer in which the region is located.
|
||||
---@param regionName string The name of the region in which the location of the point is checked.
|
||||
---@param point Position Point position.
|
||||
---@return boolean, number?
|
||||
function MapGen:pointInRegion2D(layer, regionName, point)
|
||||
local region = layer.regionsByName[regionName]
|
||||
|
||||
assert(layer ~= nil, ('There is no region named `%s` registered.'):format(regionName))
|
||||
|
||||
return region:pointInRegion(point)
|
||||
end
|
||||
|
||||
---Returns `true` if there is a cavern at the specified coordinates.
|
||||
---@param layer MapGen.Layer
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return boolean
|
||||
function MapGen:isCavern(layer, x, y, z)
|
||||
for _, cavern in ipairs(layer.cavernsList) do
|
||||
if cavern.isRegional then
|
||||
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, {x=x,y=y,z=z})
|
||||
|
||||
if inRegion and distance ~= nil then
|
||||
if cavern:isCavern(x, y, z, distance) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
else
|
||||
if cavern:isLayeredCavern(x, y, z) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---Creates a unique key for a vertex (using X and Z coordinates).
|
||||
---@param peak MapGen.Peak
|
||||
---@return string
|
||||
local function vertexKey(peak)
|
||||
local pos = peak:getPeakPos()
|
||||
|
||||
return string.format("%.6f,%.6f", pos.x, pos.z)
|
||||
end
|
||||
|
||||
---Creates a canonical (sorted) key for an edge.
|
||||
---@param edge MapGen.Triangulation.Edge
|
||||
---@return string
|
||||
local function edgeKey(edge)
|
||||
local k1 = vertexKey(edge.p1)
|
||||
local k2 = vertexKey(edge.p2)
|
||||
|
||||
if k1 < k2 then
|
||||
return k1 .. "|" .. k2
|
||||
else
|
||||
return k2 .. "|" .. k1
|
||||
end
|
||||
end
|
||||
|
||||
---Calculates the outer boundary of a triangulated region.
|
||||
---Works on the XZ horizontal plane.
|
||||
---@param triangles MapGen.Triangle[]
|
||||
---@return table
|
||||
function MapGen:getTriangulateBoundaryVertices(triangles)
|
||||
-- Count how many triangles share each edge
|
||||
local edgeCount = {}
|
||||
---@type table<string, MapGen.Triangulation.Edge>
|
||||
local edgeData = {}
|
||||
|
||||
for _, triangle in ipairs(triangles) do
|
||||
local edges = {
|
||||
triangle.e1,
|
||||
triangle.e2,
|
||||
triangle.e3
|
||||
}
|
||||
|
||||
for _, edge in ipairs(edges) do
|
||||
local key = edgeKey(edge)
|
||||
|
||||
edgeCount[key] = (edgeCount[key] or 0) + 1
|
||||
edgeData[key] = edge
|
||||
end
|
||||
end
|
||||
|
||||
-- Boundary edges belong to exactly ONE triangle
|
||||
---@type MapGen.Triangulation.Edge[]
|
||||
local boundaryEdges = {}
|
||||
|
||||
for key, count in pairs(edgeCount) do
|
||||
if count == 1 then
|
||||
table.insert(boundaryEdges, edgeData[key])
|
||||
end
|
||||
end
|
||||
|
||||
if #boundaryEdges == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
-- Build adjacency list for boundary vertices
|
||||
---@type table<string, MapGen.Peak>
|
||||
local adjacency = {}
|
||||
---@type table<string, MapGen.Peak>
|
||||
local vertexData = {}
|
||||
|
||||
for _, edge in ipairs(boundaryEdges) do
|
||||
local k1 = vertexKey(edge.p1)
|
||||
local k2 = vertexKey(edge.p2)
|
||||
|
||||
vertexData[k1] = edge.p1
|
||||
vertexData[k2] = edge.p2
|
||||
|
||||
adjacency[k1] = adjacency[k1] or {}
|
||||
adjacency[k2] = adjacency[k2] or {}
|
||||
|
||||
table.insert(adjacency[k1], k2)
|
||||
table.insert(adjacency[k2], k1)
|
||||
end
|
||||
|
||||
-- Walk along boundary edges to create ordered vertex list
|
||||
---@type Position[]
|
||||
local boundary = {}
|
||||
---@type table<string, boolean>
|
||||
local visited = {}
|
||||
|
||||
if boundaryEdges[1] == nil then
|
||||
error()
|
||||
end
|
||||
|
||||
---@type string?
|
||||
local currentKey = vertexKey(boundaryEdges[1].p1)
|
||||
|
||||
while currentKey and not visited[currentKey] do
|
||||
visited[currentKey] = true
|
||||
local pos = vertexData[currentKey]:getPeakPos()
|
||||
|
||||
table.insert(boundary, {
|
||||
x = pos.x,
|
||||
y = 0,
|
||||
z = pos.z
|
||||
})
|
||||
|
||||
-- Move to next unvisited neighbor
|
||||
local nextKey = nil
|
||||
|
||||
for _, neighborKey in ipairs(adjacency[currentKey] or {}) do
|
||||
if not visited[neighborKey] then
|
||||
nextKey = neighborKey
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
currentKey = nextKey
|
||||
end
|
||||
|
||||
return boundary
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- --- REGISTRATION METHODS ---
|
||||
@@ -158,10 +387,7 @@ end
|
||||
---@param color ColorString Noise color. Must be unique.
|
||||
---@param noiseParams NoiseParams Fractal noise parameters.
|
||||
function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams)
|
||||
---@type MapGen.Layer
|
||||
local layer = self.layersByName[layerName]
|
||||
|
||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
||||
local layer = self:getLayerByName(layerName)
|
||||
|
||||
layer:addNoiseParamsColor(category, color, noiseParams)
|
||||
end
|
||||
@@ -192,17 +418,16 @@ end
|
||||
|
||||
---Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
---
|
||||
---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
---Note: The peaks shouldn't overlap.
|
||||
---@param layerName string The name of the layer in which the new peak will be included.
|
||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peak.
|
||||
---@param def MapGen.PeakDef Peak description table, see details `MapGen.PeakDef`.
|
||||
function MapGen:registerPeak(layerName, category, def)
|
||||
---@type MapGen.Layer
|
||||
local layer = self.layersByName[layerName]
|
||||
local layer = self:getLayerByName(layerName)
|
||||
|
||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
||||
|
||||
--TODO: добавить проверку, что координата пиков не совпадают
|
||||
--assert(self:getPeakByPos(layer, category, def.pos) == nil,
|
||||
--('In the `%s` layer in the `%s` category there is already a peak with coordinates: %s, %s, %s.'):format(
|
||||
-- layerName, category, def.pos.x, def.pos.y, def.pos.z))
|
||||
|
||||
---@type MapGen.Peak
|
||||
local peak = Peak:new(def)
|
||||
@@ -213,7 +438,7 @@ end
|
||||
---Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation.
|
||||
---The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
---
|
||||
---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
---Note: The peaks shouldn't overlap.
|
||||
---@param layerName string The name of the layer in which the new peak will be included.
|
||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peak.
|
||||
---@param def MapGen.PeakDef Peak description table, see details `MapGen.PeakDef`.
|
||||
@@ -234,7 +459,7 @@ end
|
||||
---Mark the world points as `MapGen.Peak` and assign them all a specific noise that will affect generation.
|
||||
---The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field.
|
||||
---
|
||||
---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation.
|
||||
---Note: The peaks shouldn't overlap.
|
||||
---@param layerName string The name of the layer in which the new peaks will be included.
|
||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peaks.
|
||||
---@param defs MapGen.PeakDef[] Peaks description table, see details `MapGen.PeakDef`.
|
||||
@@ -252,17 +477,34 @@ end
|
||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peaks.
|
||||
---@param groups? table<string, number> Groups that will be added to all peaks.
|
||||
function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups)
|
||||
if scale < 2 then
|
||||
error('The map scale should not be less than 2.')
|
||||
end
|
||||
|
||||
local modPath = core.get_modpath(core.get_current_modname())
|
||||
local peaks = ff2luat(modPath .. '/textures/maps/' .. map)
|
||||
|
||||
---@type {h:integer, w:integer}
|
||||
local mapSize = peaks.size
|
||||
peaks.size = nil
|
||||
|
||||
zeroPos.x = zeroPos.x + mathRound(mapSize.w/2)
|
||||
zeroPos.y = zeroPos.y + mathRound(mapSize.h/2)
|
||||
|
||||
local x, z
|
||||
|
||||
for color, peaksPos in pairs(peaks) do
|
||||
for _, peakPos in ipairs(peaksPos) do
|
||||
x, z = (peakPos.x - zeroPos.x - 1) * scale, (peakPos.y - zeroPos.y - 1) * -scale
|
||||
|
||||
-- Converting a rectangular grid into an isometric-like one.
|
||||
if peakPos.y % 2 == 1 then
|
||||
x = x + (scale/2)
|
||||
end
|
||||
|
||||
---@type MapGen.PeakDef
|
||||
local def = {
|
||||
pos = vector.new((peakPos.x - zeroPos.x) * scale, 0, (peakPos.y - zeroPos.y) * scale),
|
||||
pos = vector.new(x, 0, z),
|
||||
color = color,
|
||||
groups = groups,
|
||||
}
|
||||
@@ -272,14 +514,28 @@ function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category,
|
||||
end
|
||||
end
|
||||
|
||||
---Adds groups to the already registered groups in the peak by coordinate.
|
||||
---If the peak does not exist, an error will be raised.
|
||||
---@param layerName string The name of the layer in which the new peak will be included.
|
||||
---@param category MapGen.Layer.Category Category indicating what will be generated by peak.
|
||||
---@param pos Position The position of the peak to which the group should be added.
|
||||
---@param groups table<string, number> Groups to be added.
|
||||
function MapGen:addGroupsToPeakByPos(layerName, category, pos, groups)
|
||||
local layer = self:getLayerByName(layerName)
|
||||
|
||||
local peak = self:getPeakByPos(layer, category, pos)
|
||||
assert( peak ~= nil, ('In the `%s` layer in the `%s` category there is no peak with coordinates: %s, %s, %s.'):format(
|
||||
layerName, category, pos.x, pos.y, pos.z))
|
||||
|
||||
peak:addGroups(groups)
|
||||
end
|
||||
|
||||
---Mark a point on the biomes diagram and constrain the world area by height to mark it as `MapGen.Biome`.
|
||||
---@param layerName string The name of the layer in which the new biome will be included.
|
||||
---@param biomeName string The name to be assigned to the biome. The name must be unique for each biome.
|
||||
---@param def MapGen.BiomeDef Biome description table, see details `MapGen.BiomeDef`
|
||||
function MapGen:registerBiome(layerName, biomeName, def)
|
||||
local layer = self.layersByName[layerName]
|
||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
||||
assert(layer.biomesByName[biomeName] == nil, ('A biome named `%s` already exists in the `%s` layer.'):format(biomeName, layerName))
|
||||
local layer = self:getLayerByName(layerName)
|
||||
|
||||
local biome = Biome:new(biomeName, def)
|
||||
|
||||
@@ -290,27 +546,68 @@ end
|
||||
---@param layerName string The name of the layer in which the new cavern will be included.
|
||||
---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern.
|
||||
---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef`
|
||||
function MapGen:registerCavern(layerName, cavernName, def)
|
||||
local layer = self.layersByName[layerName]
|
||||
assert(layer ~= nil, ('There is no layer named `%s` registered.'):format(layerName))
|
||||
assert(layer.cavernsByName[cavernName] == nil, ('A cavern named `%s` already exists in the `%s` layer.'):format(cavernName, layerName))
|
||||
---@param regionVertices Position[]? The region to which the cave generation will be limited.
|
||||
function MapGen:registerCavern(layerName, cavernName, def, regionVertices)
|
||||
local layer = self:getLayerByName(layerName)
|
||||
|
||||
if regionVertices ~= nil then
|
||||
self:registerRegion(layerName, cavernName, {
|
||||
vertices = regionVertices
|
||||
})
|
||||
|
||||
def.isRegional = true
|
||||
end
|
||||
|
||||
local cavern = Cavern:new(cavernName, def)
|
||||
|
||||
layer:addCavern(cavernName, cavern)
|
||||
end
|
||||
|
||||
---Mark the world region between the vertices as `MapGen.Region` and give it a name.
|
||||
---@param layerName string The name of the layer in which the new region will be included.
|
||||
---@param regionName string The name to be assigned to the region. The name must be unique for each region.
|
||||
---@param def MapGen.RegionDef Region description table, see details `MapGen.RegionDef`
|
||||
function MapGen:registerRegion(layerName, regionName, def)
|
||||
if regionName == 'landscape_boundary' or
|
||||
regionName == 'temp_boundary' or
|
||||
regionName == 'humidity_boundary' then
|
||||
error(('The name `%s` is reserved for special regions and cannot be used.'):format(regionName))
|
||||
end
|
||||
|
||||
local layer = self:getLayerByName(layerName)
|
||||
|
||||
local region = Region:new(regionName, def)
|
||||
|
||||
layer:addRegion(regionName, region)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- --- INITIALIZATION METHODS ---
|
||||
|
||||
---Initialize the boundary region for a triangulated area.
|
||||
---@param layer MapGen.Layer
|
||||
---@param category MapGen.Layer.Category
|
||||
---@param triangles MapGen.Triangle[]
|
||||
function MapGen:initTriangultaionBoundaryRegion(layer, category, triangles)
|
||||
local regionVertices = self:getTriangulateBoundaryVertices(triangles)
|
||||
|
||||
local regionName = category..'_boundary'
|
||||
|
||||
local region = Region:new(regionName, {vertices = regionVertices})
|
||||
|
||||
layer:addRegion(regionName, region)
|
||||
end
|
||||
|
||||
---Divide all layers into triangles whose vertices are the `Mapgen.Peak` belonging to these layers.
|
||||
function MapGen:initLayersTriangultaion()
|
||||
---@param layer MapGen.Layer
|
||||
for _, layer in ipairs(self.layersList) do
|
||||
for category, peaks in pairs(layer.peaksList) do
|
||||
local triangles = Triangulation.triangulate(peaks)
|
||||
|
||||
layer.trianglesList[category] = Triangulation.triangulate(peaks)
|
||||
layer.trianglesList[category] = triangles
|
||||
--self:initTriangultaionBoundaryRegion(layer, category, triangles)
|
||||
-- layer.tetrahedronsList = Triangulation.tetrahedralize(layer.peaksList) -- 3D not supported
|
||||
end
|
||||
end
|
||||
@@ -344,29 +641,13 @@ function MapGen:initCavernsNoise()
|
||||
|
||||
end
|
||||
|
||||
self.cavernsNoiseInitialized = true
|
||||
self.isCavernsNoiseInitialized = true
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- --- GENERATION METHODS ---
|
||||
|
||||
---Returns `true` if there is a cavern at the specified coordinates.
|
||||
---@param layer MapGen.Layer
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@return boolean
|
||||
local function isCavern(layer, x, y, z)
|
||||
for _, cavern in ipairs(layer.cavernsList) do
|
||||
if cavern:isCavern(x, y, z) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
||||
---and which biome will be generated at the specified coordinates.
|
||||
---@param mapGenerator MapGen
|
||||
@@ -376,9 +657,9 @@ end
|
||||
---@param humidity number
|
||||
---@param data number[]
|
||||
---@param index number
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
|
||||
local ids = mapGenerator.nodeIDs
|
||||
local waterLevel = layer.waterLevel
|
||||
@@ -388,17 +669,15 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
||||
local scatteringVertical = layer.biomesVerticalScattering or 0
|
||||
local scattTemp = temp
|
||||
local scattHumidity = humidity
|
||||
---@type number
|
||||
local scattHeight = y
|
||||
|
||||
if scatteringGorizontal ~= 0 then
|
||||
---@diagnostic disable-next-line: param-type-not-match
|
||||
scattTemp = scattTemp + math.random(scatteringGorizontal * -1, scatteringGorizontal)
|
||||
---@diagnostic disable-next-line: param-type-not-match
|
||||
scattHumidity = scattHumidity + math.random(scatteringGorizontal * -1, scatteringGorizontal)
|
||||
end
|
||||
|
||||
if scatteringVertical ~= 0 then
|
||||
---@diagnostic disable-next-line: param-type-not-match
|
||||
scattHeight = scattHeight + math.random(scatteringVertical * -1, scatteringVertical)
|
||||
end
|
||||
|
||||
@@ -425,7 +704,7 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
||||
-- If the block is below the surface height...
|
||||
elseif y <= height then
|
||||
-- ... and a cavern is generated in the block...
|
||||
if isCavern(layer, x, y, z) then
|
||||
if mapGenerator:isCavern(layer, x, y, z) then
|
||||
-- ... then airspace is generated.
|
||||
biome:generateCavernAir(mapGenerator, data, index, x, y, z)
|
||||
|
||||
@@ -467,9 +746,9 @@ end
|
||||
---the triangle's height and specifying the distance to the peak
|
||||
---for which the weight is calculated.
|
||||
---@param height MapGen.Triangulation.Edge
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return number
|
||||
local function calcWeight(height, x, y, z)
|
||||
local pos1 = vector.new(x, y, z)
|
||||
@@ -489,43 +768,23 @@ local function calcWeight(height, x, y, z)
|
||||
return 1 - vector.distance(pos2, posP) / height:length()
|
||||
end
|
||||
|
||||
---Returns `true` if the point is within the triangle's region.
|
||||
---The barycentric coordinate method is used.
|
||||
---@param px number
|
||||
---@param pz number
|
||||
---@param triangle MapGen.Triangle
|
||||
local function pointInTriangle(px, pz, triangle)
|
||||
local posP = vector.new(px, 0, pz)
|
||||
local pos1 = triangle.p1.getPeakPos()
|
||||
local pos2 = triangle.p2.getPeakPos()
|
||||
local pos3 = triangle.p3.getPeakPos()
|
||||
|
||||
local v0 = pos3 - pos1
|
||||
local v1 = pos2 - pos1
|
||||
local v2 = posP - pos1
|
||||
|
||||
local dot00 = vector.dot(v0, v0)
|
||||
local dot01 = vector.dot(v0, v1)
|
||||
local dot02 = vector.dot(v0, v2)
|
||||
local dot11 = vector.dot(v1, v1)
|
||||
local dot12 = vector.dot(v1, v2)
|
||||
|
||||
local invDenom = 1 / (dot00 * dot11 - dot01 * dot01)
|
||||
local u = (dot11 * dot02 - dot01 * dot12) * invDenom
|
||||
local v = (dot00 * dot12 - dot01 * dot02) * invDenom
|
||||
|
||||
return (u >= 0) and (v >= 0) and (u + v <= 1)
|
||||
end
|
||||
|
||||
---Returns the weighted values of 2d noise.
|
||||
---@param category MapGen.Layer.Category
|
||||
---@param layer MapGen.Layer
|
||||
---@param triangle MapGen.Triangle
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return number
|
||||
local function calcNoise2dValue(category, layer, triangle, x, y, z)
|
||||
local triangleColor = triangle.color
|
||||
|
||||
-- If the triangle is monochromatic (all peaks have the same color and,
|
||||
-- accordingly, the same noise), then there is no point in smoothing out the noise.
|
||||
if triangleColor ~= nil then
|
||||
return layer:getNoiseByColor(category, triangleColor):get_2d({x = x, y = z})
|
||||
end
|
||||
|
||||
local peak1 = triangle.p1
|
||||
local peak2 = triangle.p2
|
||||
local peak3 = triangle.p3
|
||||
@@ -561,9 +820,9 @@ end
|
||||
---Returns `nil` if the point is not included in any triangle.
|
||||
---@param category MapGen.Layer.Category
|
||||
---@param layer MapGen.Layer
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return number?
|
||||
function MapGen:getNoises2dValue(category, layer, x, y, z)
|
||||
---@type MapGen.PastCalcNoiseValue
|
||||
@@ -573,19 +832,38 @@ function MapGen:getNoises2dValue(category, layer, x, y, z)
|
||||
return pastCalc.noiseValue
|
||||
end
|
||||
|
||||
if pastCalc.triangle ~= nil and pointInTriangle(x, z, pastCalc.triangle) then
|
||||
local noiseValue = calcNoise2dValue(category, layer, pastCalc.triangle, x, y, z)
|
||||
if pastCalc.triangle ~= nil then
|
||||
---@type number?
|
||||
local noiseValue
|
||||
|
||||
pastCalc.x = x
|
||||
pastCalc.z = z
|
||||
pastCalc.noiseValue = noiseValue
|
||||
local triangles = {
|
||||
pastCalc.triangle,
|
||||
pastCalc.triangle.neighbours.t1,
|
||||
pastCalc.triangle.neighbours.t2,
|
||||
pastCalc.triangle.neighbours.t3,
|
||||
}
|
||||
|
||||
return noiseValue
|
||||
---@param t MapGen.Triangle
|
||||
for _, t in ipairs(triangles) do
|
||||
if pointInTriangle2D(x, z, t) then
|
||||
noiseValue = calcNoise2dValue(category, layer, t, x, y, z)
|
||||
|
||||
pastCalc.x = x
|
||||
pastCalc.z = z
|
||||
pastCalc.noiseValue = noiseValue
|
||||
|
||||
return noiseValue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not self:pointInRegion2D(layer, category..'_boundary', {x=x, y=y, z=z}) then
|
||||
return nil
|
||||
end
|
||||
|
||||
---@param triangle MapGen.Triangle
|
||||
for _, triangle in ipairs(layer.trianglesList[category]) do
|
||||
if pointInTriangle(x, z,triangle) then
|
||||
if pointInTriangle2D(x, z, triangle) then
|
||||
local noiseValue = calcNoise2dValue(category, layer, triangle, x, y, z)
|
||||
|
||||
pastCalc.triangle = triangle
|
||||
@@ -696,9 +974,9 @@ end
|
||||
---@param mapGenerator MapGen
|
||||
---@param data number[]
|
||||
---@param index number
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
local function generatorHandler(mapGenerator, data, index, x, y, z)
|
||||
-- If the node belongs to a static layer, then a static node is generated.
|
||||
local static = mapGenerator:getStaticByHeight(y)
|
||||
@@ -716,12 +994,25 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
|
||||
return
|
||||
end
|
||||
|
||||
-- Calculating landscape height
|
||||
-- If the value of the noise is `nil`,
|
||||
-- then the point does not fall within any of the triangles.
|
||||
local noiseHeightValue = mapGenerator:getNoises2dValue('landscape', layer, x, y, z) or 0.0
|
||||
local noiseTempValue = mapGenerator:getNoises2dValue('temp', layer, x, y, z) or 0.0
|
||||
local noiseHumidityValue = mapGenerator:getNoises2dValue('humidity', layer, x, y, z) or 0.0
|
||||
local noiseHeightValue = mapGenerator:getNoises2dValue('landscape', layer, x, y, z)
|
||||
if noiseHeightValue == nil then
|
||||
data[index] = core.CONTENT_IGNORE
|
||||
return
|
||||
end
|
||||
|
||||
local noiseTempValue = mapGenerator:getNoises2dValue('temp', layer, x, y, z)
|
||||
if noiseTempValue == nil then
|
||||
data[index] = core.CONTENT_IGNORE
|
||||
return
|
||||
end
|
||||
|
||||
local noiseHumidityValue = mapGenerator:getNoises2dValue('humidity', layer, x, y, z)
|
||||
if noiseHumidityValue == nil then
|
||||
data[index] = core.CONTENT_IGNORE
|
||||
return
|
||||
end
|
||||
|
||||
-- We recalculate the climate based on altitude.
|
||||
noiseTempValue = layer:calcTemp(noiseTempValue, y)
|
||||
@@ -732,8 +1023,8 @@ end
|
||||
|
||||
---Chunk generation handler.
|
||||
---@param voxelManip VoxelManip
|
||||
---@param minPos table
|
||||
---@param maxPos table
|
||||
---@param minPos Position
|
||||
---@param maxPos Position
|
||||
---@param blockseed number
|
||||
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
-- We obtain a generation area for further manipulations
|
||||
@@ -741,11 +1032,11 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
|
||||
local eMin, eMax = voxelManip:get_emerged_area()
|
||||
|
||||
if not self.layersNoisesInitialized then
|
||||
if not self.isLayersNoisesInitialized then
|
||||
self:initLayersNoises()
|
||||
end
|
||||
|
||||
if not self.cavernsNoiseInitialized then
|
||||
if not self.isCavernsNoiseInitialized then
|
||||
self:initCavernsNoise()
|
||||
end
|
||||
|
||||
@@ -795,6 +1086,7 @@ function MapGen:run()
|
||||
error('Only one instance of a `MapGen` class can be running.')
|
||||
end
|
||||
|
||||
---@param ... VoxelManip
|
||||
core.register_on_generated(function(...)
|
||||
self:onMapGenerated(...)
|
||||
end)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local id = core.get_content_id
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.Biome
|
||||
---@field name string
|
||||
---@field tempPoint number
|
||||
@@ -165,7 +167,7 @@ function Biome:new(name, def)
|
||||
end
|
||||
|
||||
---@type MapGen.Biome
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
name = name,
|
||||
tempPoint = def.tempPoint,
|
||||
humidityPoint = def.humidityPoint,
|
||||
@@ -181,7 +183,7 @@ function Biome:new(name, def)
|
||||
generateSoil = def.generateSoil,
|
||||
generateTurf = def.generateTurf,
|
||||
generateBottom = def.generateBottom,
|
||||
}, {__index = self})
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
local mathMin, mathMax, mathAbs
|
||||
= math.min, math.max, math.abs
|
||||
local mathMin, mathMax, mathAbs, mathClamp
|
||||
= math.min, math.max, math.abs, math.clamp
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.Cavern
|
||||
---@field name string
|
||||
---@field isRegional boolean
|
||||
---@field minY number
|
||||
---@field maxY number
|
||||
---@field smoothDistance number
|
||||
@@ -16,6 +19,7 @@ local Cavern = {}
|
||||
---
|
||||
---**Only for EmmyLua.**
|
||||
---@class MapGen.CavernDef
|
||||
---@field isRegional boolean?
|
||||
---@field minY number
|
||||
---@field maxY number
|
||||
---@field noiseParams NoiseParams
|
||||
@@ -50,13 +54,14 @@ function Cavern:new(name, def)
|
||||
end
|
||||
|
||||
---@type MapGen.Cavern
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
name = name,
|
||||
minY = def.minY,
|
||||
maxY = def.maxY,
|
||||
smoothDistance = def.smoothDistance,
|
||||
threshold = def.threshold,
|
||||
}, {__index = self})
|
||||
isRegional = def.isRegional or false,
|
||||
})
|
||||
|
||||
function instance:getNoise()
|
||||
return _noise
|
||||
@@ -77,32 +82,49 @@ function Cavern:new(name, def)
|
||||
return instance
|
||||
end
|
||||
|
||||
---@param y number
|
||||
---@param minY number
|
||||
---@param maxY number
|
||||
---@param smoothDistance number
|
||||
---@return number
|
||||
local function calcCavernWeight(y, smoothDistance, minY, maxY)
|
||||
local maxDist = maxY - y
|
||||
local minDist = y - minY
|
||||
|
||||
return mathMax(0, mathMin(maxDist / smoothDistance, minDist / smoothDistance, 1))
|
||||
---@param distance number
|
||||
---@return number
|
||||
function Cavern:calcCavernWeight(distance)
|
||||
return mathClamp(distance / self.smoothDistance, 0, 1)
|
||||
end
|
||||
|
||||
---Returns `true` if there is a cavern at the specified coordinates.
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@return boolean
|
||||
function Cavern:isCavern(x, y, z)
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@param distance number
|
||||
---@return boolean
|
||||
function Cavern:isCavern(x, y, z, distance)
|
||||
local minY, maxY = self.minY, self.maxY
|
||||
|
||||
if y >= maxY or y <= minY then
|
||||
return false
|
||||
end
|
||||
|
||||
distance = mathMin(maxY - y, y - minY, distance)
|
||||
|
||||
local noise = self:getNoise()
|
||||
local weight = self:calcCavernWeight(distance)
|
||||
|
||||
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
||||
end
|
||||
|
||||
---Returns `true` if there is a cavern at the specified coordinates.
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return boolean
|
||||
function Cavern:isLayeredCavern(x, y, z)
|
||||
local minY, maxY = self.minY, self.maxY
|
||||
|
||||
if y > maxY or y < minY then
|
||||
return false
|
||||
end
|
||||
|
||||
local distance = mathMin(maxY - y, y - minY)
|
||||
|
||||
local noise = self:getNoise()
|
||||
local weight = calcCavernWeight(y, self.smoothDistance, minY, maxY)
|
||||
local weight = self:calcCavernWeight(distance)
|
||||
|
||||
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---**NOT IMPLEMENTED**
|
||||
---@class MapGen.Decoration
|
||||
local Decoration = {}
|
||||
@@ -5,9 +7,9 @@ local Decoration = {}
|
||||
---@return MapGen.Decoration
|
||||
function Decoration:new()
|
||||
---@type MapGen.Decoration
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
|
||||
}, {__index = self})
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.Layer
|
||||
---@field name string
|
||||
---@field minY number
|
||||
---@field maxY number
|
||||
---@field minTemp number
|
||||
---@field maxTemp number
|
||||
---@field minHumidity number
|
||||
---@field maxHumidity number
|
||||
---@field waterLevel number
|
||||
---@field minY integer
|
||||
---@field maxY integer
|
||||
---@field minTemp integer
|
||||
---@field maxTemp integer
|
||||
---@field minHumidity integer
|
||||
---@field maxHumidity integer
|
||||
---@field waterLevel integer
|
||||
---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number
|
||||
---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number
|
||||
---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]}
|
||||
@@ -15,10 +17,11 @@
|
||||
---@field biomesByName table<string, MapGen.Biome>
|
||||
---@field biomesList MapGen.Biome[]
|
||||
---@field biomesDiagram table
|
||||
---@field biomesGorizontalScattering number
|
||||
---@field biomesVerticalScattering number
|
||||
---@field biomesGorizontalScattering integer
|
||||
---@field biomesVerticalScattering integer
|
||||
---@field cavernsByName table<string, MapGen.Cavern>
|
||||
---@field cavernsList MapGen.Cavern[]
|
||||
---@field regionsByName table<string, MapGen.Region>
|
||||
---@field trianglesList {['landscape']:MapGen.Triangle[],['temp']:MapGen.Triangle[],['humidity']:MapGen.Triangle[]}
|
||||
---@field tetrahedronsList MapGen.Tetrahedron[] **Not supported**
|
||||
local Layer = {
|
||||
@@ -42,6 +45,7 @@ local Layer = {
|
||||
biomesDiagram = {},
|
||||
cavernsByName = {},
|
||||
cavernsList = {},
|
||||
regionsByName = {},
|
||||
trianglesList = {
|
||||
landscape = {},
|
||||
temp = {},
|
||||
@@ -89,7 +93,7 @@ function Layer:new(name, def)
|
||||
end
|
||||
|
||||
---@type MapGen.Layer
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
name = name,
|
||||
minY = def.minY,
|
||||
maxY = def.maxY,
|
||||
@@ -102,7 +106,7 @@ function Layer:new(name, def)
|
||||
calcHumidity = def.calcHumidity,
|
||||
biomesGorizontalScattering = def.biomesGorizontalScattering or 0,
|
||||
biomesVerticalScattering = def.biomesVerticalScattering or 0,
|
||||
}, {__index = self})
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
@@ -125,12 +129,27 @@ function Layer:addPeak(category, peak)
|
||||
end
|
||||
end
|
||||
|
||||
---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`.
|
||||
---@param category MapGen.Layer.Category The category in which the peak is located.
|
||||
---@param pos Position Coordinate of the desired peak.
|
||||
---@return MapGen.Peak?
|
||||
function Layer:getPeakByPos(category, pos)
|
||||
pos = vector.new(pos)
|
||||
|
||||
---@param peak MapGen.Peak
|
||||
for _, peak in ipairs(self.peaksList[category]) do
|
||||
if peak:getPeakPos() == pos then
|
||||
return peak
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Adds a NoiseParams color to the `Layer.noisesParamsByColor`
|
||||
---@param category MapGen.Layer.Category
|
||||
---@param color ColorString
|
||||
---@param noiseParams NoiseParams
|
||||
function Layer:addNoiseParamsColor(category, color, noiseParams)
|
||||
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
|
||||
color = Smc.fixColorString(color)
|
||||
|
||||
local noisesParams = self.noisesParamsByColor
|
||||
|
||||
@@ -153,7 +172,7 @@ end
|
||||
---@param color ColorString
|
||||
---@return ValueNoise
|
||||
function Layer:getNoiseByColor(category, color)
|
||||
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
|
||||
color = Smc.fixColorString(color)
|
||||
|
||||
local noises = self.noisesByColor
|
||||
|
||||
@@ -175,18 +194,69 @@ end
|
||||
---@param biomeName string
|
||||
---@param biome MapGen.Biome
|
||||
function Layer:addBiome(biomeName, biome)
|
||||
assert(self.biomesByName[biomeName] == nil,
|
||||
('A biome named `%s` already exists in the `%s` layer.'):format(
|
||||
biomeName, self.name))
|
||||
|
||||
self.biomesByName[biomeName] = biome
|
||||
table.insert(self.biomesList, biome)
|
||||
end
|
||||
|
||||
---Returns a biome by name, if there is no such biome, it will raise an error.
|
||||
---@param biomeName string
|
||||
---@return MapGen.Biome
|
||||
function Layer:getBiomeByName(biomeName)
|
||||
local biome = self.biomesByName[biomeName]
|
||||
assert(biome ~= nil, ('Biome named `%s` does not exist in the `%s` layer.'):format(
|
||||
biomeName, self.name))
|
||||
|
||||
return biome
|
||||
end
|
||||
|
||||
---Adds a cavern to the `Layer.cavernsByName` & `Layer.cavernsList`
|
||||
---@param cavernName string
|
||||
---@param cavern MapGen.Cavern
|
||||
function Layer:addCavern(cavernName, cavern)
|
||||
assert(self.cavernsByName[cavernName] == nil,
|
||||
('A cavern named `%s` already exists in the `%s` layer.'):format(
|
||||
cavernName, self.name))
|
||||
|
||||
self.cavernsByName[cavernName] = cavern
|
||||
table.insert(self.cavernsList, cavern)
|
||||
end
|
||||
|
||||
---Returns a cavern by name, if there is no such cavern, it will raise an error.
|
||||
---@param cavernName string
|
||||
---@return MapGen.Cavern
|
||||
function Layer:getCavernByName(cavernName)
|
||||
local cavern = self.cavernsByName[cavernName]
|
||||
assert(cavern ~= nil, ('Cavern named `%s` does not exist in the `%s` layer.'):format(
|
||||
cavernName, self.name))
|
||||
|
||||
return cavern
|
||||
end
|
||||
|
||||
function Layer:addRegion(regionName, region)
|
||||
assert(self.regionsByName[regionName] == nil,
|
||||
('A region named `%s` already exists in the `%s` layer.'):format(
|
||||
regionName, self.name))
|
||||
|
||||
self.regionsByName[regionName] = region
|
||||
--table.insert(self.regionsList, region)
|
||||
end
|
||||
|
||||
---Returns a region by name, if there is no such region, it will raise an error.
|
||||
---@param regionName string
|
||||
---@return MapGen.Region
|
||||
function Layer:getRegionByName(regionName)
|
||||
local region = self.regionsByName[regionName]
|
||||
assert(region ~= nil, ('Region named `%s` does not exist in the `%s` layer.'):format(
|
||||
regionName, self.name))
|
||||
|
||||
return region
|
||||
end
|
||||
|
||||
|
||||
---@param height number
|
||||
---@param biomesList MapGen.Biome[]
|
||||
---@return string[], MapGen.Biome[]
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.Peak
|
||||
---@field id number
|
||||
---@field getPeakPos fun():vector
|
||||
---@field getColor fun():ColorString
|
||||
---@field getGroups fun():table<string, number>
|
||||
---@field id number
|
||||
---@field getPeakPos fun(self):vector
|
||||
---@field getColor fun(self):ColorString
|
||||
---@field getGroups fun(self):table<string, number>
|
||||
---@field addGroups fun(self, groups:table<string, number>)
|
||||
local Peak = {
|
||||
id = 0,
|
||||
}
|
||||
@@ -31,9 +34,8 @@ function Peak:new(def)
|
||||
end
|
||||
|
||||
---@type MapGen.Peak
|
||||
local instance = setmetatable({},
|
||||
local instance = getInstance(self,{},
|
||||
{
|
||||
__index = self,
|
||||
__tostring = self.toString,
|
||||
__eq = self.eq
|
||||
})
|
||||
@@ -50,6 +52,14 @@ function Peak:new(def)
|
||||
return table.copy_with_metatables(_groups)
|
||||
end
|
||||
|
||||
function instance:addGroups(groups)
|
||||
-- Groups that cannot be overwritten
|
||||
groups.is2d = nil
|
||||
groups.is3d = nil
|
||||
|
||||
_groups = table.merge(_groups, groups, true)
|
||||
end
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
|
||||
112
mods/CORE/MapGen/src/MapGen/Region.lua
Normal file
112
mods/CORE/MapGen/src/MapGen/Region.lua
Normal file
@@ -0,0 +1,112 @@
|
||||
local mathClamp, mathHuge, mathSqrt = math.clamp, math.huge, math.sqrt
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.Region
|
||||
---@field name string
|
||||
---@field vertices Position[]
|
||||
local Region = {}
|
||||
|
||||
---@class MapGen.RegionDef
|
||||
---@field vertices Position[]
|
||||
|
||||
---@param def MapGen.RegionDef
|
||||
---@return MapGen.Region
|
||||
function Region:new(name, def)
|
||||
local instance = getInstance(self, {
|
||||
name = name,
|
||||
vertices = def.vertices
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
---Calculate squared distance from point to line segment.
|
||||
---@param px integer
|
||||
---@param pz integer
|
||||
---@param x1 integer
|
||||
---@param z1 integer
|
||||
---@param x2 integer
|
||||
---@param z2 integer
|
||||
---@return number
|
||||
local function calcDistanceSq(px, pz, x1, z1, x2, z2)
|
||||
local dx = x2 - x1
|
||||
local dz = z2 - z1
|
||||
local len_sq = dx * dx + dz * dz
|
||||
|
||||
-- Degenerate segment (a single point):
|
||||
if len_sq == 0 then
|
||||
return (px - x1)^2 + (pz - z1)^2
|
||||
end
|
||||
|
||||
-- Project point onto line, clamped to segment [0, 1]
|
||||
local param = mathClamp(((px - x1) * dx + (pz - z1) * dz) / len_sq, 0, 1)
|
||||
|
||||
-- Closest point on segment
|
||||
local closest_x = x1 + param * dx
|
||||
local closest_z = z1 + param * dz
|
||||
|
||||
return (px - closest_x)^2 + (pz - closest_z)^2
|
||||
end
|
||||
|
||||
---Checks if a point is inside a `MapGen.Region` (2D check using x and z coordinates).
|
||||
---@param point Position
|
||||
---@return boolean, number?
|
||||
function Region:pointInRegion(point)
|
||||
local vertices = self.vertices
|
||||
local px, pz = point.x, point.z
|
||||
|
||||
local n = #vertices
|
||||
if n < 3 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Calculate minimum squared distance to any edge
|
||||
local minDistanceSq = mathHuge
|
||||
for i = 1, n do
|
||||
local j = (i % n) + 1
|
||||
local v1, v2 = vertices[i], vertices[j]
|
||||
|
||||
if v1 == nil or v2 == nil then error() end
|
||||
|
||||
local dist_sq = calcDistanceSq(px, pz, v1.x, v1.z, v2.x, v2.z)
|
||||
|
||||
if dist_sq < minDistanceSq then
|
||||
minDistanceSq = dist_sq
|
||||
end
|
||||
end
|
||||
|
||||
local minDistance = mathSqrt(minDistanceSq)
|
||||
|
||||
-- Check if point is on edge (within small epsilon)
|
||||
if minDistance <= 1e-9 then
|
||||
return true, minDistance
|
||||
end
|
||||
|
||||
-- Ray casting algorithm: count edge crossings
|
||||
local inside = false
|
||||
|
||||
for i = 1, n do
|
||||
local j = (i % n) + 1
|
||||
local vi, vj = vertices[i], vertices[j]
|
||||
|
||||
if vi == nil or vj == nil then error() end
|
||||
|
||||
local xi, zi = vi.x, vi.z
|
||||
local xj, zj = vj.x, vj.z
|
||||
|
||||
-- Check if horizontal ray from point (going +x) crosses this edge
|
||||
if ((zi > pz) ~= (zj > pz)) and
|
||||
(px < (xj - xi) * (pz - zi) / (zj - zi) + xi) then
|
||||
inside = not inside
|
||||
end
|
||||
end
|
||||
|
||||
if inside then
|
||||
return true, minDistance
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return Region
|
||||
@@ -1,5 +1,7 @@
|
||||
local id = core.get_content_id
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.StaticLayer
|
||||
---@field name string
|
||||
---@field minY number
|
||||
@@ -43,14 +45,14 @@ function StaticLayer:new(name, def)
|
||||
local staticNodeID = id(def.staticNode)
|
||||
|
||||
---@type MapGen.StaticLayer
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
name = name,
|
||||
minY = def.minY,
|
||||
maxY = def.maxY,
|
||||
staticNode = def.staticNode,
|
||||
staticNodeID = staticNodeID,
|
||||
generateStaticNode = def.generateStaticNode
|
||||
}, {__index = self})
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local mathAbs = math.abs
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||
local require = modInfo.require
|
||||
|
||||
@@ -31,7 +33,7 @@ local Tetrahedron = {}
|
||||
---@param p4 MapGen.Peak
|
||||
---@return MapGen.Tetrahedron
|
||||
function Tetrahedron:new(p1, p2, p3, p4)
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
p1 = p1,
|
||||
p2 = p2,
|
||||
p3 = p3,
|
||||
@@ -44,8 +46,8 @@ function Tetrahedron:new(p1, p2, p3, p4)
|
||||
f2 = Triangle:new(p1, p2, p4),
|
||||
f3 = Triangle:new(p1, p3, p4),
|
||||
f4 = Triangle:new(p2, p3, p4),
|
||||
}, {
|
||||
__index = self,
|
||||
},
|
||||
{
|
||||
__tostring = self.toString
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local mathSqrt, mathAbs
|
||||
= math.sqrt, math.abs
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||
local require = modInfo.require
|
||||
|
||||
@@ -54,6 +56,12 @@ end
|
||||
|
||||
-- --- Class registration ---
|
||||
|
||||
---Adjacent triangles:
|
||||
--- * `t1` with a common side p1-p2
|
||||
--- * `t2` with a common side p2-p3
|
||||
--- * `t3` with a common side p3-p1
|
||||
---@alias MapGen.Triangle.Neighbours {t1:MapGen.Triangle?,t2:MapGen.Triangle?,t3:MapGen.Triangle?}
|
||||
|
||||
---@class MapGen.Triangle
|
||||
---@field p1 MapGen.Peak
|
||||
---@field p2 MapGen.Peak
|
||||
@@ -64,17 +72,30 @@ end
|
||||
---@field h1 MapGen.Triangulation.Edge
|
||||
---@field h2 MapGen.Triangulation.Edge
|
||||
---@field h3 MapGen.Triangulation.Edge
|
||||
local Triangle = {}
|
||||
---@field neighbours MapGen.Triangle.Neighbours
|
||||
---@field color ColorString?
|
||||
local Triangle = {
|
||||
neighbours = {}
|
||||
}
|
||||
|
||||
---@param p1 MapGen.Peak
|
||||
---@param p2 MapGen.Peak
|
||||
---@param p3 MapGen.Peak
|
||||
---@return MapGen.Triangle
|
||||
function Triangle:new( p1, p2, p3 )
|
||||
function Triangle:new(p1, p2, p3)
|
||||
assert(not isFlatAngle(p1, p2, p3), ("angle (p1, p2, p3) is flat:\n %s\n %s\n %s")
|
||||
:format(tostring(p1), tostring(p2), tostring(p3)))
|
||||
|
||||
local instance = setmetatable({
|
||||
---@type ColorString?
|
||||
local color = nil
|
||||
|
||||
local c1, c2, c3 = p1.getColor(), p2.getColor(), p3.getColor()
|
||||
|
||||
if c1 == c2 and c2 == c3 and c3 == c1 then
|
||||
color = c1
|
||||
end
|
||||
|
||||
local instance = getInstance(self, {
|
||||
p1 = p1,
|
||||
p2 = p2,
|
||||
p3 = p3,
|
||||
@@ -83,10 +104,10 @@ function Triangle:new( p1, p2, p3 )
|
||||
h3 = Triangle:getHeight(p3, p1, p2),
|
||||
e1 = Edge:new(p1, p2),
|
||||
e2 = Edge:new(p2, p3),
|
||||
e3 = Edge:new(p3, p1)
|
||||
e3 = Edge:new(p3, p1),
|
||||
color = color
|
||||
},
|
||||
{
|
||||
__index = self,
|
||||
__tostring = self.toString,
|
||||
__eq = self.eq
|
||||
})
|
||||
@@ -130,7 +151,7 @@ function Triangle:getCenter()
|
||||
return (pos1 + pos2 + pos3) / 3
|
||||
end
|
||||
|
||||
---Returns the area of a triangle.
|
||||
---Returns the area of a triangle.
|
||||
---@return number
|
||||
function Triangle:getArea()
|
||||
local a, b, c = self:getSidesLength()
|
||||
@@ -260,6 +281,8 @@ function Triangle:getCircumCircle2D()
|
||||
return c, r
|
||||
end
|
||||
|
||||
---@alias MapGen.Triangle.CircumCircleEnum 'IN'|'BEHIND'|'ON'
|
||||
|
||||
---Checks if a given point lies into the triangle circumcircle.
|
||||
---
|
||||
---Note: This function does not take into account the Y-coordinate,
|
||||
@@ -273,6 +296,7 @@ function Triangle:inCircumCircle2D(p)
|
||||
|
||||
local distance = (c - pos):length()
|
||||
|
||||
|
||||
return distance <= r
|
||||
end
|
||||
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
-- * splitting code into different files (classes);
|
||||
-- * Adapting the code to the mapgen concept;
|
||||
-- * Adding tetrahedralization;
|
||||
-- * Fixed non-determinism by sorting vertices before processing;
|
||||
|
||||
local assert, mathMax, tableRemove
|
||||
= assert, math.max, table.remove
|
||||
local assert, mathMax, tableRemove, tableSort
|
||||
= assert, math.max, table.remove, table.sort
|
||||
|
||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||
local require = modInfo.require
|
||||
@@ -28,6 +29,67 @@ local Triangulation = {
|
||||
convexMultiplier = 1e3,
|
||||
}
|
||||
|
||||
---Finds and writes adjacent triangles into triangles.
|
||||
---@param triangles MapGen.Triangle[]
|
||||
local function findTrianglesNeighbours(triangles)
|
||||
for _, triangle in ipairs(triangles) do
|
||||
for _, t in ipairs(triangles) do
|
||||
if triangle.e1 == t.e1 and triangle.p3 ~= t.p3 then
|
||||
triangle.neighbours.t1 = t
|
||||
elseif triangle.e2 == t.e2 and triangle.p3 ~= t.p1 then
|
||||
triangle.neighbours.t2 = t
|
||||
elseif triangle.e3 == t.e3 and triangle.p3 ~= t.p2 then
|
||||
triangle.neighbours.t3 = t
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Filter vertices by group and return a new table
|
||||
---@param vertices table<integer, MapGen.Peak>
|
||||
---@param groupKey string
|
||||
---@return table<integer, MapGen.Peak>
|
||||
local function filterVerticesByGroup(vertices, groupKey)
|
||||
local result = {}
|
||||
for i = 1, #vertices do
|
||||
local vertex = vertices[i]
|
||||
if vertex:getGroups()[groupKey] ~= nil then
|
||||
result[#result + 1] = vertex
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
---Sort vertices deterministically by position to ensure consistent triangulation
|
||||
---@param vertices table<integer, MapGen.Peak>
|
||||
local function sortVerticesDeterministically(vertices)
|
||||
tableSort(vertices, function(a, b)
|
||||
local posA = a:getPeakPos()
|
||||
local posB = b:getPeakPos()
|
||||
|
||||
-- Sort by X first
|
||||
if posA.x ~= posB.x then
|
||||
return posA.x < posB.x
|
||||
end
|
||||
|
||||
-- Then by Z
|
||||
if posA.z ~= posB.z then
|
||||
return posA.z < posB.z
|
||||
end
|
||||
|
||||
-- Then by Y
|
||||
if posA.y ~= posB.y then
|
||||
return posA.y < posB.y
|
||||
end
|
||||
|
||||
-- Fallback to unique identifier if positions are identical
|
||||
-- This handles potential duplicate positions
|
||||
local nameA = a.getName and a:getName() or ""
|
||||
local nameB = b.getName and b:getName() or ""
|
||||
return nameA < nameB
|
||||
end)
|
||||
end
|
||||
|
||||
---The Delaunay method divides a plane into triangles based on a list of their vertices.
|
||||
---
|
||||
---Doesn't take into account the Y coordinate of the vertices.
|
||||
@@ -35,31 +97,28 @@ local Triangulation = {
|
||||
---
|
||||
---Vertices that do not have a `is2d` group will not participate in the triangulation.
|
||||
---@param vertices table<integer, MapGen.Peak>
|
||||
function Triangulation.triangulate( vertices )
|
||||
vertices = table.copy_with_metatables(vertices)
|
||||
function Triangulation.triangulate(vertices)
|
||||
-- Filter vertices with is2d group (creates a new table)
|
||||
vertices = filterVerticesByGroup(vertices, "is2d")
|
||||
|
||||
-- Only peaks with a `is2d` group can be triangulated.
|
||||
for i, vertex in ipairs(vertices) do
|
||||
if vertex:getGroups().is2d == nil then
|
||||
table.remove(vertices, i)
|
||||
end
|
||||
end
|
||||
-- Sort deterministically to ensure consistent results across sessions
|
||||
sortVerticesDeterministically(vertices)
|
||||
|
||||
local nvertices = #vertices
|
||||
|
||||
assert( nvertices > 2, "Cannot triangulate, needs more than 3 vertices" )
|
||||
assert(nvertices > 2, "Cannot triangulate, needs more than 3 vertices")
|
||||
|
||||
if nvertices == 3 then
|
||||
return {Triangle:new(vertices[1], vertices[2], vertices[3])}
|
||||
end
|
||||
|
||||
local minPos = vertices[1].getPeakPos()
|
||||
local minPos = vertices[1]:getPeakPos()
|
||||
local minX, minY = minPos.x, minPos.z
|
||||
local maxX, maxY = minX, minY
|
||||
|
||||
for i = 1, nvertices do
|
||||
local vertex = vertices[i]
|
||||
local vertexPos = vertex.getPeakPos()
|
||||
local vertexPos = vertex:getPeakPos()
|
||||
vertex.id = i
|
||||
|
||||
if vertexPos.x < minX then
|
||||
@@ -79,21 +138,21 @@ function Triangulation.triangulate( vertices )
|
||||
end
|
||||
end
|
||||
|
||||
---Finding the vertices of a supertriangle
|
||||
-- Finding the vertices of a supertriangle
|
||||
local convex_mult = Triangulation.convexMultiplier
|
||||
local dx, dy = (maxX - minX) * convex_mult, (maxY - minY) * convex_mult
|
||||
local deltaMax = mathMax(dx, dy)
|
||||
local midx, midy = (minX + maxX) * 0.5, (minY + maxY) * 0.5
|
||||
|
||||
local p1 = FakePeak:new(vector.new( midx - 2 * deltaMax,0, midy - deltaMax ))
|
||||
local p2 = FakePeak:new(vector.new(midx,0, midy + 2 * deltaMax ))
|
||||
local p3 = FakePeak:new( vector.new(midx + 2 * deltaMax,0, midy - deltaMax ))
|
||||
local p1 = FakePeak:new(vector.new(midx - 2 * deltaMax, 0, midy - deltaMax))
|
||||
local p2 = FakePeak:new(vector.new(midx, 0, midy + 2 * deltaMax))
|
||||
local p3 = FakePeak:new(vector.new(midx + 2 * deltaMax, 0, midy - deltaMax))
|
||||
|
||||
p1.id, p2.id, p3.id = nvertices + 1, nvertices + 2, nvertices + 3
|
||||
vertices[p1.id], vertices[p2.id], vertices[p3.id] = p1, p2, p3
|
||||
|
||||
---@type MapGen.Triangle[]
|
||||
local triangles = {Triangle:new( vertices[nvertices + 1], vertices[nvertices + 2], vertices[nvertices + 3] )}
|
||||
local triangles = {Triangle:new(vertices[nvertices + 1], vertices[nvertices + 2], vertices[nvertices + 3])}
|
||||
|
||||
for i = 1, nvertices do
|
||||
---@type MapGen.Triangulation.Edge[]
|
||||
@@ -107,7 +166,7 @@ function Triangulation.triangulate( vertices )
|
||||
edges[#edges + 1] = curTriangle.e1
|
||||
edges[#edges + 1] = curTriangle.e2
|
||||
edges[#edges + 1] = curTriangle.e3
|
||||
tableRemove( triangles, j )
|
||||
tableRemove(triangles, j)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,8 +174,8 @@ function Triangulation.triangulate( vertices )
|
||||
for j = #edges - 1, 1, -1 do
|
||||
for k = #edges, j + 1, -1 do
|
||||
if edges[j] and edges[k] and edges[j]:same(edges[k]) then
|
||||
tableRemove( edges, j )
|
||||
tableRemove( edges, k-1 )
|
||||
tableRemove(edges, j)
|
||||
tableRemove(edges, k - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -127,19 +186,21 @@ function Triangulation.triangulate( vertices )
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove tetrahedra associated with the vertices of a supertriangle.
|
||||
-- Remove triangles associated with the vertices of a supertriangle.
|
||||
for i = #triangles, 1, -1 do
|
||||
local triangle = triangles[i]
|
||||
if triangle.p1.id > nvertices or triangle.p2.id > nvertices or triangle.p3.id > nvertices then
|
||||
tableRemove( triangles, i )
|
||||
tableRemove(triangles, i)
|
||||
end
|
||||
end
|
||||
|
||||
-- Removing the vertices of a super supertriangle.
|
||||
for _ = 1,3 do
|
||||
tableRemove( vertices )
|
||||
-- Removing the vertices of a supertriangle.
|
||||
for _ = 1, 3 do
|
||||
tableRemove(vertices)
|
||||
end
|
||||
|
||||
findTrianglesNeighbours(triangles)
|
||||
|
||||
return triangles
|
||||
end
|
||||
|
||||
@@ -148,14 +209,11 @@ end
|
||||
---Vertices that do not have a `is3d` group will not participate in the triangulation.
|
||||
---@param vertices table<integer, MapGen.Peak>
|
||||
function Triangulation.tetrahedralize(vertices)
|
||||
vertices = table.copy_with_metatables(vertices)
|
||||
-- Filter vertices with is3d group (creates a new table)
|
||||
vertices = filterVerticesByGroup(vertices, "is3d")
|
||||
|
||||
-- Only peaks with a `is3d` group can be triangulated.
|
||||
for i, vertex in ipairs(vertices) do
|
||||
if vertex:getGroups().is3d == nil then
|
||||
table.remove(vertices, i)
|
||||
end
|
||||
end
|
||||
-- Sort deterministically to ensure consistent results across sessions
|
||||
sortVerticesDeterministically(vertices)
|
||||
|
||||
local nvertices = #vertices
|
||||
|
||||
@@ -165,13 +223,13 @@ function Triangulation.tetrahedralize(vertices)
|
||||
return {Tetrahedron:new(vertices[1], vertices[2], vertices[3], vertices[4])}
|
||||
end
|
||||
|
||||
local minPos = vertices[1].getPeakPos()
|
||||
local minPos = vertices[1]:getPeakPos()
|
||||
local minX, minY, minZ = minPos.x, minPos.y, minPos.z
|
||||
local maxX, maxY, maxZ = minX, minY, minZ
|
||||
|
||||
for i = 1, nvertices do
|
||||
local vertex = vertices[i]
|
||||
local vertexPos = vertex.getPeakPos()
|
||||
local vertexPos = vertex:getPeakPos()
|
||||
vertex.id = i
|
||||
|
||||
if vertexPos.x < minX then
|
||||
@@ -237,8 +295,8 @@ function Triangulation.tetrahedralize(vertices)
|
||||
for j = #faces - 1, 1, -1 do
|
||||
for k = #faces, j + 1, -1 do
|
||||
if faces[j] and faces[k] and faces[j]:same(faces[k]) then
|
||||
tableRemove( faces, j )
|
||||
tableRemove( faces, k-1 )
|
||||
tableRemove(faces, j)
|
||||
tableRemove(faces, k - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -247,20 +305,19 @@ function Triangulation.tetrahedralize(vertices)
|
||||
for j = 1, #faces do
|
||||
tetrahedrons[#tetrahedrons + 1] = Tetrahedron:new(faces[j].p1, faces[j].p2, faces[j].p3, vertices[i])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Remove tetrahedra associated with the vertices of a supertetrahedron.
|
||||
for i = #tetrahedrons, 1, -1 do
|
||||
local tetrahedron = tetrahedrons[i]
|
||||
if tetrahedron.p1.id > nvertices or tetrahedron.p2.id > nvertices or tetrahedron.p3.id > nvertices or tetrahedron.p4.id > nvertices then
|
||||
tableRemove( tetrahedrons, i )
|
||||
tableRemove(tetrahedrons, i)
|
||||
end
|
||||
end
|
||||
|
||||
-- Removing the vertices of a supertetrahedron.
|
||||
for i = 1, 4 do
|
||||
tableRemove( vertices )
|
||||
for _ = 1, 4 do
|
||||
tableRemove(vertices)
|
||||
end
|
||||
|
||||
return tetrahedrons
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class MapGen.Triangulation.Edge
|
||||
---@field p1 MapGen.Peak
|
||||
---@field p2 MapGen.Peak
|
||||
@@ -8,12 +10,11 @@ local Edge = {}
|
||||
---@return MapGen.Triangulation.Edge
|
||||
function Edge:new( p1, p2 )
|
||||
---@type MapGen.Triangulation.Edge
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
p1 = p1,
|
||||
p2 = p2
|
||||
},
|
||||
{
|
||||
__index = self,
|
||||
__tostring = self.toString,
|
||||
__eq = self.eq
|
||||
})
|
||||
|
||||
@@ -66,7 +66,7 @@ local function ff2luat(filepath, backgroundColor)
|
||||
|
||||
if not backgroundColor then backgroundColor = '#000000FF' end
|
||||
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
|
||||
backgroundColor = core.colorspec_to_colorstring(core.colorspec_to_table(backgroundColor))
|
||||
backgroundColor = Smc.fixColorString(backgroundColor)
|
||||
|
||||
---@type ColoredDotsTable
|
||||
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
|
||||
@@ -83,7 +83,7 @@ local function ff2luat(filepath, backgroundColor)
|
||||
}
|
||||
|
||||
---@type string @ColorString
|
||||
local color = core.colorspec_to_colorstring(colorT)
|
||||
local color = core.colorspec_to_colorstring(colorT) or ''
|
||||
|
||||
if color ~= backgroundColor then
|
||||
if not dots[color] then
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local mathRound = math.round
|
||||
|
||||
local getInstance = Class.getInstance
|
||||
|
||||
---@class TileSheet
|
||||
---@field image string Name of texture
|
||||
---@field width number Number of tiles in the table horizontally
|
||||
@@ -70,11 +72,11 @@ function TileSheet:new(image, tileWidth, tileHeight)
|
||||
end
|
||||
|
||||
---@type TileSheet
|
||||
local instance = setmetatable({
|
||||
local instance = getInstance(self, {
|
||||
image = image,
|
||||
width = mathRound(width / tileWidth),
|
||||
height = mathRound(height / tileHeight),
|
||||
}, {__index = self})
|
||||
})
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -12,13 +12,12 @@ listForm:list('current_player', 'main', 10.5, 6.5, 8, 4)
|
||||
|
||||
local listFormItems = Formspec:new()
|
||||
|
||||
local items = core.registered_nodes
|
||||
|
||||
local items = table.get_keys(core.registered_nodes)
|
||||
table.sort(items)
|
||||
local w, h = 0, 0
|
||||
|
||||
---@param name string
|
||||
---@param def NodeDefinition
|
||||
for name, def in pairs(items) do
|
||||
for _, name in ipairs(items) do
|
||||
listFormItems:itemImageButton(w, h, 1, 1, name, name..'::item_button')
|
||||
|
||||
w = w + 1
|
||||
@@ -31,10 +30,9 @@ end
|
||||
|
||||
--listFormItems:list('current_player', 'main', 0, 0, 1, 32)
|
||||
|
||||
listForm:scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical')
|
||||
listForm:scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
|
||||
|
||||
core.log(listForm:toString())
|
||||
listForm:
|
||||
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'):
|
||||
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items')
|
||||
|
||||
core.register_chatcommand('list', {
|
||||
privs = {server = true},
|
||||
@@ -55,9 +53,13 @@ core.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
for key, value in pairs(fields) do
|
||||
if string.ends_with(key, '::item_button') then
|
||||
---@type ItemStackString
|
||||
---@type ItemStackString?
|
||||
local stack = string.match(key, '(%S+)::item_button')
|
||||
|
||||
if stack == nil then
|
||||
return
|
||||
end
|
||||
|
||||
core.log(tostring(stack))
|
||||
|
||||
---@type InvRef
|
||||
|
||||
@@ -37,6 +37,8 @@ dofile(core.get_modpath('smc__system__table')..'/init.lua')
|
||||
-- TODO: пока что закоментировано, поскольку вызывает ошибку из-за global_step
|
||||
-- Smc lib loader
|
||||
-- dofile(core.get_modpath('smc__system__helper_lib')..'/init.lua')
|
||||
Smc = {}
|
||||
dofile(core.get_modpath('smc__system__helper_lib')..'/src/Lib/color.lua')
|
||||
|
||||
---@type MapGen
|
||||
local mapGenerator = dofile(core.get_modpath('smc__core__map_generator')..'/src/mapGenerator.lua')
|
||||
|
||||
@@ -15,14 +15,16 @@ local MapGen = mapGenRequire('MapGen')
|
||||
air = 'air',
|
||||
|
||||
-- Rocks
|
||||
sylite = 'rocks:sylite',
|
||||
tauitite = 'rocks:tauitite',
|
||||
iyellite = 'rocks:iyellite',
|
||||
falmyte = 'rocks:falmyte',
|
||||
hapcoryte = 'rocks:hapcoryte',
|
||||
burcite = 'rocks:burcite',
|
||||
felhor = 'rocks:felhor',
|
||||
malachite = 'rocks:malachite',
|
||||
sylite = 'rocks:sylite',
|
||||
syliteGray = 'rocks:sylite_gray',
|
||||
syliteBlack = 'rocks:sylite_black',
|
||||
tauitite = 'rocks:tauitite',
|
||||
iyellite = 'rocks:iyellite',
|
||||
falmyte = 'rocks:falmyte',
|
||||
hapcoryte = 'rocks:hapcoryte',
|
||||
burcite = 'rocks:burcite',
|
||||
felhor = 'rocks:felhor',
|
||||
malachite = 'rocks:malachite',
|
||||
|
||||
-- Liquids
|
||||
water = 'liquids:water_source',
|
||||
@@ -50,114 +52,411 @@ mapGenerator:registerLayer('midgard', {
|
||||
biomesGorizontalScattering = 5
|
||||
})
|
||||
|
||||
local land1 = {
|
||||
offset = -20,
|
||||
scale = 5,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
|
||||
-- TODO: Config should be imported from .json file in the world's folder
|
||||
local ocean = {
|
||||
['landscape'] = {
|
||||
offset = -10,
|
||||
scale = 3,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 420,
|
||||
octaves = 2,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = -10,
|
||||
scale = 5,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = -10,
|
||||
scale = 5,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local land2 = {
|
||||
offset = 10,
|
||||
scale = 5,
|
||||
spread = {x = 30, y = 30, z = 30},
|
||||
seed = 47,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
}
|
||||
|
||||
local climat1 = {
|
||||
offset = 80,
|
||||
scale = 10,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 8,
|
||||
persistence = 0.6,
|
||||
lacunarity = 2,
|
||||
}
|
||||
|
||||
local climat2 = {
|
||||
offset = 30,
|
||||
scale = 10,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 8,
|
||||
persistence = 0.6,
|
||||
lacunarity = 2,
|
||||
}
|
||||
|
||||
local climat0 = {
|
||||
offset = 50,
|
||||
scale = 0,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 8,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
}
|
||||
|
||||
local v = vector.new
|
||||
--[[
|
||||
mapGenerator:register2DPeaks('midgard',
|
||||
{
|
||||
landscapeNoise = land1,
|
||||
tempNoise = climat2,
|
||||
humidityNoise = climat2,
|
||||
},{
|
||||
v(500, 0, 500),
|
||||
v(-500, 0, -500),
|
||||
v(-500, 0, 500),
|
||||
v(500, 0, -500),
|
||||
})
|
||||
|
||||
mapGenerator:register2DPeaks('midgard',
|
||||
{
|
||||
landscapeNoise = land2,
|
||||
tempNoise = climat1,
|
||||
humidityNoise = climat1,
|
||||
},{
|
||||
v(-300, 0, 300),
|
||||
v(200, 0, -400),
|
||||
})
|
||||
|
||||
mapGenerator:register2DPeaks('midgard',
|
||||
{
|
||||
landscapeNoise = land2,
|
||||
tempNoise = climat2,
|
||||
humidityNoise = climat2,
|
||||
},{
|
||||
v(200, 0, 100),
|
||||
v(-300, 0, -200),
|
||||
})--]]
|
||||
|
||||
for _, c in ipairs({'landscape', 'temp', 'humidity'}) do
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#4978c6', land1)
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#77ea72', land2)
|
||||
end
|
||||
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 64,{x=8, y=8}, 'landscape')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 100,{x=8, y=8}, 'temp')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 100,{x=8, y=8}, 'humidity')
|
||||
|
||||
--[[
|
||||
mapGenerator:registerCavern('midgard', 'cavern1', {
|
||||
minY = -48,
|
||||
maxY = 0,
|
||||
smoothDistance = 20,
|
||||
threshold = 0.3,
|
||||
noiseParams ={
|
||||
local common_lands = {
|
||||
['landscape'] = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x = 25, y = 25, z = 25},
|
||||
seed = 5934,
|
||||
scale = 5,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 88005553535,
|
||||
octaves = 2,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = -10,
|
||||
scale = 5,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = -10,
|
||||
scale = 5,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 47,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local foresty_lands = {
|
||||
['landscape'] = {
|
||||
offset = 5,
|
||||
scale = 8,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 12345,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 20,
|
||||
scale = 10,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 48,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 60,
|
||||
scale = 15,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 49,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local hilly_lands = {
|
||||
['landscape'] = {
|
||||
offset = 15,
|
||||
scale = 12,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 54321,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 15,
|
||||
scale = 10,
|
||||
spread = {x = 25, y = 25, z = 25},
|
||||
seed = 50,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 40,
|
||||
scale = 15,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 51,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local low_mountains = {
|
||||
['landscape'] = {
|
||||
offset = 30,
|
||||
scale = 20,
|
||||
spread = {x = 25, y = 25, z = 25},
|
||||
seed = 11111,
|
||||
octaves = 4,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 5,
|
||||
scale = 15,
|
||||
spread = {x = 30, y = 30, z = 30},
|
||||
seed = 52,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 30,
|
||||
scale = 15,
|
||||
spread = {x = 25, y = 25, z = 25},
|
||||
seed = 53,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local high_mountains = {
|
||||
['landscape'] = {
|
||||
offset = 60,
|
||||
scale = 35,
|
||||
spread = {x = 30, y = 30, z = 30},
|
||||
seed = 22222,
|
||||
octaves = 4,
|
||||
persistence = 0.55,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = -10,
|
||||
scale = 15,
|
||||
spread = {x = 35, y = 35, z = 35},
|
||||
seed = 54,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 20,
|
||||
scale = 10,
|
||||
spread = {x = 30, y = 30, z = 30},
|
||||
seed = 55,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local highest_peaks = {
|
||||
['landscape'] = {
|
||||
offset = 100,
|
||||
scale = 50,
|
||||
spread = {x = 40, y = 40, z = 40},
|
||||
seed = 33333,
|
||||
octaves = 5,
|
||||
persistence = 0.6,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = -30,
|
||||
scale = 10,
|
||||
spread = {x = 50, y = 50, z = 50},
|
||||
seed = 56,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 10,
|
||||
scale = 10,
|
||||
spread = {x = 40, y = 40, z = 40},
|
||||
seed = 57,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local rivers = {
|
||||
['landscape'] = {
|
||||
offset = -5,
|
||||
scale = 2,
|
||||
spread = {x = 5, y = 5, z = 100},
|
||||
seed = 44444,
|
||||
octaves = 2,
|
||||
persistence = 0.3,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 10,
|
||||
scale = 5,
|
||||
spread = {x = 50, y = 50, z = 50},
|
||||
seed = 58,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 80,
|
||||
scale = 10,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 59,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local lakes = {
|
||||
['landscape'] = {
|
||||
offset = -8,
|
||||
scale = 2,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 55555,
|
||||
octaves = 2,
|
||||
persistence = 0.3,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 10,
|
||||
scale = 5,
|
||||
spread = {x = 30, y = 30, z = 30},
|
||||
seed = 60,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 90,
|
||||
scale = 5,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 61,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local rocky_shores = {
|
||||
['landscape'] = {
|
||||
offset = 2,
|
||||
scale = 4,
|
||||
spread = {x = 8, y = 8, z = 8},
|
||||
seed = 66666,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 15,
|
||||
scale = 8,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 62,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 70,
|
||||
scale = 10,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 63,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local rocky_islands = {
|
||||
['landscape'] = {
|
||||
offset = 8,
|
||||
scale = 10,
|
||||
spread = {x = 12, y = 12, z = 12},
|
||||
seed = 77777,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 20,
|
||||
scale = 8,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 64,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 60,
|
||||
scale = 15,
|
||||
spread = {x = 20, y = 20, z = 20},
|
||||
seed = 65,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
local swamp_land = {
|
||||
['landscape'] = {
|
||||
offset = 1,
|
||||
scale = 2,
|
||||
spread = {x = 12, y = 12, z = 12},
|
||||
seed = 88888,
|
||||
octaves = 2,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['temp'] = {
|
||||
offset = 25,
|
||||
scale = 5,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 66,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
['humidity'] = {
|
||||
offset = 85,
|
||||
scale = 10,
|
||||
spread = {x = 15, y = 15, z = 15},
|
||||
seed = 67,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
local v = vector.new
|
||||
|
||||
for _, c in ipairs({'landscape', 'temp', 'humidity'}) do
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#4978c6', ocean[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#81c948', common_lands[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#187726', foresty_lands[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#357a60', hilly_lands[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#5a7269', low_mountains[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#773b18', high_mountains[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#a3a3a3', highest_peaks[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#182077', rivers[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#06f5ff', lakes[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#677a48', rocky_shores[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#e4dc36', rocky_islands[c])
|
||||
mapGenerator:registerLayerNoiseColor('midgard', c, '#3b7718', swamp_land[c])
|
||||
end
|
||||
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'landscape')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'temp')
|
||||
mapGenerator:register2DPeaksFromFile('midgard', 'map.ff', 32,{x=0, y=0}, 'humidity')
|
||||
|
||||
-- [[
|
||||
mapGenerator:registerCavern('midgard', 'cavern1', {
|
||||
minY = -48,
|
||||
maxY = 100,
|
||||
smoothDistance = 20,
|
||||
threshold = 0.1,
|
||||
noiseParams ={
|
||||
offset = 0.2,
|
||||
scale = 1,
|
||||
spread = {x = 10, y = 250, z = 30},
|
||||
seed = 5934,
|
||||
octaves = 3,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2.0
|
||||
},
|
||||
},
|
||||
{
|
||||
{x=100, y=0, z=100},
|
||||
{x=100, y=0, z=200},
|
||||
{x=200, y=0, z=200},
|
||||
{x=200, y=0, z=100},
|
||||
})--]]
|
||||
|
||||
-- --- Biomes ---
|
||||
@@ -183,8 +482,8 @@ local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||
end
|
||||
|
||||
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||
if noiseRocksValue == 1 then
|
||||
local noiseRocksValue = (rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||
--[[if noiseRocksValue == 1 then
|
||||
data[index] = ids.malachite
|
||||
elseif noiseRocksValue == 2 then
|
||||
data[index] = ids.hapcoryte
|
||||
@@ -200,6 +499,13 @@ local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
||||
data[index] = ids.burcite
|
||||
elseif noiseRocksValue == 8 then
|
||||
data[index] = ids.felhor
|
||||
end--]]
|
||||
if noiseRocksValue > 5 then
|
||||
data[index] = ids.syliteBlack
|
||||
elseif noiseRocksValue > 4.5 then
|
||||
data[index] = ids.syliteGray
|
||||
else
|
||||
data[index] = ids.sylite
|
||||
end
|
||||
end
|
||||
|
||||
@@ -210,9 +516,13 @@ local function generateSoil(biome, mapGenerator, data, index, x, y, z)
|
||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||
end
|
||||
|
||||
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||
local noiseRocksValue = (rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||
|
||||
if noiseRocksValue > 4 then
|
||||
if noiseRocksValue > 5 then
|
||||
data[index] = ids.syliteBlack
|
||||
elseif noiseRocksValue > 4.5 then
|
||||
data[index] = ids.syliteGray
|
||||
elseif noiseRocksValue > 4 then
|
||||
data[index] = ids.sylite
|
||||
else
|
||||
data[index] = biome.groundNodesIDs.soil
|
||||
@@ -226,9 +536,13 @@ local function generateTurf(biome, mapGenerator, data, index, x, y, z)
|
||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||
end
|
||||
|
||||
local noiseRocksValue = mathRound(rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||
local noiseRocksValue = (rocksNoise:get_3d({x = x, y = y, z = z}))
|
||||
|
||||
if noiseRocksValue > 4 then
|
||||
if noiseRocksValue > 5 then
|
||||
data[index] = ids.syliteBlack
|
||||
elseif noiseRocksValue > 4.5 then
|
||||
data[index] = ids.syliteGray
|
||||
elseif noiseRocksValue > 4 then
|
||||
data[index] = ids.sylite
|
||||
else
|
||||
data[index] = biome.groundNodesIDs.turf
|
||||
@@ -239,7 +553,7 @@ mapGenerator:registerBiome('midgard', 'swamp', {
|
||||
tempPoint = 0,
|
||||
humidityPoint = 80,
|
||||
minY = 100,
|
||||
maxY = 0,
|
||||
maxY = -50,
|
||||
groundNodes = {
|
||||
soil = 'soils:rocky_soil_baren',
|
||||
turf = 'soils:turf_swamp',
|
||||
|
||||
Binary file not shown.
@@ -66,10 +66,10 @@ liquidFactory:registerItems({
|
||||
settings = {
|
||||
name = "liquids:water_flowing",
|
||||
drawtype = "flowingliquid",
|
||||
tiles = {"default_water.png"},
|
||||
tiles = {"liquids_water.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
name = "default_water_flowing_animated.png",
|
||||
name = "liquids_water_flowing.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
@@ -79,7 +79,7 @@ liquidFactory:registerItems({
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "default_water_flowing_animated.png",
|
||||
name = "liquids_water_flowing.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
|
||||
BIN
mods/GAME/ITEMS/liquids/textures/liquids_water_flowing.png
Normal file
BIN
mods/GAME/ITEMS/liquids/textures/liquids_water_flowing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -24,16 +24,30 @@ local rockFactory = defaultRock:getFactory()
|
||||
---@type TileSheet
|
||||
local ts = TileSheet:new("rocks_sheet.png", 16, 16)
|
||||
|
||||
rockFactory:registerNodesByShortDef({
|
||||
{"sylite", {ts:t(0, 0)}},
|
||||
{"tauitite", {ts:t(0, 2)}},
|
||||
{"iyellite", {ts:t(0, 4)}},
|
||||
{"falmyte", {ts:t(0, 6)}},
|
||||
{"hapcoryte", {ts:t(0, 8)}},
|
||||
{"burcite", {ts:t(0, 10)}},
|
||||
{"felhor", {ts:t(0, 12)}},
|
||||
{"malachite", {ts:t(0, 14)}}
|
||||
})
|
||||
local function registerRocksTypes(postfix, x)
|
||||
rockFactory:registerNodesByShortDef({
|
||||
{"sylite"..postfix, {ts:t(x, 0)}},
|
||||
{"sylite_gray"..postfix, {ts:t(x, 1)}},
|
||||
{"sylite_black"..postfix, {ts:t(x, 2)}},
|
||||
{"tauitite_light"..postfix, {ts:t(x, 3)}},
|
||||
{"tauitite_pink"..postfix, {ts:t(x, 4)}},
|
||||
{"tauitite"..postfix, {ts:t(x, 5)}},
|
||||
{"falmyte_light"..postfix, {ts:t(x, 6)}},
|
||||
{"falmyte_yellow"..postfix, {ts:t(x, 7)}},
|
||||
{"falmyte_red"..postfix, {ts:t(x, 8)}},
|
||||
{"falmyte_dark"..postfix, {ts:t(x, 9)}},
|
||||
{"iyellite"..postfix, {ts:t(x, 14)}},
|
||||
{"falmyte"..postfix, {ts:t(x, 14)}},
|
||||
{"hapcoryte"..postfix, {ts:t(x, 14)}},
|
||||
{"burcite"..postfix, {ts:t(x, 14)}},
|
||||
{"felhor"..postfix, {ts:t(x, 14)}},
|
||||
{"malachite"..postfix, {ts:t(x, 14)}}
|
||||
})
|
||||
end
|
||||
|
||||
registerRocksTypes('', 0)
|
||||
registerRocksTypes('_block', 2)
|
||||
registerRocksTypes('_bricks', 5)
|
||||
|
||||
--[[
|
||||
rockFactory:registerItems({
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
@@ -1,3 +1,5 @@
|
||||
local setMetaTable, TableCopy = setmetatable, table.copy_with_metatables
|
||||
|
||||
---@class Class
|
||||
Class = {}
|
||||
|
||||
@@ -5,5 +7,25 @@ Class = {}
|
||||
---@param parent table
|
||||
---@param child table
|
||||
function Class.extend(parent ,child)
|
||||
return setmetatable(child or {}, { __index = parent })
|
||||
return setmetatable(child or {}, { __index = TableCopy(parent) })
|
||||
end
|
||||
|
||||
---Intended for class constructors.
|
||||
---
|
||||
---Correctly creates an object of the class using `setmetatable()`.
|
||||
---@generic T:table
|
||||
---@param self T Parent class.
|
||||
---@param params table Child object parameters.
|
||||
---@param metatable table? The table that will become the metatable for the object. Note: The `__index` field will be overwritten by a copy of `self`.
|
||||
---@return T
|
||||
function Class.getInstance(self, params, metatable)
|
||||
if metatable == nil then
|
||||
metatable = {}
|
||||
end
|
||||
|
||||
metatable.__index = TableCopy(self)
|
||||
|
||||
local instance = setMetaTable(params, metatable)
|
||||
|
||||
return instance
|
||||
end
|
||||
@@ -4,3 +4,4 @@ local modInfo = Mod.getInfo('smc__system__helper_lib')
|
||||
local require = modInfo.require
|
||||
|
||||
require('Lib.globalStep')
|
||||
require('Lib.color')
|
||||
|
||||
57
mods/SYSTEM/HelperLib/src/Lib/color.lua
Normal file
57
mods/SYSTEM/HelperLib/src/Lib/color.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
---Converts a colorstring into a single representation so that similar colors can match.
|
||||
---@param color ColorString
|
||||
---@return ColorString
|
||||
function Smc.fixColorString(color)
|
||||
local colorTable = core.colorspec_to_table(color)
|
||||
|
||||
if colorTable == nil then
|
||||
return ''
|
||||
end
|
||||
|
||||
local colorString = core.colorspec_to_colorstring(colorTable)
|
||||
|
||||
if colorString == nil then
|
||||
return ''
|
||||
end
|
||||
|
||||
return colorString
|
||||
end
|
||||
|
||||
---Makes gradient on given text with many of core.colorize.
|
||||
---@param colorFrom ColorString
|
||||
---@param colorTo ColorString
|
||||
---@param msg string text
|
||||
---@return string
|
||||
function Smc.makeGradient(colorFrom, colorTo, msg)
|
||||
-- Original feature author: @ssdaniel24 (github)
|
||||
|
||||
msg = core.strip_colors(msg)
|
||||
|
||||
local colorFromTable = core.colorspec_to_table(colorFrom)
|
||||
local colorToTable = core.colorspec_to_table(colorTo)
|
||||
|
||||
if colorFromTable == nil or colorToTable == nil then
|
||||
error('Incorrect color')
|
||||
end
|
||||
|
||||
local gradientStepTable = core.colorspec_to_table('#00000000') or {}
|
||||
for k, _ in pairs(gradientStepTable) do
|
||||
gradientStepTable[k] = (colorToTable[k] - colorFromTable[k]) / string.len(msg)
|
||||
end
|
||||
|
||||
local result = ''
|
||||
local currentColorTable = table.copy(colorFromTable)
|
||||
|
||||
for i = 1,#msg do
|
||||
local char = msg:sub(i,i)
|
||||
local color = core.colorspec_to_colorstring(currentColorTable) or ''
|
||||
|
||||
result = result .. core.colorize(color, char)
|
||||
|
||||
for k,_ in pairs(gradientStepTable) do
|
||||
currentColorTable[k] = currentColorTable[k] + gradientStepTable[k]
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
@@ -4,6 +4,7 @@ local math = math
|
||||
---@param value number The value to be limited.
|
||||
---@param min number Minimum limit.
|
||||
---@param max number Maximum limit.
|
||||
---@return number
|
||||
math.clamp = function(value, min, max)
|
||||
return math.min(math.max(value, min), max)
|
||||
end
|
||||
@@ -12,6 +13,7 @@ end
|
||||
---@param a number Minimum value.
|
||||
---@param b number Maximum value.
|
||||
---@param t number Number in range [0, 1].
|
||||
---@return number
|
||||
math.lerp = function (a, b, t)
|
||||
t = math.clamp(t, 0, 1)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local tableCopy, tableKeyOf, pairs, ipairs, next, type, assert, ensureArgType, ensureArgNotNil
|
||||
= table.copy, table.keyof, pairs, ipairs, next, type, assert, Ensure.argType, Ensure.argNotNil
|
||||
local tableCopy, tableKeyOf, pairs, ipairs, next, type, assert, ensureArgType, ensureArgNotNil, toString
|
||||
= table.copy, table.keyof, pairs, ipairs, next, type, assert, Ensure.argType, Ensure.argNotNil, tostring
|
||||
|
||||
-- While extending Lua's table library, we maintain snake_case naming for standard library
|
||||
-- functions and arguments to match standard library conventions. The code that is not exposed
|
||||
@@ -57,6 +57,8 @@ end
|
||||
--- @return boolean
|
||||
function table.contains(t, value)
|
||||
ensureArgType(t, 'table', 1, 'table.contains')
|
||||
|
||||
---@diagnostic disable-next-line: param-type-not-match
|
||||
return tableKeyOf(t, value) ~= nil
|
||||
end
|
||||
|
||||
@@ -357,4 +359,28 @@ function table.divide_values(t1, t2, empty_value)
|
||||
return a / b
|
||||
end
|
||||
return operateValues(t1, t2, empty_value or 1, operation)
|
||||
end
|
||||
|
||||
--- Returns a string of the format `'key1=value1,key2=value2...keyN=valueN'`.
|
||||
--- @param t table
|
||||
--- @param separator string? Default: `,`
|
||||
--- @return string
|
||||
function table.key_value_list(t, separator)
|
||||
separator = separator or ','
|
||||
|
||||
local result = ''
|
||||
|
||||
local size = #t
|
||||
local k = 1
|
||||
for key, value in pairs(t) do
|
||||
if size < k then
|
||||
result = result..key..'='..toString(value)..separator
|
||||
else
|
||||
result = result..key..'='..toString(value)
|
||||
end
|
||||
|
||||
k = k + 1
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
Submodule mods/SYSTEM/Utf8 updated: 4478c13bec...08edd23035
Submodule util/ide-helper updated: 138ceae165...3eb0f97115
Reference in New Issue
Block a user