Compare commits
60 Commits
mapgen-opt
...
bbe7a14401
| Author | SHA1 | Date | |
|---|---|---|---|
| bbe7a14401 | |||
| ad521ce2b7 | |||
| 0d986dafd5 | |||
| f34c12c59f | |||
| 89bc05d2cb | |||
| 99093493c0 | |||
| 31d66277ae | |||
| 93d4b3145c | |||
| ed9a80b2cf | |||
| 9fd665aaa5 | |||
| 8e09f8fa53 | |||
| 97084c9060 | |||
| 7e46c858cc | |||
| ac28f9e92b | |||
| b62e19d10a | |||
| 6dba6f8c78 | |||
| 0a97ef3a83 | |||
| 7661cacbfe | |||
| c172198ff7 | |||
| f1c82d9220 | |||
| b4290ad1f9 | |||
| f31277f8b0 | |||
| 0189b29257 | |||
| b0aad2823a | |||
| 76f74743ba | |||
| cc8f896d6e | |||
| b579418b9a | |||
| bddcb4e36c | |||
| d5c6101c0f | |||
| b53753c6a5 | |||
| 427c674103 | |||
| 91603e21f8 | |||
| f5fba0b779 | |||
| d5b9504cc5 | |||
| a1e74978a5 | |||
| 1dc6fb3f39 | |||
| 89c52c80bc | |||
| 162f8d2639 | |||
| 7af83a87d8 | |||
| 0e59cf799a | |||
| 89de48b5a8 | |||
| 362d626f9b | |||
| defd3531bc | |||
| 584e710d5c | |||
| 8a0b5785ab | |||
| 9873e059cb | |||
| d05af7dacc | |||
| 9ed2319b14 | |||
| d6cc39a0b2 | |||
| 2935c4d10b | |||
| 53801a56a8 | |||
| f1610056cc | |||
| 914ea881a4 | |||
| cb87d16560 | |||
| 44916bcd3b | |||
| 3483cd650a | |||
| c4104a1834 | |||
| e98935cf6f | |||
| 338cc7a36b | |||
| 18f06d13d3 |
@@ -2,7 +2,7 @@
|
||||
|
||||
**The MIT License (MIT)**
|
||||
|
||||
Copyright (c) 2025 Apancore.Studio, Van (varttist), Doloment
|
||||
Copyright (c) 2025-2026 Apancore.Studio, Van (varttist), Doloment
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
@@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
|
||||
**CC BY 4.0**
|
||||
|
||||
Copyright (c) 2025 Apancore.Studio, Van (varttist) and others (see list below)
|
||||
Copyright (c) 2025-2026 Apancore.Studio, Van (varttist) and others (see list below)
|
||||
|
||||
All textures except those listed here are copyrighted by Van (varttist) and are distributed under the CC BY 4.0.
|
||||
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
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:
|
||||
@@ -1,54 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# global MapGen.Decoration
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Decoration.new
|
||||
---
|
||||
```lua
|
||||
function Decoration.new() -> MapGen.Decoration {
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,673 +0,0 @@
|
||||
# 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**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,536 +0,0 @@
|
||||
# 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)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,745 +0,0 @@
|
||||
# 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?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
# 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,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# 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/)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -1,738 +0,0 @@
|
||||
# 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>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# 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}, ... },
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,312 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
# 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?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
# 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>?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# class Decoration
|
||||
|
||||
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
**NOT IMPLEMENTED**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## methods
|
||||
---
|
||||
|
||||
### Decoration.new
|
||||
---
|
||||
```lua
|
||||
function Decoration.new() -> MapGen.Decoration {
|
||||
new = function,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# alias Category
|
||||
---
|
||||
|
||||
- namespace: MapGen.Layer
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) Category = ("landscape"|"temp"|"humidity")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
A category of noise that affects specific map generation objects.
|
||||
|
||||
@@ -1,678 +0,0 @@
|
||||
# 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**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
# 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?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# alias PastCalcNoiseValue
|
||||
---
|
||||
|
||||
- namespace: MapGen
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) PastCalcNoiseValue = { noiseValue: number?, triangle: MapGen.Triangle?, x: integer?, z: integer? }
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# 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>?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,541 +0,0 @@
|
||||
# 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)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# alias CircumCircleEnum
|
||||
---
|
||||
|
||||
- namespace: MapGen.Triangle
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) CircumCircleEnum = ("IN"|"BEHIND"|"ON")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# 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
|
||||
|
||||
@@ -1,750 +0,0 @@
|
||||
# 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?
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
# 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,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,741 +0,0 @@
|
||||
# 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>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# class MapGenDef
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Definition table for the `MapGen`.
|
||||
|
||||
**Only for EmmyLua.**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
## fields
|
||||
---
|
||||
|
||||
### MapGenDef.nodes
|
||||
---
|
||||
```lua
|
||||
MapGenDef.nodes : table<string,string>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# alias generateFunc
|
||||
---
|
||||
|
||||
|
||||
|
||||
```lua
|
||||
(alias) generateFunc = fun(self, mapGenerator: MapGen, data: number[], index: number, x: number, y: number, z: number)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
|
||||
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: ""
|
||||
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 7.3 MiB |
@@ -24,13 +24,16 @@ function BaseUI:new(name, getFormSpecString, clearContex)
|
||||
instance.getFormSpecString = getFormSpecString
|
||||
|
||||
if clearContex then
|
||||
core.log(name)
|
||||
-- Ensure that when the form is closed, the context is cleared.
|
||||
instance:registerOnFormQuit(function(player)
|
||||
instance:clearContex(player)
|
||||
end)
|
||||
end
|
||||
|
||||
instance:registerOnFormQuit(function(player)
|
||||
Smc.clearActiveFormspec(player:get_player_name())
|
||||
end)
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -118,6 +121,7 @@ end
|
||||
---@param playerName string
|
||||
function BaseUI:showForm(playerName, ...)
|
||||
core.show_formspec(playerName, self.name, self:getFormSpecString(playerName, ...))
|
||||
Smc.setActiveFormspec(playerName, self.name)
|
||||
end
|
||||
|
||||
---Close the player the FormSpec registered by the instance of this UI.
|
||||
|
||||
@@ -8,6 +8,6 @@ local BaseCraft = {}
|
||||
---
|
||||
---**Only for EmmyLua.**
|
||||
---@class CraftSystem.BaseCraftDef
|
||||
---@field group CraftSystem.CraftGroup
|
||||
---@field group CraftSystem.CraftGroup?
|
||||
|
||||
return BaseCraft
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
local PLAYERS_KNOW_ALL_RECIPES = true
|
||||
|
||||
---Abstract class for handling crafting.
|
||||
---@class CraftSystem.BaseCraftHandler
|
||||
---@field craftsByName table<string, CraftSystem.BaseCraft>
|
||||
---@field craftsByGroup table<CraftSystem.CraftGroup, CraftSystem.BaseCraft[]>
|
||||
---@field craftsList CraftSystem.BaseCraft[]
|
||||
---@field learnedCrafts table<string, table<string, CraftSystem.BaseCraft>>
|
||||
---@field groupedCrafts (CraftSystem.BaseCraft[]|CraftSystem.BaseCraft)[]
|
||||
---@field learnedCrafts table<string, (CraftSystem.BaseCraft[]|CraftSystem.BaseCraft)[]>
|
||||
local BaseCraftHandler = {
|
||||
craftsByName = {},
|
||||
craftsByGroup = {},
|
||||
craftsList = {},
|
||||
groupedCrafts = {},
|
||||
learnedCrafts = {},
|
||||
}
|
||||
|
||||
@@ -34,12 +38,18 @@ function BaseCraftHandler:getCraftsByGroup(craftGroup)
|
||||
end
|
||||
|
||||
---@param playerName string
|
||||
---@return table<string, CraftSystem.BaseCraft>
|
||||
---@return (CraftSystem.BaseCraft[]|CraftSystem.BaseCraft)[]
|
||||
function BaseCraftHandler:getLearnedCrafts(playerName)
|
||||
if PLAYERS_KNOW_ALL_RECIPES then
|
||||
return self.groupedCrafts
|
||||
end
|
||||
|
||||
local crafts = self.learnedCrafts[playerName]
|
||||
|
||||
assert(crafts ~= nil, ('There is no primitive crafting data for a player named `%s`.'):format(
|
||||
playerName))
|
||||
if crafts == nil then
|
||||
crafts = {}
|
||||
self.learnedCrafts[playerName] = crafts
|
||||
end
|
||||
|
||||
return crafts
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ local stageTypes = {
|
||||
---Immersive crafting aimed at a more logical process of crafting items.
|
||||
---@class CraftSystem.ImmersiveCraft : CraftSystem.BaseCraft
|
||||
---@field startStageName string
|
||||
---@field triggerItem string
|
||||
---@field triggerItem ItemStackString
|
||||
---@field output ItemStackString
|
||||
---@field stagesByName table<string, CraftSystem.ImmersiveCraftStage>
|
||||
local ImmersiveCraft = extend(BaseCraft, {})
|
||||
@@ -28,8 +28,8 @@ local ImmersiveCraft = extend(BaseCraft, {})
|
||||
---**Only for EmmyLua.**
|
||||
---@class CraftSystem.ImmersiveCraftDef : CraftSystem.BaseCraftDef
|
||||
---@field startStageName string
|
||||
---@field triggerItem string
|
||||
---@field output string
|
||||
---@field triggerItem ItemStackString
|
||||
---@field output ItemStackString
|
||||
---@field stages CraftSystem.ImmersiveCraftStageDef[]
|
||||
|
||||
---@param name string
|
||||
|
||||
@@ -29,12 +29,13 @@ function ImmersiveCraftHandler:registerCraft(craftName, def)
|
||||
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
||||
craftName))
|
||||
|
||||
-- The craft group to which the craft belongs.
|
||||
local group = 'craft_group:' .. (def.group or 'UNDEFINED')
|
||||
def.group = group
|
||||
|
||||
-- We obtain a crafting instance according to the given parameters.
|
||||
local craft = ImmersiveCraft:new(craftName, def)
|
||||
|
||||
-- The craft group to which the craft belongs.
|
||||
local group = def.group
|
||||
|
||||
-- If no craft with this group has been registered before...
|
||||
if self.craftsByGroup[group] == nil then
|
||||
-- ...then we create a list for this group.
|
||||
|
||||
@@ -7,7 +7,7 @@ local require = modInfo.require
|
||||
local BaseCraft = require('CraftSystem.BaseCraft')
|
||||
|
||||
---@class CraftSystem.PrimitiveCraft : CraftSystem.BaseCraft
|
||||
---@field output string
|
||||
---@field output ItemStackString
|
||||
---@field recipe CraftSystem.CraftRecipe
|
||||
---@field returnItems ItemStackString[]
|
||||
local PrimitiveCraft = extend(BaseCraft, {})
|
||||
@@ -16,9 +16,9 @@ local PrimitiveCraft = extend(BaseCraft, {})
|
||||
---
|
||||
---**Only for EmmyLua.**
|
||||
---@class CraftSystem.PrimitiveCraftDef : CraftSystem.BaseCraftDef
|
||||
---@field output string
|
||||
---@field output ItemStackString
|
||||
---@field recipe CraftSystem.CraftRecipe
|
||||
---@field returnItems ItemStackString[]
|
||||
---@field returnItems ItemStackString[]?
|
||||
|
||||
---@param name string
|
||||
---@param def CraftSystem.PrimitiveCraftDef
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local extend = Class.extend
|
||||
|
||||
local tableInsert = table.insert
|
||||
local tableInsert, tableSort, tableJoin = table.insert, table.sort, table.join
|
||||
|
||||
local modInfo = Mod.getInfo('smc__core__craft_system')
|
||||
local require = modInfo.require
|
||||
@@ -14,9 +14,11 @@ local PrimitiveCraft = require('CraftSystem.PrimitiveCraft')
|
||||
---A primitive crafting processor that doesn't require much interaction and provides
|
||||
---simple crafting based on a recipe-result scheme.
|
||||
---@class CraftSystem.PrimitiveCraftHandler : CraftSystem.BaseCraftHandler
|
||||
---@field craftsByGroup table<CraftSystem.CraftGroup, CraftSystem.PrimitiveCraft[]>
|
||||
---@field groupedCrafts (CraftSystem.PrimitiveCraft[]|CraftSystem.PrimitiveCraft)[]
|
||||
---@field getCraftByName fun(self, craftName:string):CraftSystem.PrimitiveCraft
|
||||
---@field getCraftsByGroup fun(self, craftGroup):CraftSystem.PrimitiveCraft[]
|
||||
---@field getLearnedCrafts fun(self, playerName):table<string, CraftSystem.PrimitiveCraft>
|
||||
---@field getCraftsByGroup fun(self, craftGroup:string):CraftSystem.PrimitiveCraft[]
|
||||
---@field getLearnedCrafts fun(self, playerName:string):(CraftSystem.PrimitiveCraft[]|CraftSystem.PrimitiveCraft)[]
|
||||
local PrimitiveCraftHandler = extend(BaseCraftHandler, {})
|
||||
|
||||
---Register a primitive craft that does not require special interaction.
|
||||
@@ -26,9 +28,10 @@ function PrimitiveCraftHandler:registerCraft(craftName, def)
|
||||
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
||||
craftName))
|
||||
|
||||
local craft = PrimitiveCraft:new(craftName, def)
|
||||
local group = 'craft_group:' .. (def.group or 'UNDEFINED')
|
||||
def.group = group
|
||||
|
||||
local group = def.group
|
||||
local craft = PrimitiveCraft:new(craftName, def)
|
||||
|
||||
if self.craftsByGroup[group] == nil then
|
||||
self.craftsByGroup[group] = {}
|
||||
@@ -39,4 +42,29 @@ function PrimitiveCraftHandler:registerCraft(craftName, def)
|
||||
tableInsert(self.craftsList, craft)
|
||||
end
|
||||
|
||||
core.register_on_mods_loaded(function()
|
||||
for groupName, crafts in pairs(PrimitiveCraftHandler.craftsByGroup) do
|
||||
tableSort(crafts, function(a, b)
|
||||
if a.output < b.output then
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
if groupName ~= 'craft_group:UNDEFINED' then
|
||||
tableInsert(PrimitiveCraftHandler.groupedCrafts, crafts)
|
||||
else
|
||||
PrimitiveCraftHandler.groupedCrafts = tableJoin(PrimitiveCraftHandler.groupedCrafts, crafts)
|
||||
end
|
||||
end
|
||||
|
||||
tableSort(PrimitiveCraftHandler.groupedCrafts, function(a, b)
|
||||
local outputA = (a[1] and a[1].output) or a.output
|
||||
local outputB = (b[1] and b[1].output) or b.output
|
||||
|
||||
if outputA < outputB then
|
||||
return true
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
return PrimitiveCraftHandler
|
||||
|
||||
@@ -197,12 +197,30 @@ end
|
||||
---@return Formspec
|
||||
function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemIndex)
|
||||
local element = ('list[%s;%s;%s,%s;%s,%s;%s]'):format(
|
||||
inventoryLocation, listName, x, y, w, h,startingItemIndex or '')
|
||||
inventoryLocation, listName, x, y, w, h, startingItemIndex or '')
|
||||
|
||||
self:addElement(element)
|
||||
return self
|
||||
end
|
||||
|
||||
---A wrapper around `Formspec:list` that allows access to the inventory of a node,
|
||||
---specified by the coordinates of its position in the world.
|
||||
---@param nodePos MapPosition
|
||||
---@param listName string
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param w number Are in inventory slots, not in coordinates.
|
||||
---@param h number Are in inventory slots, not in coordinates.
|
||||
---@param startingItemIndex number? The index of the first (upper-left) item to draw. Indices start at `0`. Default is `0`.
|
||||
---@return Formspec
|
||||
function Formspec:listNodeMetaLocation(nodePos, listName, x, y, w, h, startingItemIndex)
|
||||
local inventoryLocation = ('nodemeta:%s,%s,%s'):format(nodePos.x, nodePos.y, nodePos.z)
|
||||
|
||||
self:list(inventoryLocation, listName, x, y, w, h, startingItemIndex)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
---Creates and appends a list of `listring[<inventory location>;<list name>]` items based on the passed inventory list.
|
||||
---
|
||||
---**Elements:** `listring[<inventory location>;<list name>]` or `listring[]`
|
||||
@@ -296,7 +314,7 @@ end
|
||||
---@param w number
|
||||
---@param h number
|
||||
---@param textureName string
|
||||
---@param middle boolean? Makes the image render in 9-sliced mode and defines the middle rect.
|
||||
---@param middle string? Makes the image render in 9-sliced mode and defines the middle rect.
|
||||
---@return Formspec
|
||||
function Formspec:image(x, y, w, h, textureName, middle)
|
||||
local element = ('image[%s,%s;%s,%s;%s;%s]'):format(
|
||||
@@ -441,7 +459,7 @@ end
|
||||
--- * All numbers in middle are integers.
|
||||
---@return Formspec
|
||||
function Formspec:background9(x, y, w, h, textureName, autoClip, middle)
|
||||
local element = ('background9[%s,%s;%s,%s;%s;%s]'):format(
|
||||
local element = ('background9[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||
x, y, w, h, textureName, autoClip, middle)
|
||||
|
||||
self:addElement(element)
|
||||
@@ -700,7 +718,7 @@ end
|
||||
---
|
||||
---**Elements:** `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]` or
|
||||
---`image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
|
||||
---@overload fun(x:number, y:number, w:number, h:number, textureName:string, name:string, label:string)
|
||||
---@overload fun(x:number, y:number, w:number, h:number, textureName:string, name:string, label:string?):Formspec
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param w number
|
||||
@@ -708,7 +726,7 @@ end
|
||||
---@param textureName string Is the filename of an image.
|
||||
---@param name string
|
||||
---@param label string?
|
||||
---@param pressedTextureName string Is the filename of an image on pressed state.
|
||||
---@param pressedTextureName string? Is the filename of an image on pressed state.
|
||||
---@param noclip boolean? Means the image button doesn't need to be within specified formsize. Default: `true`
|
||||
---@param drawborder boolean? Draw button border or not. Default `false`
|
||||
---@return Formspec
|
||||
@@ -720,7 +738,7 @@ function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextu
|
||||
x, y, w, h, textureName, name, label or '')
|
||||
else
|
||||
element = ('image_button[%s,%s;%s,%s;%s;%s;%s;%s;%s;%s]'):format(
|
||||
x, y, w, h, textureName, name, label or '', pressedTextureName, noclip or true, drawborder or false)
|
||||
x, y, w, h, textureName, name, label or '', noclip or true, drawborder or false, pressedTextureName)
|
||||
end
|
||||
|
||||
self:addElement(element)
|
||||
|
||||
@@ -4,6 +4,14 @@ local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
|
||||
|
||||
local ItemFactory = Smc.requireItemFactory()
|
||||
|
||||
---Colors the title according to the rarity of the item.
|
||||
---
|
||||
---Note: that if `true`, the `_title_color` will be ignored.
|
||||
local TITLE_RARITY_COLOR = true
|
||||
|
||||
---Shows rarity on a separate line.
|
||||
local SHOW_RARITY = false
|
||||
|
||||
---Determines whether common rarity will be shown in item descriptions or not.
|
||||
local SHOW_COMMON_RARITY = true
|
||||
|
||||
@@ -57,6 +65,10 @@ local Item = {
|
||||
---@param desc string
|
||||
---@return string
|
||||
local function addRarityToDesc(rarity, desc)
|
||||
if not SHOW_RARITY then
|
||||
return desc
|
||||
end
|
||||
|
||||
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
||||
return desc
|
||||
end
|
||||
@@ -98,22 +110,26 @@ local function itemDefToLuantiDef(itemDef)
|
||||
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
||||
end
|
||||
|
||||
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
||||
|
||||
if s._title_color ~= nil and s._description_color ~= nil then
|
||||
title = colorize(s._title_color , S(title))
|
||||
if TITLE_RARITY_COLOR then
|
||||
title = colorize(RARITY_COLORS[s._rarity], S(title))
|
||||
else
|
||||
title = colorize(s._title_color, S(title))
|
||||
end
|
||||
description = colorize(s._description_color, S(description))
|
||||
else
|
||||
error('Item description color parameters cannot be empty.')
|
||||
end
|
||||
|
||||
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
||||
|
||||
local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description)
|
||||
|
||||
s._title = title
|
||||
s._description = description
|
||||
s.description = luantiDescription..core.get_background_escape_sequence('#110F13')
|
||||
|
||||
local luantiDef = defMerge(s, c)
|
||||
local luantiDef = defMerge(s, c, true)
|
||||
|
||||
return luantiDef
|
||||
end
|
||||
|
||||
@@ -10,13 +10,87 @@ local defMerge = function(...)
|
||||
return table.merge(...)
|
||||
end
|
||||
|
||||
---@param nodeDef Node.NodeDefinition
|
||||
---@return Node
|
||||
---@param nodeDef Node.NodeDefinition
|
||||
local function registerSlab(nodeDef)
|
||||
nodeDef = table.copy_with_metatables(nodeDef)
|
||||
|
||||
local settings = nodeDef.settings
|
||||
assert(settings.groups ~= nil)
|
||||
settings._title = nil
|
||||
settings._description = nil
|
||||
settings.name = settings.name..'_slab'
|
||||
settings.node_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
}
|
||||
settings.drawtype = 'nodebox'
|
||||
settings.paramtype = 'light'
|
||||
settings.paramtype2 = 'facedir'
|
||||
settings.groups['segments'] = nil
|
||||
settings.groups['slabs'] = 1
|
||||
if nodeDef.callbacks ~= nil then
|
||||
nodeDef.callbacks.on_place = core.rotate_and_place
|
||||
else
|
||||
nodeDef.callbacks = {on_place = core.rotate_and_place}
|
||||
end
|
||||
|
||||
Node:new(nodeDef)
|
||||
end
|
||||
|
||||
---@param nodeDef Node.NodeDefinition
|
||||
local function registerStair(nodeDef)
|
||||
nodeDef = table.copy_with_metatables(nodeDef)
|
||||
|
||||
local settings = nodeDef.settings
|
||||
assert(settings.groups ~= nil)
|
||||
settings._title = nil
|
||||
settings._description = nil
|
||||
settings.name = settings.name..'_stair'
|
||||
settings.node_box = {
|
||||
type = 'fixed',
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
|
||||
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
|
||||
},
|
||||
}
|
||||
settings.drawtype = 'nodebox'
|
||||
settings.paramtype = 'light'
|
||||
settings.paramtype2 = 'facedir'
|
||||
settings.groups['segments'] = nil
|
||||
settings.groups['slabs'] = 1
|
||||
if nodeDef.callbacks ~= nil then
|
||||
nodeDef.callbacks.on_place = core.rotate_and_place
|
||||
else
|
||||
nodeDef.callbacks = {on_place = core.rotate_and_place}
|
||||
end
|
||||
|
||||
Node:new(nodeDef)
|
||||
end
|
||||
|
||||
---@param nodeDef Node.NodeDefinition
|
||||
---@return Node
|
||||
function Node:new(nodeDef)
|
||||
---Adding default parameters
|
||||
-- Adding default parameters.
|
||||
nodeDef = defMerge(nodeDef, self.defaultDef, true)
|
||||
|
||||
nodeDef.settings._type = 'node'
|
||||
local settings = nodeDef.settings
|
||||
settings._type = 'node'
|
||||
|
||||
-- Registration of segmented blocks.
|
||||
-- If you specify a specific group with a specific index for a node,
|
||||
-- the slabs and stairs will be registered automatically.
|
||||
local segmentsIndex = settings.groups and settings.groups['segments']
|
||||
if segmentsIndex == 1 then
|
||||
-- Only slabs
|
||||
registerSlab(nodeDef)
|
||||
elseif segmentsIndex == 2 then
|
||||
-- Only stairs
|
||||
registerStair(nodeDef)
|
||||
elseif segmentsIndex == 3 then
|
||||
-- Slabs & stairs
|
||||
registerSlab(nodeDef)
|
||||
registerStair(nodeDef)
|
||||
end
|
||||
|
||||
---@type Node
|
||||
local instance = Item:new(nodeDef)
|
||||
@@ -29,7 +103,7 @@ end
|
||||
---@param defaultDef Node.NodeDefinition
|
||||
---@return Node
|
||||
function Node:getExtended(defaultDef)
|
||||
defaultDef = defMerge(defaultDef, self.defaultDef)
|
||||
defaultDef = defMerge(defaultDef, self.defaultDef, true)
|
||||
|
||||
---@type Node
|
||||
local ChildClass = Class.extend(self, {
|
||||
@@ -46,7 +120,7 @@ function Node:getFactory(defaultDef)
|
||||
if defaultDef == nil then
|
||||
defaultDef = self.defaultDef
|
||||
else
|
||||
defaultDef = defMerge(self.defaultDef, defaultDef)
|
||||
defaultDef = defMerge(self.defaultDef, defaultDef, true)
|
||||
end
|
||||
|
||||
---@type ItemFactory
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
name = smc__core__player
|
||||
depends = smc__system__system_loader
|
||||
depends = smc__system__system_loader, smc__ui__player_inventory
|
||||
|
||||
@@ -9,6 +9,12 @@ core.register_on_joinplayer(function(player)
|
||||
player:hud_set_hotbar_itemcount(9)
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size('main', 18)
|
||||
-- Player equipment slots:
|
||||
inv:set_size('equip_head', 2)
|
||||
inv:set_size('equip_torso', 2)
|
||||
inv:set_size('equip_legs', 2)
|
||||
inv:set_size('equip_feet', 2)
|
||||
inv:set_size('listring_equip', 1) -- Slot for correct listring.
|
||||
end)
|
||||
|
||||
core.register_chatcommand('show_inv',
|
||||
@@ -20,4 +26,8 @@ core.register_chatcommand('show_inv',
|
||||
}
|
||||
)
|
||||
|
||||
local require = Mod.getInfo('smc__core__player').require
|
||||
|
||||
require('Player.inventory')
|
||||
|
||||
return Player
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
---@class Player.GUI
|
||||
local GUI = {}
|
||||
|
||||
return GUI
|
||||
6
mods/CORE/Player/src/Player/inventory.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
---@type PlayerInventoryUI
|
||||
local PlayerInventoryUI = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
|
||||
|
||||
-- TODO: перенести обработки в PlayerUI
|
||||
|
||||
@@ -29,7 +29,7 @@ end
|
||||
---@param defaultDef Item.ItemDefinition
|
||||
---@return Tool
|
||||
function Tool:getExtended(defaultDef)
|
||||
defaultDef = defMerge(defaultDef, self.defaultDef)
|
||||
defaultDef = defMerge(defaultDef, self.defaultDef, true)
|
||||
|
||||
---@type Tool
|
||||
local ChildClass = Class.extend(self, {
|
||||
@@ -46,7 +46,7 @@ function Tool:getFactory(defaultDef)
|
||||
if defaultDef == nil then
|
||||
defaultDef = self.defaultDef
|
||||
else
|
||||
defaultDef = defMerge(self.defaultDef, defaultDef)
|
||||
defaultDef = defMerge(self.defaultDef, defaultDef, true)
|
||||
end
|
||||
|
||||
---@type ItemFactory
|
||||
@@ -54,17 +54,5 @@ function Tool:getFactory(defaultDef)
|
||||
|
||||
return instance
|
||||
end
|
||||
--[[
|
||||
Tool:new({
|
||||
settings = {
|
||||
name = 'tool',
|
||||
inventory_image = 'anoba.png',
|
||||
tool_capabilities = {
|
||||
groupcaps={
|
||||
crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
|
||||
},
|
||||
}
|
||||
}
|
||||
})--]]
|
||||
|
||||
return Tool
|
||||
|
||||
@@ -18,13 +18,13 @@ local MapGen = mapGenRequire('MapGen')
|
||||
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',
|
||||
--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',
|
||||
|
||||
64
mods/GAME/ITEMS/equipment/init.lua
Normal file
@@ -0,0 +1,64 @@
|
||||
local Item, TileSheet = Smc.requireItem(), Smc.requireTileSheet()
|
||||
|
||||
local EquipTileSheet = TileSheet:new('equipment_sheet.png', 16, 16)
|
||||
|
||||
Item:new({
|
||||
settings = {
|
||||
name = 'linothorax',
|
||||
inventory_image = EquipTileSheet:t(0, 1),
|
||||
groups = {
|
||||
equip_torso = 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Item:new({
|
||||
settings = {
|
||||
name = 'copper_lamellar_armor',
|
||||
inventory_image = EquipTileSheet:t(1, 1),
|
||||
groups = {
|
||||
equip_torso = 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Item:new({
|
||||
settings = {
|
||||
name = 'bronze_breastplate',
|
||||
inventory_image = EquipTileSheet:t(2, 1),
|
||||
groups = {
|
||||
equip_torso = 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Item:new({
|
||||
settings = {
|
||||
name = 'bronze_knee_pads',
|
||||
inventory_image = EquipTileSheet:t(2, 2),
|
||||
groups = {
|
||||
equip_legs = 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Item:new({
|
||||
settings = {
|
||||
name = 'steel_boots',
|
||||
inventory_image = EquipTileSheet:t(3, 3),
|
||||
groups = {
|
||||
equip_feet = 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Item:new({
|
||||
settings = {
|
||||
name = 'steel_helmet',
|
||||
inventory_image = EquipTileSheet:t(3, 0),
|
||||
groups = {
|
||||
equip_head = 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
2
mods/GAME/ITEMS/equipment/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
name = smc__game__items__equipment
|
||||
depends = smc__core__item
|
||||
BIN
mods/GAME/ITEMS/equipment/textures/sheets/equipment_sheet.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -1,66 +1,174 @@
|
||||
local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
|
||||
|
||||
---@type Node.NodeDefinition
|
||||
local defaultRockDef = {
|
||||
settings = {
|
||||
name = '',
|
||||
tiles = {},
|
||||
groups = {
|
||||
dig_immediate = 2,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
---@type Node
|
||||
local defaultRock = Node:getExtended(defaultRockDef)
|
||||
|
||||
local rockFactory = defaultRock:getFactory()
|
||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
|
||||
---@type TileSheet
|
||||
local ts = TileSheet:new("rocks_sheet.png", 16, 16)
|
||||
local rocksTileSheet = TileSheet:new("rocks_sheet.png", 16, 16)
|
||||
|
||||
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)}}
|
||||
---@class RockDef
|
||||
---@field rarity Item.Rarity?
|
||||
|
||||
local function registerSegmentsCrafts(name, craftGroup)
|
||||
PrimitiveCraftHandler:registerCraft(name..'_slab', {
|
||||
recipe = {name},
|
||||
output = name..'_slab',
|
||||
group = craftGroup
|
||||
})
|
||||
|
||||
PrimitiveCraftHandler:registerCraft(name..'_stair', {
|
||||
recipe = {name},
|
||||
output = name..'_stair',
|
||||
group = craftGroup
|
||||
})
|
||||
end
|
||||
|
||||
local function registerPilarStaff(rock, y)
|
||||
local columnTop = ts:t(9, y)
|
||||
---@param name string
|
||||
---@param y number
|
||||
---@param def RockDef?
|
||||
---@param staff {block:boolean?,bricks:boolean?,pillar:boolean?}
|
||||
local function registerRock(name, y, def, staff)
|
||||
if def == nil then
|
||||
def = {}
|
||||
end
|
||||
|
||||
rockFactory:registerNodesByShortDef({
|
||||
{rock..'_fluted_column', {columnTop, columnTop, ts:t(6, y)}},
|
||||
{rock..'_ionic_chapiter', {
|
||||
ts:t(3, y),
|
||||
columnTop,
|
||||
ts:t(7, y),
|
||||
ts:t(7, y),
|
||||
ts:t(8, y),
|
||||
ts:t(8, y)}},
|
||||
local modPrefix = Mod.getInfo().shortName..':'
|
||||
local craftGroup = 'rocks_'..name..'_staff'
|
||||
|
||||
-- Default rock
|
||||
local defaultRock = Node:getExtended({
|
||||
settings = {
|
||||
name = '',
|
||||
_rarity = def.rarity,
|
||||
groups = {
|
||||
rocks = 1,
|
||||
dig_immediate = 2,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- Solid rock
|
||||
defaultRock:new({
|
||||
settings = {
|
||||
name = name,
|
||||
tiles = {{ name = rocksTileSheet:t(0, y), align_style='world'}},
|
||||
groups = {
|
||||
segments = 3
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
registerSegmentsCrafts(modPrefix..name, craftGroup)
|
||||
|
||||
-- Chipped rock
|
||||
local chippedRockName = name..'_chipped'
|
||||
defaultRock:new({
|
||||
settings = {
|
||||
name = chippedRockName,
|
||||
tiles = {{ name = rocksTileSheet:t(1, y), align_style='world'}},
|
||||
groups = {
|
||||
segments = 3
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
registerSegmentsCrafts(modPrefix..chippedRockName, craftGroup)
|
||||
|
||||
if staff.block == true then
|
||||
-- Solid rock block
|
||||
local blockName = name..'_block'
|
||||
defaultRock:new({
|
||||
settings = {
|
||||
name = name..'_block',
|
||||
tiles = {{ name = rocksTileSheet:t(3, y), align_style='world'}},
|
||||
groups = {
|
||||
segments = 3
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
registerSegmentsCrafts(modPrefix..blockName, craftGroup)
|
||||
|
||||
PrimitiveCraftHandler:registerCraft(blockName, {
|
||||
recipe = {modPrefix..name},
|
||||
output = modPrefix..blockName,
|
||||
group = craftGroup,
|
||||
})
|
||||
end
|
||||
|
||||
if staff.bricks == true then
|
||||
-- Solid rock bricks
|
||||
local bricksName = name..'_bricks'
|
||||
defaultRock:new({
|
||||
settings = {
|
||||
name = bricksName,
|
||||
tiles = {{ name = rocksTileSheet:t(4, y), align_style='world'}},
|
||||
groups = {
|
||||
segments = 3
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
registerSegmentsCrafts(modPrefix..bricksName, craftGroup)
|
||||
|
||||
PrimitiveCraftHandler:registerCraft(bricksName, {
|
||||
recipe = {modPrefix..name},
|
||||
output = modPrefix..bricksName,
|
||||
group = craftGroup,
|
||||
})
|
||||
end
|
||||
|
||||
if staff.pillar == true then
|
||||
local columnTopTexture = rocksTileSheet:t(9, y)
|
||||
|
||||
-- Fluted column
|
||||
defaultRock:new({
|
||||
settings = {
|
||||
name = name..'_fluted_column',
|
||||
tiles = {
|
||||
columnTopTexture,
|
||||
columnTopTexture,
|
||||
rocksTileSheet:t(6, y)
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
-- Ionic chapiter
|
||||
defaultRock:new({
|
||||
settings = {
|
||||
name = name..'_ionic_chapiter',
|
||||
tiles = {
|
||||
rocksTileSheet:t(3, y),
|
||||
columnTopTexture,
|
||||
rocksTileSheet:t(7, y),
|
||||
rocksTileSheet:t(7, y),
|
||||
rocksTileSheet:t(8, y),
|
||||
rocksTileSheet:t(8, y)
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
registerPilarStaff('sylite', 0)
|
||||
registerPilarStaff('sylite_gray', 1)
|
||||
registerPilarStaff('sylite_black', 2)
|
||||
-- Sylite group
|
||||
registerRock('sylite', 0, {}, {block = true, bricks = true, pillar = true})
|
||||
registerRock('sylite_gray', 1, {}, {block = true, bricks = true, pillar = true})
|
||||
registerRock('sylite_black', 2, {}, {block = true, bricks = true, pillar = true})
|
||||
|
||||
registerRocksTypes('', 0)
|
||||
registerRocksTypes('_chipped', 1)
|
||||
registerRocksTypes('_block', 3)
|
||||
registerRocksTypes('_bricks', 4)
|
||||
registerRocksTypes('_bricks_2', 5)
|
||||
-- Tauitite group
|
||||
registerRock('tauitite_light', 3, {}, {block = true, bricks = true})
|
||||
registerRock('tauitite_pink', 4, {}, {block = true, bricks = true})
|
||||
registerRock('tauitite_black', 5, {}, {block = true, bricks = true})
|
||||
|
||||
-- Falmyte group
|
||||
registerRock('falmyte_light', 6, {}, {block = true, bricks = true})
|
||||
registerRock('falmyte_yellow', 7, {}, {block = true, bricks = true})
|
||||
registerRock('falmyte_red', 8, {}, {block = true, bricks = true})
|
||||
registerRock('falmyte_dark', 9, {}, {block = true, bricks = true})
|
||||
|
||||
-- TODO:
|
||||
-- iyellite
|
||||
-- falmyte
|
||||
-- hapcoryte
|
||||
-- burcite
|
||||
-- felhor
|
||||
-- malachite
|
||||
|
||||
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
@@ -97,3 +97,11 @@ storageFactory:registerItems({
|
||||
},
|
||||
})
|
||||
|
||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
|
||||
PrimitiveCraftHandler:registerCraft('storages:case_closed', {
|
||||
recipe = {
|
||||
'group:log 4'
|
||||
},
|
||||
output = 'storages:case_closed',
|
||||
})
|
||||
@@ -1,4 +1,6 @@
|
||||
local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
|
||||
local Item, Node, TileSheet = Smc.requireItem(), Smc.requireNode(), Smc.requireTileSheet()
|
||||
|
||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
|
||||
---@type Node.NodeDefinition
|
||||
local defaultLogDef = {
|
||||
@@ -6,7 +8,7 @@ local defaultLogDef = {
|
||||
name = '',
|
||||
tiles = {},
|
||||
groups = {
|
||||
dig_immediate = 2,
|
||||
dig_immediate = 3,
|
||||
wood = 1
|
||||
},
|
||||
}
|
||||
@@ -18,7 +20,7 @@ local defaultPlanksDef = {
|
||||
name = '',
|
||||
tiles = {},
|
||||
groups = {
|
||||
dig_immediate = 2,
|
||||
dig_immediate = 3,
|
||||
},
|
||||
paramtype2 = 'facedir',
|
||||
},
|
||||
@@ -31,7 +33,7 @@ local defaultLeafsDef = {
|
||||
name = '',
|
||||
tiles = {},
|
||||
groups = {
|
||||
dig_immediate = 2,
|
||||
dig_immediate = 3,
|
||||
},
|
||||
--paramtype = 'light',
|
||||
paramtype2 = 'facedir',
|
||||
@@ -40,26 +42,33 @@ local defaultLeafsDef = {
|
||||
},
|
||||
}
|
||||
|
||||
---@type Item.ItemDefinition
|
||||
local defaultStickDef = {
|
||||
settings = {
|
||||
name = '',
|
||||
},
|
||||
}
|
||||
|
||||
local defaultLog = Node:getExtended(defaultLogDef)
|
||||
local defaultPlanks = Node:getExtended(defaultPlanksDef)
|
||||
local defaultLeafs = Node:getExtended(defaultLeafsDef)
|
||||
local defaultStick = Item:getExtended(defaultStickDef)
|
||||
|
||||
local logFactory = defaultLog:getFactory()
|
||||
local planksFactory = defaultPlanks:getFactory()
|
||||
|
||||
---@type TileSheet
|
||||
local logTileSheet = TileSheet:new('wood_sheet.png', 16, 16)
|
||||
local woodTileSheet = TileSheet:new('wood_sheet.png', 16, 16)
|
||||
|
||||
local function getLogTiles(x, y)
|
||||
return {
|
||||
logTileSheet:t(x, y),
|
||||
logTileSheet:t(x, y),
|
||||
logTileSheet:t(x, y+1),
|
||||
woodTileSheet:t(x, y),
|
||||
woodTileSheet:t(x, y),
|
||||
woodTileSheet:t(x, y+1),
|
||||
}
|
||||
end
|
||||
|
||||
local t = logTileSheet
|
||||
|
||||
local t = woodTileSheet
|
||||
|
||||
---@class WoodDef
|
||||
---@field rarity Item.Rarity?
|
||||
@@ -78,6 +87,7 @@ local function registerWood(name, x, def)
|
||||
tiles = getLogTiles(x, 2),
|
||||
paramtype2 = 'facedir',
|
||||
_rarity = def.rarity,
|
||||
groups = {log = 1}
|
||||
},
|
||||
callbacks = {
|
||||
on_place = core.rotate_node
|
||||
@@ -99,21 +109,21 @@ local function registerWood(name, x, def)
|
||||
defaultLog:new({
|
||||
settings = {
|
||||
name = name..'_timber',
|
||||
tiles = {logTileSheet:t(x, 8), logTileSheet:t(x, 8),
|
||||
logTileSheet:t(x, 7), logTileSheet:t(x, 7),
|
||||
logTileSheet:t(x, 8), logTileSheet:t(x, 8),},
|
||||
tiles = {
|
||||
woodTileSheet:t(x, 8)..'^[transformR90', woodTileSheet:t(x, 8)..'^[transformR90',
|
||||
woodTileSheet:t(x, 8), woodTileSheet:t(x, 8),
|
||||
woodTileSheet:t(x, 7), woodTileSheet:t(x, 7)
|
||||
},
|
||||
paramtype2 = 'facedir',
|
||||
_rarity = def.rarity,
|
||||
groups = {segments = 1}
|
||||
},
|
||||
callbacks = {
|
||||
on_place = core.rotate_node
|
||||
}
|
||||
})
|
||||
|
||||
defaultLog:new({
|
||||
settings = {
|
||||
name = name..'_trunk',
|
||||
tiles = {logTileSheet:t(x, 3)},
|
||||
name = name..'_trunk_6_sides',
|
||||
tiles = {woodTileSheet:t(x, 3)},
|
||||
inventory_overlay = 'wood_trunk_overlay.png',
|
||||
drop = 'wood:'..name..'_log',
|
||||
paramtype2 = 'facedir',
|
||||
@@ -126,7 +136,7 @@ local function registerWood(name, x, def)
|
||||
|
||||
defaultLog:new({
|
||||
settings = {
|
||||
name = name..'_trunk_vertical',
|
||||
name = name..'_trunk_4_sides',
|
||||
tiles = getLogTiles(x, 2),
|
||||
inventory_overlay = 'wood_trunk_overlay.png',
|
||||
drop = 'wood:'..name..'_log',
|
||||
@@ -138,17 +148,15 @@ local function registerWood(name, x, def)
|
||||
}
|
||||
})
|
||||
|
||||
defaultLog:new({
|
||||
local defaultBranch6Sides = defaultLog:getExtended({
|
||||
settings = {
|
||||
drawtype = 'nodebox',
|
||||
name = name..'_trunk_branch',
|
||||
tiles = {logTileSheet:t(x, 3)},
|
||||
inventory_overlay = 'wood_trunk_overlay.png',
|
||||
drop = 'wood:'..name..'_log',
|
||||
drawtype = 'nodebox',
|
||||
name = '',
|
||||
tiles = {woodTileSheet:t(x, 3)},
|
||||
paramtype = 'light',
|
||||
node_box = {
|
||||
type = 'connected',
|
||||
fixed = {-.25,-.25,-.25, .25,.25,.25},
|
||||
node_box = {
|
||||
type = 'connected',
|
||||
fixed = {-.25,-.25,-.25, .25,.25,.25},
|
||||
connect_top = {-.25,-.25,-.25, .25,.5,.25},
|
||||
connect_bottom = {-.25,-.5,-.25, .25,.25,.25},
|
||||
connect_front = {-.25,-.25,-.5, .25,.25,.25},
|
||||
@@ -157,44 +165,133 @@ local function registerWood(name, x, def)
|
||||
connect_right = {-.25,-.25,-.25, .5,.25,.25},
|
||||
},
|
||||
connects_to = {'group:wood', 'group:soil'},
|
||||
_rarity = def.rarity,
|
||||
_rarity = def.rarity,
|
||||
},
|
||||
})
|
||||
|
||||
defaultLog:new({
|
||||
local node = defaultBranch6Sides:new({
|
||||
settings = {
|
||||
drawtype = 'nodebox',
|
||||
name = name..'_trunk_branch_vertical',
|
||||
tiles = getLogTiles(x, 2),
|
||||
name = name..'_log_branch_6_sides',
|
||||
}
|
||||
})
|
||||
|
||||
defaultBranch6Sides:new({
|
||||
settings = {
|
||||
name = name..'_trunk_branch_6_sides',
|
||||
inventory_overlay = 'wood_trunk_overlay.png',
|
||||
drop = 'wood:'..name..'_log',
|
||||
drop = name..'_log_branch_6_sides',
|
||||
}
|
||||
})
|
||||
|
||||
local defaultBranch4Sides = defaultLog:getExtended({
|
||||
settings = {
|
||||
drawtype = 'nodebox',
|
||||
name = '',
|
||||
tiles = getLogTiles(x, 2),
|
||||
drop = 'wood:'..name..'_log',
|
||||
paramtype = 'light',
|
||||
node_box = {
|
||||
type = 'connected',
|
||||
fixed = {-.25,-.25,-.25, .25,.25,.25},
|
||||
node_box = {
|
||||
type = 'connected',
|
||||
fixed = {-.25,-.25,-.25, .25,.25,.25},
|
||||
connect_top = {-.25,-.25,-.25, .25,.5,.25},
|
||||
connect_bottom = {-.25,-.5,-.25, .25,.25,.25},
|
||||
},
|
||||
connects_to = {'group:wood', 'group:soil'},
|
||||
_rarity = def.rarity,
|
||||
_rarity = def.rarity,
|
||||
},
|
||||
})
|
||||
|
||||
defaultBranch4Sides:new({
|
||||
settings = {
|
||||
name = name..'_log_branch_4_sides',
|
||||
}
|
||||
})
|
||||
|
||||
defaultBranch4Sides:new({
|
||||
settings = {
|
||||
name = name..'_trunk_branch_4_sides',
|
||||
inventory_overlay = 'wood_trunk_overlay.png',
|
||||
drop = name..'_log_branch_4_sides',
|
||||
}
|
||||
})
|
||||
|
||||
defaultPlanks:new({
|
||||
settings = {
|
||||
name = name..'_planks',
|
||||
tiles = { logTileSheet:t(x, 6) },
|
||||
tiles = { woodTileSheet:t(x, 6) },
|
||||
_rarity = def.rarity,
|
||||
groups = {segments = 3},
|
||||
},
|
||||
})
|
||||
|
||||
defaultLeafs:new({
|
||||
settings = {
|
||||
name = name..'_leafs',
|
||||
tiles = { logTileSheet:t(x, 1) },
|
||||
tiles = { woodTileSheet:t(x, 1) },
|
||||
_rarity = def.rarity,
|
||||
},
|
||||
})
|
||||
|
||||
defaultStick:new({
|
||||
settings = {
|
||||
name = name..'_stick',
|
||||
inventory_image = woodTileSheet:t(x, 9)
|
||||
}
|
||||
})
|
||||
|
||||
defaultStick:new({
|
||||
settings = {
|
||||
name = name..'_plank',
|
||||
inventory_image = woodTileSheet:t(x, 10)
|
||||
}
|
||||
})
|
||||
|
||||
defaultStick:new({
|
||||
settings = {
|
||||
name = name..'_bar',
|
||||
inventory_image = woodTileSheet:t(x, 11)
|
||||
}
|
||||
})
|
||||
|
||||
PrimitiveCraftHandler:registerCraft('wood:'..name..'_planks', {
|
||||
recipe = {
|
||||
'wood:'..name..'_log'
|
||||
},
|
||||
output = 'wood:'..name..'_planks 4',
|
||||
group = 'wood:planks_blocks',
|
||||
})
|
||||
|
||||
PrimitiveCraftHandler:registerCraft('wood:'..name..'_log_stripped', {
|
||||
recipe = {
|
||||
'wood:'..name..'_log'
|
||||
},
|
||||
output = 'wood:'..name..'_log_stripped',
|
||||
group = 'wood:logs_stripped',
|
||||
})
|
||||
|
||||
PrimitiveCraftHandler:registerCraft('wood:'..name..'_bar', {
|
||||
recipe = {
|
||||
'wood:'..name..'_log'
|
||||
},
|
||||
output = 'wood:'..name..'_bar 4',
|
||||
group = 'wood:bars',
|
||||
})
|
||||
|
||||
PrimitiveCraftHandler:registerCraft('wood:'..name..'_plank', {
|
||||
recipe = {
|
||||
'wood:'..name..'_bar'
|
||||
},
|
||||
output = 'wood:'..name..'_plank 2',
|
||||
group = 'wood:planks',
|
||||
})
|
||||
|
||||
PrimitiveCraftHandler:registerCraft('wood:'..name..'_stick', {
|
||||
recipe = {
|
||||
'wood:'..name..'_bar'
|
||||
},
|
||||
output = 'wood:'..name..'_stick 4',
|
||||
group = 'wood:sticks',
|
||||
})
|
||||
end
|
||||
|
||||
registerWood('marentine', 0)
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 133 KiB |
@@ -21,7 +21,9 @@ end
|
||||
---@param ... any
|
||||
function Events.call(eventName, ...)
|
||||
local callbacks = registeredEvents[eventName]
|
||||
assert(callbacks ~= nil, ('Event %s does not exist'):format(eventName))
|
||||
if callbacks == nil then
|
||||
return
|
||||
end
|
||||
|
||||
for _, func in ipairs(callbacks) do
|
||||
func(eventName, ...)
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
# Game fonts
|
||||
Description of the fonts that are pre-installed for the project and passed on to all clients for displaying text.
|
||||
|
||||
## Philosopher
|
||||
Download site: https://fonts-online.ru/fonts/doloto.
|
||||
|
||||
Used in:
|
||||
- `regular.ttf`
|
||||
- `mono.ttf`
|
||||
|
||||
### Info
|
||||
Designed by **Jovanny Lemonad**.
|
||||
|
||||
### Licence
|
||||
Copyright 2011 The Philosopher Project Authors (https://github.com/alexeiva/philosopher)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1 . This license is copied below, and is also available with a FAQ at: https://openfontlicense.org
|
||||
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
|
||||
#### PREAMBLE
|
||||
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
|
||||
|
||||
#### DEFINITIONS
|
||||
|
||||
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
|
||||
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
|
||||
|
||||
#### PERMISSION & CONDITIONS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
|
||||
|
||||
- Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
|
||||
- Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
|
||||
- No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
|
||||
- The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
|
||||
- The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
|
||||
|
||||
#### TERMINATION
|
||||
|
||||
This license becomes null and void if any of the above conditions are not met.
|
||||
|
||||
#### DISCLAIMER
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
---
|
||||
@@ -3,6 +3,7 @@ Smc = {}
|
||||
local modInfo = Mod.getInfo('smc__system__helper_lib')
|
||||
local require = modInfo.require
|
||||
|
||||
require('Lib.activeFormspecs')
|
||||
require('Lib.globalStep')
|
||||
require('Lib.color')
|
||||
require('Lib.immersiveCraftData')
|
||||
|
||||
19
mods/SYSTEM/HelperLib/src/Lib/activeFormspecs.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
---@type table<string, string>
|
||||
local activeFormspecsList = {}
|
||||
|
||||
---@param playerName string
|
||||
---@param formName string?
|
||||
function Smc.setActiveFormspec(playerName, formName)
|
||||
activeFormspecsList[playerName] = formName
|
||||
end
|
||||
|
||||
---@param playerName string
|
||||
---@return string?
|
||||
function Smc.getActiveFormspec(playerName)
|
||||
return activeFormspecsList[playerName]
|
||||
end
|
||||
|
||||
---@param playerName string
|
||||
function Smc.clearActiveFormspec(playerName)
|
||||
Smc.setActiveFormspec(playerName, nil)
|
||||
end
|
||||
@@ -41,7 +41,7 @@ local callsForEachPlayer = {}
|
||||
---@param timeDelay number
|
||||
---@param callbackFunc fun(deltaTime:number, player:Player)
|
||||
function Smc.registerGlobalStepForEachPlayer(timeDelay, callbackFunc)
|
||||
table.insert(callsWithDelay, {
|
||||
table.insert(callsForEachPlayer, {
|
||||
timeDelay = timeDelay,
|
||||
callbackFunc = callbackFunc,
|
||||
timer = 0.0,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---@type table<string, Item>
|
||||
---@type table<string, Item|Node>
|
||||
local registeredItems = {}
|
||||
|
||||
---@type table<string, table<string, Item>>
|
||||
---@type table<string, table<string, Item|Node>>
|
||||
local registeredItemsByMod = {}
|
||||
|
||||
---@param shortModName string
|
||||
---@param item Item
|
||||
---@param item Item|Node
|
||||
function Smc.addRegisteredItem(shortModName, item)
|
||||
local itemName = item.itemDef.settings.name
|
||||
local modItems = registeredItemsByMod[shortModName]
|
||||
@@ -18,7 +18,7 @@ function Smc.addRegisteredItem(shortModName, item)
|
||||
assert(modItems[itemName] == nil)
|
||||
|
||||
registeredItems[itemName] = item
|
||||
modItems[itemName] = item
|
||||
modItems[itemName] = item
|
||||
end
|
||||
|
||||
---@param shortModName string
|
||||
@@ -27,7 +27,13 @@ function Smc.getRegisteredItemsByMod(shortModName)
|
||||
return table.copy_with_metatables(registeredItemsByMod[shortModName])
|
||||
end
|
||||
|
||||
---@return table<string, Item>?
|
||||
---@param itemName string
|
||||
---@return Item|Node
|
||||
function Smc.getRegisteredItemByName(itemName)
|
||||
return table.copy_with_metatables(registeredItems[itemName])
|
||||
end
|
||||
|
||||
---@return table<string, Item|Node>?
|
||||
function Smc.getRegisteredItems()
|
||||
return table.copy_with_metatables(registeredItems)
|
||||
end
|
||||
|
||||
@@ -64,3 +64,26 @@ function Smc.requireFormspec()
|
||||
return class
|
||||
end
|
||||
|
||||
---@return CraftSystem
|
||||
function Smc.requireCraftSystem()
|
||||
---@type CraftSystem
|
||||
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem')
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
---@return CraftSystem.PrimitiveCraftHandler
|
||||
function Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
---@type CraftSystem.PrimitiveCraftHandler
|
||||
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem.PrimitiveCraftHandler')
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
---@return CraftSystem.ImmersiveCraftHandler
|
||||
function Smc.requireCraftSystemImmersiveCraftHandler()
|
||||
---@type CraftSystem.ImmersiveCraftHandler
|
||||
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem.ImmersiveCraftHandler')
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
@@ -170,6 +170,30 @@ function table.merge(t1, t2, recursively)
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
--- Appends a second list to the end of the first list,
|
||||
--- thereby concatenating the two lists together.
|
||||
--- @generic t
|
||||
--- @param t1 t[]
|
||||
--- @param t2 t[]
|
||||
--- @return t[]
|
||||
function table.join(t1, t2)
|
||||
ensureArgType(t1, 'table', 1, 'table.join')
|
||||
ensureArgType(t2, 'table', 2, 'table.join')
|
||||
|
||||
local result = {}
|
||||
for i, v in ipairs(t1) do
|
||||
result[i] = v
|
||||
end
|
||||
|
||||
local offset = #t1
|
||||
for i, v in ipairs(t2) do
|
||||
result[offset + i] = v
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--- Returns an array containing only unique values of the table `t`.
|
||||
--- @param t any[] Array to check
|
||||
--- @return any[]
|
||||
|
||||
@@ -40,24 +40,24 @@ local function getFormSpecString(self, playerName, isSelect)
|
||||
size = {x=21, y=12},
|
||||
})
|
||||
|
||||
listForm:
|
||||
list('current_player', 'main', 10.5, 6.5, 8, 4):
|
||||
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', self:getContex(playerName, 'scroll'))
|
||||
listForm
|
||||
:list('current_player', 'main', 10.5, 6.5, 8, 4)
|
||||
: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', self:getContex(playerName, 'scroll'))
|
||||
|
||||
if isSelect then
|
||||
---@type ItemStackString
|
||||
local item = self:getContex(playerName, 'select_item')
|
||||
local itemDef = core.registered_items[item]
|
||||
listForm:
|
||||
itemImage(11, 0.5, 2, 2, item):
|
||||
areaLabel(11, 4.5, 4, 1, 'Add to inventory:'):
|
||||
button(11, 5, 3, 1, 'admin_commands:list_add_item', '1'):
|
||||
button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemDef.stack_max)):
|
||||
areaLabel(14.5, 0.5, 6, 4,
|
||||
item..'\n\n'..
|
||||
itemDef._title..'\n'..
|
||||
itemDef._description)
|
||||
listForm
|
||||
:itemImage(11, 0.5, 2, 2, item)
|
||||
:areaLabel(11, 4.5, 4, 1, 'Add to inventory:')
|
||||
:button(11, 5, 3, 1, 'admin_commands:list_add_item', '1')
|
||||
:button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemDef.stack_max))
|
||||
:areaLabel(14.5, 0.5, 6, 4,
|
||||
item..'\n\n'..
|
||||
itemDef._title..'\n'..
|
||||
itemDef._description)
|
||||
end
|
||||
|
||||
return listForm:toString()
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
name = smc__ui__player_inventory
|
||||
depends = smc__core__formspec
|
||||
depends = smc__core__formspec, smc__core__tilesheet
|
||||
|
||||
@@ -1,40 +1,580 @@
|
||||
local stringMatch = string.match
|
||||
|
||||
local BaseUI, Formspec = Smc.requireBaseUI(), Smc.requireFormspec()
|
||||
|
||||
---@param self BaseUI
|
||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
|
||||
local require = Mod.getInfo('smc__ui__player_inventory').require
|
||||
|
||||
---@alias PlayerInventoryUI.TabType 'left'|'right'
|
||||
---@alias PlayerInventoryUI.getTabFunc fun(self:PlayerInventoryUI,playerName:string,tabType:PlayerInventoryUI.TabType):Formspec
|
||||
---@alias PlayerInventoryUI.TabName 'select_tab_menu'|'bag_tab'|'craft_tab'|'equip_tab'|'ref_tab'
|
||||
|
||||
---@type PlayerInventoryUI.getTabFunc
|
||||
local getBagTab = require('PlayerInventoryUI.getBagTab')
|
||||
---@type PlayerInventoryUI.getTabFunc
|
||||
local getCraftTab = require('PlayerInventoryUI.getCraftTab')
|
||||
---@type PlayerInventoryUI.getTabFunc
|
||||
local getEquipTab = require('PlayerInventoryUI.getEquipTab')
|
||||
---@type PlayerInventoryUI.getTabFunc
|
||||
local getRefTab = require('PlayerInventoryUI.getRefTab')
|
||||
|
||||
---@type table<PlayerInventoryUI.TabName, PlayerInventoryUI.getTabFunc>
|
||||
local tabs = {
|
||||
['bag_tab'] = getBagTab,
|
||||
['craft_tab'] = getCraftTab,
|
||||
['equip_tab'] = getEquipTab,
|
||||
['ref_tab'] = getRefTab,
|
||||
}
|
||||
|
||||
local selectTabButtonTexture, unselectTabButtonTexture = 'player_inventory_select_tab_button.png', 'player_inventory_select_tab_button_unselected.png'
|
||||
local tabButtonTextures = {
|
||||
['craft_tab'] = {
|
||||
selectTabButtonTexture,
|
||||
unselectTabButtonTexture,
|
||||
unselectTabButtonTexture,
|
||||
unselectTabButtonTexture
|
||||
},
|
||||
['equip_tab'] = {
|
||||
unselectTabButtonTexture,
|
||||
selectTabButtonTexture,
|
||||
unselectTabButtonTexture,
|
||||
unselectTabButtonTexture
|
||||
},
|
||||
['bag_tab'] = {
|
||||
unselectTabButtonTexture,
|
||||
unselectTabButtonTexture,
|
||||
selectTabButtonTexture,
|
||||
unselectTabButtonTexture
|
||||
},
|
||||
['ref_tab'] = {
|
||||
unselectTabButtonTexture,
|
||||
unselectTabButtonTexture,
|
||||
unselectTabButtonTexture,
|
||||
selectTabButtonTexture
|
||||
}
|
||||
}
|
||||
|
||||
---Returns the formspec definition for the compact (single tab)
|
||||
---version of the player's inventory.
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@return string
|
||||
local function getFormSpecString(self, playerName)
|
||||
local function getCompactForm(self, playerName)
|
||||
-- We geet the name of the selected (active) tab.
|
||||
-- The left tab is considered the primary tab (shown in the compact version).
|
||||
--
|
||||
-- If the tab is not specified, the equipment tab will be opened by default.
|
||||
---@type PlayerInventoryUI.TabName
|
||||
local leftTabName = self:getContex(playerName, 'left_tab_name') or 'equip_tab'
|
||||
|
||||
-- TODO: убрать, если будет не нужно
|
||||
local leftTabIsBlock = self:getContex(playerName, 'left_tab_is_block')
|
||||
|
||||
local InventoryForm = Formspec:new({
|
||||
size = {x=24, y=8.5},
|
||||
position = {x=0.5, y=0.6},
|
||||
size = {x=14, y=12.5},
|
||||
position = {x=0.5, y=0.55},
|
||||
noPrepend = true,
|
||||
})
|
||||
|
||||
InventoryForm:
|
||||
list('current_player', 'main', 12,0.5, 9,2)
|
||||
-- We get a table for textures for tab selection buttons according to the active tab.
|
||||
-- The active button should be lighter than the others.
|
||||
-- This is achieved by using a different texture on the button.
|
||||
local leftTabButtonTextures = tabButtonTextures[leftTabName]
|
||||
|
||||
InventoryForm
|
||||
-- Removing the inventory background color:
|
||||
:bgcolor('#00000000', 'neither')
|
||||
-- A permanent part of the inventory:
|
||||
:background(0, 0.5, 14, 12.5, 'player_inventory_compact_middle_background.png', false)
|
||||
:listColors('#00000000', '#e1b69150')
|
||||
:list('current_player', 'main', 1.5,9.75, 9,1)
|
||||
:list('current_player', 'main', 1.5,11.25, 9,1, 9)
|
||||
-- Inventory mode switch button (compact/full):
|
||||
:imageButton(13, 9.75, 0.5, 1, 'player_inventory_compact_mode_button_on.png', 'change_compact_mode')
|
||||
-- Tab:
|
||||
:container(tabs[leftTabName](self, playerName, 'left'), 1.5, 0.5)
|
||||
-- Selection buttons for the (left) panel:
|
||||
:imageButton(1.5,0,2,0.5, leftTabButtonTextures[1],'select_left_craft_tab', core.colorize('#e1b691','craft'))
|
||||
:imageButton(3.5,0,2,0.5, leftTabButtonTextures[2], 'select_left_equip_tab', core.colorize('#e1b691','equip'))
|
||||
:imageButton(5.5,0,2,0.5, leftTabButtonTextures[3], 'select_left_bag_tab', core.colorize('#e1b691','bags'))
|
||||
:imageButton(7.5,0,2,0.5, leftTabButtonTextures[4], 'select_left_ref_tab', core.colorize('#e1b691','refs'))
|
||||
|
||||
return InventoryForm:toString()
|
||||
end
|
||||
|
||||
---Returns the formspec definition for the full (two tab)
|
||||
---version of the player's inventory.
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@return string
|
||||
local function getFullForm(self, playerName)
|
||||
-- We get the names of the active tabs (left and right).
|
||||
-- The tabs are identical, but when switching the inventory
|
||||
-- to compact mode, the left tab becomes the primary one.
|
||||
--
|
||||
-- The default values are:
|
||||
-- * left tab - equipment;
|
||||
-- * right tab - crafting menu.
|
||||
---@type PlayerInventoryUI.TabName
|
||||
local leftTabName = self:getContex(playerName, 'left_tab_name') or 'equip_tab'
|
||||
---@type PlayerInventoryUI.TabName
|
||||
local rightTabName = self:getContex(playerName, 'right_tab_name') or 'craft_tab'
|
||||
|
||||
-- TODO: убрать, если будет не нужно
|
||||
local leftTabIsBlock = self:getContex(playerName, 'left_tab_is_block')
|
||||
local rightTabIsBlock = self:getContex(playerName, 'right_tab_is_block')
|
||||
|
||||
local InventoryForm = Formspec:new({
|
||||
size = {x=22, y=12.5},
|
||||
position = {x=0.5, y=0.55},
|
||||
noPrepend = true,
|
||||
})
|
||||
|
||||
-- We get texture tables for the tab selection buttons depending on the active tabs.
|
||||
-- The active button should be lighter than the others.
|
||||
-- This is achieved by using a different texture on the button.
|
||||
local leftTabButtonTextures = tabButtonTextures[leftTabName]
|
||||
local rightTabButtonTextures = tabButtonTextures[rightTabName]
|
||||
|
||||
InventoryForm
|
||||
-- Removing the inventory background color:
|
||||
:bgcolor('#00000000', 'neither')
|
||||
-- A permanent part of the inventory:
|
||||
:background(0, 9.5, 22, 3, 'player_inventory_middle_background.png', false)
|
||||
:listColors('#00000000', '#e1b69150')
|
||||
:list('current_player', 'main', 5.5,9.75, 9,1)
|
||||
:list('current_player', 'main', 5.5,11.25, 9,1, 9)
|
||||
-- Inventory mode switch button (compact/full):
|
||||
:imageButton(17, 9.75, 0.5, 1, 'player_inventory_compact_mode_button_off.png', 'change_compact_mode')
|
||||
-- Tabs:
|
||||
:container(tabs[leftTabName](self, playerName, 'left'), 0, 0.5)
|
||||
:container(tabs[rightTabName](self, playerName, 'right'), 11, 0.5)
|
||||
-- Selection buttons for the left panel:
|
||||
:imageButton(0,0,2,0.5, leftTabButtonTextures[1],'select_left_craft_tab', core.colorize('#e1b691','craft'))
|
||||
:imageButton(2,0,2,0.5, leftTabButtonTextures[2], 'select_left_equip_tab', core.colorize('#e1b691','equip'))
|
||||
:imageButton(4,0,2,0.5, leftTabButtonTextures[3], 'select_left_bag_tab', core.colorize('#e1b691','bags'))
|
||||
:imageButton(6,0,2,0.5, leftTabButtonTextures[4], 'select_left_ref_tab', core.colorize('#e1b691','refs'))
|
||||
-- Selection buttons for the right panel:
|
||||
:imageButton(11,0,2,0.5, rightTabButtonTextures[1],'select_right_craft_tab', core.colorize('#e1b691','craft'))
|
||||
:imageButton(13,0,2,0.5, rightTabButtonTextures[2], 'select_right_equip_tab', core.colorize('#e1b691','equip'))
|
||||
:imageButton(15,0,2,0.5, rightTabButtonTextures[3], 'select_right_bag_tab', core.colorize('#e1b691','bags'))
|
||||
:imageButton(17,0,2,0.5, rightTabButtonTextures[4], 'select_right_ref_tab', core.colorize('#e1b691','refs'))
|
||||
|
||||
return InventoryForm:toString()
|
||||
end
|
||||
|
||||
---Returns the inventory formspec definition
|
||||
---depending on the selected inventory mod (compact/full).
|
||||
---
|
||||
---The selected inventory mode is contained in the context of the `PlayerInventoryUI` UI class.
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@return string
|
||||
local function getFormSpecString(self, playerName)
|
||||
-- We get the selected inventory mode.
|
||||
-- * `true` - compact mode
|
||||
-- * `false` - full mode
|
||||
---@type boolean
|
||||
local compactMode = self:getContex(playerName, 'compact_mode')
|
||||
|
||||
-- By default, the player will be shown a compact form.
|
||||
if compactMode == nil then
|
||||
compactMode = true
|
||||
end
|
||||
|
||||
if compactMode then
|
||||
return getCompactForm(self, playerName)
|
||||
else
|
||||
return getFullForm(self, playerName)
|
||||
end
|
||||
end
|
||||
|
||||
---Context keys for the `PlayerInventoryUI` class.
|
||||
---@alias PlayerInventoryUI.ContexKey
|
||||
--- 'compact_mode'|
|
||||
---
|
||||
--- 'left_tab_name'|
|
||||
--- 'right_tab_name'|
|
||||
--- 'left_tab_is_block'|
|
||||
--- 'right_tab_is_block'|
|
||||
---
|
||||
--- 'left_tab_craft_selected_craft'|
|
||||
--- 'right_tab_craft_selected_craft'|
|
||||
--- 'left_tab_craft_selected_group'|
|
||||
--- 'right_tab_craft_selected_group'|
|
||||
--- 'group_image_number'|
|
||||
--- 'left_tab_craft_page_number'|
|
||||
--- 'right_tab_craft_page_number'|
|
||||
--- 'left_tab_craft_scroll'|
|
||||
--- 'right_tab_craft_scroll'
|
||||
|
||||
---@class PlayerInventoryUI : BaseUI
|
||||
---@field getFormSpecString fun(self:BaseUI,playerName:string):string
|
||||
---@field showForm fun(self:BaseUI,playerName:string):string
|
||||
---@field getFormSpecString fun(self:PlayerInventoryUI,playerName:string):string
|
||||
---@field showForm fun(self:PlayerInventoryUI,playerName:string):string
|
||||
---@field getContex fun(self:PlayerInventoryUI,player:string|Player,key:PlayerInventoryUI.ContexKey):any
|
||||
---@field setContex fun(self:PlayerInventoryUI,player:string|Player,key:PlayerInventoryUI.ContexKey,value:any)
|
||||
local PlayerInventoryUI = BaseUI:new('', getFormSpecString, false)
|
||||
|
||||
--[[
|
||||
---Shows the player their inventory.
|
||||
---@param playerName string
|
||||
-- We are overriding the `BaseUI.showForm`.
|
||||
local showForm = PlayerInventoryUI.showForm
|
||||
|
||||
function PlayerInventoryUI:showForm(playerName)
|
||||
local player = core.get_player_by_name(playerName)
|
||||
assert(player ~= nil)
|
||||
|
||||
player:set_inventory_formspec(self:getFormSpecString(playerName))
|
||||
core.show_formspec(playerName, '', '')
|
||||
-- We overwrite the player's inventory definition so that the updated inventory
|
||||
-- is shown to the player when they press the "open inventory" key.
|
||||
player:set_inventory_formspec(PlayerInventoryUI:getFormSpecString(playerName))
|
||||
|
||||
-- We call the standard `BaseUI.showForm` function for the standard operation.
|
||||
return showForm(self, playerName)
|
||||
end
|
||||
|
||||
---Closes the player's inventory.
|
||||
---@param playerName string
|
||||
function PlayerInventoryUI:closeForm(playerName)
|
||||
core.close_formspec(playerName, '')
|
||||
end--]]
|
||||
-- Handling the press of the inventory mode change button.
|
||||
PlayerInventoryUI:registerOnFormFieldAction('change_compact_mode', function(player, fieldName, fieldValue)
|
||||
local playerName = player:get_player_name()
|
||||
|
||||
local compactMode = PlayerInventoryUI:getContex(playerName, 'compact_mode')
|
||||
|
||||
-- By default, the player will be shown a compact form.
|
||||
if compactMode == nil then
|
||||
compactMode = true
|
||||
end
|
||||
|
||||
PlayerInventoryUI:setContex(playerName, 'compact_mode', (not compactMode))
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the left inventory tab selection button press.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('select_left_%S+', function(player, fieldName, fieldValue)
|
||||
local tabName = stringMatch(fieldName, 'select_%S+_(%S+_%S+)')
|
||||
assert(tabName ~= nil)
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
|
||||
PlayerInventoryUI:setContex(playerName, 'left_tab_name', tabName)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the right inventory tab selection button press.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('select_right_%S+', function(player, fieldName, fieldValue)
|
||||
local tabName = stringMatch(fieldName, 'select_%S+_(%S+_%S+)')
|
||||
assert(tabName ~= nil)
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
|
||||
PlayerInventoryUI:setContex(playerName, 'right_tab_name', tabName)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the click of the button to turning back through the crafting menu pages.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_back', function(player, fieldName, fieldValue)
|
||||
local tabType = stringMatch(fieldName, '(%S+)::page_back')
|
||||
assert(tabType == 'left' or tabType == 'right')
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
local pageNumber = PlayerInventoryUI:getContex(playerName, tabType..'_tab_craft_page_number') or 1
|
||||
pageNumber = pageNumber - 1
|
||||
|
||||
if pageNumber <= 0 then
|
||||
pageNumber = 1
|
||||
end
|
||||
|
||||
PlayerInventoryUI:setContex(playerName, tabType..'_tab_craft_page_number', pageNumber)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the click of the button to turning forward through the crafting menu pages.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_forward', function(player, fieldName, fieldValue)
|
||||
local tabType = stringMatch(fieldName, '(%S+)::page_forward')
|
||||
assert(tabType == 'left' or tabType == 'right')
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
local pageNumber = PlayerInventoryUI:getContex(playerName, tabType..'_tab_craft_page_number') or 1
|
||||
pageNumber = pageNumber + 1
|
||||
|
||||
if pageNumber <= 0 then
|
||||
pageNumber = 1
|
||||
end
|
||||
|
||||
PlayerInventoryUI:setContex(playerName, tabType..'_tab_craft_page_number', pageNumber)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Processing closing of the selected item group in the crafting menu (returning to the main list of crafts).
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::close_group', function(player, fieldName, fieldValue)
|
||||
local tabType = stringMatch(fieldName, '(%S+)::close_group')
|
||||
assert(tabType == 'left' or tabType == 'right')
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
PlayerInventoryUI:setContex(playerName, tabType..'_tab_craft_selected_group', nil)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the button click for selecting an item for crafting.
|
||||
-- Opens the item description and allows you to craft the selected item.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('.+::%S+::item_button',function(player, fieldName, fieldValue)
|
||||
local craftName, tabType = string.match(fieldName, '(.+)::(%S+)::item_button')
|
||||
assert(craftName ~= nil)
|
||||
assert(tabType == 'left' or tabType == 'right')
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
PlayerInventoryUI:setContex(playerName, tabType..'_tab_craft_selected_craft', craftName)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the click of the crafting group selection button.
|
||||
-- Causes grouped items to be expanded into a separate list.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('.+::%S+::group_button',function(player, fieldName, fieldValue)
|
||||
local groupName, tabType = string.match(fieldName, '(.+)::(%S+)::group_button')
|
||||
assert(groupName ~= nil)
|
||||
assert(tabType == 'left' or tabType == 'right')
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
PlayerInventoryUI:setContex(playerName, tabType..'_tab_craft_selected_group', groupName)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end)
|
||||
|
||||
-- Handling the click to craft an item.
|
||||
-- If the player has crafting materials, they are removed and the crafted item is added to the inventory.
|
||||
--
|
||||
-- Note: Materials are only searched in the player's main inventory.
|
||||
PlayerInventoryUI:registerOnFormFieldActionMatch('.+::craft_item', function(player, fieldName, fieldValue)
|
||||
---@type InvRef
|
||||
local inv = player:get_inventory()
|
||||
|
||||
local playerName = player:get_player_name()
|
||||
local tabType = string.match(fieldName, '(.+)::craft_item')
|
||||
assert(tabType == 'left' or tabType == 'right')
|
||||
|
||||
-- We get the recipe selected in the crafting menu.
|
||||
local craftName = PlayerInventoryUI:getContex(playerName, tabType..'_tab_craft_selected_craft')
|
||||
local craft = PrimitiveCraftHandler:getCraftByName(craftName)
|
||||
|
||||
-- We create an ItemStack of the crafted item by multiplying
|
||||
-- its count by a multiplier - the number of items the player wants to craft at once.
|
||||
-- The multiplier value is determined by the crafting button.
|
||||
local OutputStack = ItemStack(craft.output)
|
||||
OutputStack:set_count(OutputStack:get_count() * fieldValue)
|
||||
|
||||
---A table containing the items required for crafting.
|
||||
local materialStacks = {}
|
||||
|
||||
---A table containing the item groups required for crafting.
|
||||
local materialGroups = {}
|
||||
|
||||
-- We fill in the tables of required materials based on the crafting recipe.
|
||||
for _, itemName in ipairs(craft.recipe) do
|
||||
local group, count = itemName:match('group:(%S+)'), itemName:match('group:%S+ (%S+)') or 1
|
||||
|
||||
-- If the specified material is not a group of items (does not meet the 'group:(%S+)' format)...
|
||||
if group == nil then
|
||||
-- ...then it is the name of a specific item.
|
||||
-- And we enter it into the list of materials as ItemStack,
|
||||
-- also multiplying the count by the multiplier.
|
||||
local item = ItemStack(itemName)
|
||||
item:set_count(item:get_count() * fieldValue)
|
||||
|
||||
table.insert(materialStacks, item)
|
||||
else
|
||||
-- If the specified item is a group,
|
||||
-- then enter this into the materials table as a key,
|
||||
-- and the value is the number of items needed.
|
||||
materialGroups[group] = (tonumber(count) or 1) * fieldValue
|
||||
end
|
||||
end
|
||||
|
||||
-- We check if the player has the required items.
|
||||
-- If they don't have at least one or if they don't have enough, we notify them.
|
||||
for _, item in ipairs(materialStacks) do
|
||||
if not inv:contains_item('main', item) then
|
||||
core.chat_send_player(playerName, 'Not enough materials for crafting!')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- We check whether the player has the required number
|
||||
-- of items with the required group for crafting.
|
||||
-- If they don't have at least one or if they don't have enough, we notify them.
|
||||
local mainList = inv:get_list('main')
|
||||
for group, count in pairs(materialGroups) do
|
||||
for _, item in ipairs(mainList) do
|
||||
-- For each item in the inventory, we check whether it has the required group.
|
||||
if core.get_item_group(item:get_name(), group) > 0 then
|
||||
local itemCount = item:get_count()
|
||||
-- If the number of required items is greater than the number of items in the stack...
|
||||
if count > itemCount then
|
||||
-- ...then we add the entire stack to the list of materials,
|
||||
-- and subtract the materials already found from the required count.
|
||||
--
|
||||
-- This is necessary to create an item even
|
||||
-- if the player does not have a single stack in the required count,
|
||||
-- but has several items that together give the required count.
|
||||
count = count - itemCount
|
||||
table.insert(materialStacks, item)
|
||||
else
|
||||
-- else (if one stack of items is enough)
|
||||
-- we add the amount we need to the list of materials.
|
||||
item:set_count(count)
|
||||
table.insert(materialStacks, item)
|
||||
count = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- If the required quantity is still positive,
|
||||
-- it means we haven't found enough materials.
|
||||
-- There will be no crafting.
|
||||
if count > 0 then
|
||||
core.chat_send_player(playerName, 'Not enough materials for crafting!')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Finally, we check if there is free space in the inventory
|
||||
-- and if so, we take the materials from the player's inventory
|
||||
-- and return the crafted item to him.
|
||||
--
|
||||
--TODO: добавить сброс предмета на землю, если нет места.
|
||||
if inv:room_for_item('main', OutputStack) then
|
||||
for _, item in ipairs(materialStacks) do
|
||||
inv:remove_item('main', item)
|
||||
end
|
||||
|
||||
inv:add_item('main', OutputStack)
|
||||
else
|
||||
core.chat_send_player(playerName, 'There is no space in the inventory!')
|
||||
end
|
||||
end)
|
||||
|
||||
---Automatically places equipment items into their corresponding slots.
|
||||
---@param player Player
|
||||
---@param inventory InvRef
|
||||
---@param fromList string
|
||||
---@param fromIndex integer
|
||||
local function equipListring(player, inventory, fromList, fromIndex)
|
||||
local itemStack = inventory:get_stack(fromList, fromIndex)
|
||||
assert(itemStack ~= nil)
|
||||
local playerName = player:get_player_name()
|
||||
|
||||
-- We check whether the item has a group that matches the equipment slot.
|
||||
-- If so, we move the item to the slot.
|
||||
--
|
||||
-- We also check if the target slot is empty.
|
||||
-- If it's already occupied, we prevent items from being moved.
|
||||
--
|
||||
-- TODO: дописать автолистринг для одежды
|
||||
if core.get_item_group(itemStack:get_name(), 'equip_head') == 2 then
|
||||
if not inventory:get_stack('equip_head', 2):is_empty() then
|
||||
return 0
|
||||
end
|
||||
inventory:set_stack('equip_head', 2, itemStack)
|
||||
inventory:set_stack(fromList, fromIndex, nil)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
return
|
||||
|
||||
elseif core.get_item_group(itemStack:get_name(), 'equip_torso') == 2 then
|
||||
if not inventory:get_stack('equip_torso', 2):is_empty() then
|
||||
return 0
|
||||
end
|
||||
inventory:set_stack('equip_torso', 2, itemStack)
|
||||
inventory:set_stack(fromList, fromIndex, nil)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
return
|
||||
|
||||
elseif core.get_item_group(itemStack:get_name(), 'equip_legs') == 2 then
|
||||
if not inventory:get_stack('equip_legs', 2):is_empty() then
|
||||
return 0
|
||||
end
|
||||
inventory:set_stack('equip_legs', 2, itemStack)
|
||||
inventory:set_stack(fromList, fromIndex, nil)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
return
|
||||
|
||||
elseif core.get_item_group(itemStack:get_name(), 'equip_feet') == 2 then
|
||||
if not inventory:get_stack('equip_feet', 2):is_empty() then
|
||||
return 0
|
||||
end
|
||||
inventory:set_stack('equip_feet', 2, itemStack)
|
||||
inventory:set_stack(fromList, fromIndex, nil)
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
return
|
||||
|
||||
else
|
||||
-- If an item does not have any equipment groups,
|
||||
-- then we prohibit its movement (the item remains in its original location)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
-- We only allow items to be placed in equipment slot
|
||||
-- that have groups that match the slot name and index.
|
||||
core.register_allow_player_inventory_action(function(player, action, inventory, inventoryInfo)
|
||||
if action == 'move' then
|
||||
-- If the move occurs in a special slot, then we add the item to the desired slot.
|
||||
-- This is necessary to bypass the standard listring[] limitation.
|
||||
-- Equipment items will automatically place themselves in their slots
|
||||
-- when you hold down the shift key.
|
||||
if inventoryInfo.to_list == 'listring_equip' then
|
||||
return equipListring(player, inventory, inventoryInfo.from_list, inventoryInfo.from_index)
|
||||
end
|
||||
|
||||
-- Checking if a slot is an equipment slot.
|
||||
local equipGroup = string.match(inventoryInfo.to_list, 'equip_%S+')
|
||||
if equipGroup == nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- We receive the item that the player wants to place in the equipment slot.
|
||||
local itemStack = inventory:get_stack(inventoryInfo.from_list, inventoryInfo.from_index)
|
||||
assert(itemStack ~= nil)
|
||||
|
||||
if core.get_item_group(itemStack:get_name(), equipGroup) == inventoryInfo.to_index then
|
||||
return
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif action == 'put' then
|
||||
-- Checking if a slot is an equipment slot.
|
||||
local equipGroup = string.match(inventoryInfo.listname, 'equip_%S+')
|
||||
if equipGroup == nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- We receive the item that the player wants to place in the equipment slot.
|
||||
local itemStack = inventory:get_stack(inventoryInfo.listname, inventoryInfo.index)
|
||||
assert(itemStack ~= nil)
|
||||
|
||||
if core.get_item_group(itemStack:get_name(), equipGroup) == inventoryInfo.index then
|
||||
return
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Update the interface if the player has moved something from the equipment slots
|
||||
-- (this enables and disables the slot overlay).
|
||||
core.register_on_player_inventory_action(function(player, action, inventory, inventoryInfo)
|
||||
local playerName = player:get_player_name()
|
||||
if action == 'move' then
|
||||
local equipGroup = string.match(inventoryInfo.to_list, 'equip_%S+') or string.match(inventoryInfo.from_list, 'equip_%S+')
|
||||
if equipGroup ~= nil then
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end
|
||||
elseif action == 'put' then
|
||||
local equipGroup = string.match(inventoryInfo.listname, 'equip_%S+')
|
||||
if equipGroup ~= nil then
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end
|
||||
elseif action == 'take' then
|
||||
local equipGroup = string.match(inventoryInfo.listname, 'equip_%S+')
|
||||
if equipGroup ~= nil then
|
||||
PlayerInventoryUI:showForm(playerName)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return PlayerInventoryUI
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
local Formspec = Smc.requireFormspec()
|
||||
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@param tabType PlayerInventoryUI.TabType
|
||||
---@return Formspec
|
||||
local function getBagTab(self, playerName, tabType)
|
||||
local BagTab = Formspec:new()
|
||||
|
||||
BagTab
|
||||
:image(0, 0, 11, 9, 'player_inventory_tab_background.png')
|
||||
:label(2,2, 'BAG PANE')
|
||||
|
||||
return BagTab
|
||||
end
|
||||
|
||||
return getBagTab
|
||||
130
mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getCraftTab.lua
Normal file
@@ -0,0 +1,130 @@
|
||||
local mathFloor = math.floor
|
||||
|
||||
---Number of crafting recipes on one menu page.
|
||||
local PAGE_NUMBER_ITEMS = 24
|
||||
|
||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
|
||||
local Formspec = Smc.requireFormspec()
|
||||
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@param tabType PlayerInventoryUI.TabType
|
||||
---@return Formspec
|
||||
local function getCraftTab(self, playerName, tabType)
|
||||
if tabType ~= 'left' and tabType ~= 'right' then
|
||||
error('Incorrect argument `tabType`: '..tabType)
|
||||
end
|
||||
|
||||
local CraftTab = Formspec:new()
|
||||
|
||||
---@type string
|
||||
local selectedCraft = self:getContex(playerName, tabType..'_tab_craft_selected_craft') or ''
|
||||
---@type CraftSystem.CraftGroup?
|
||||
local selectedGroup = self:getContex(playerName, tabType..'_tab_craft_selected_group')
|
||||
local pageNumber = self:getContex(playerName, tabType..'_tab_craft_page_number') or 1
|
||||
|
||||
local crafts
|
||||
if selectedGroup == nil then
|
||||
---@type (CraftSystem.PrimitiveCraft[]|CraftSystem.PrimitiveCraft)[]
|
||||
crafts = PrimitiveCraftHandler:getLearnedCrafts(playerName)
|
||||
else
|
||||
---@type CraftSystem.PrimitiveCraft[]
|
||||
crafts = PrimitiveCraftHandler:getCraftsByGroup(selectedGroup)
|
||||
end
|
||||
|
||||
local craftsListForm = Formspec:new()
|
||||
|
||||
---Maximum number of crafting recipe pages
|
||||
---@type integer
|
||||
local pagesMax = math.ceil(#crafts/PAGE_NUMBER_ITEMS)
|
||||
|
||||
if pageNumber > pagesMax then
|
||||
pageNumber = pagesMax
|
||||
self:setContex(playerName, tabType..'_tab_craft_page_number', pageNumber)
|
||||
end
|
||||
|
||||
local w, h = 0.0, 0.0
|
||||
|
||||
if selectedGroup ~= nil then
|
||||
craftsListForm
|
||||
:imageButton(0, 0, 1.125, 1.125, 'player_inventory_craft_tab_close_group_button_background.png', tabType..'::close_group')
|
||||
w = 1.125
|
||||
end
|
||||
|
||||
for i = PAGE_NUMBER_ITEMS*pageNumber-PAGE_NUMBER_ITEMS+1, PAGE_NUMBER_ITEMS*pageNumber do
|
||||
local craft = crafts[i]
|
||||
if craft == nil then
|
||||
break
|
||||
end
|
||||
|
||||
---@type ItemStackString?
|
||||
local output = craft.output
|
||||
|
||||
if output ~= nil then
|
||||
if craft.name == selectedCraft then
|
||||
craftsListForm
|
||||
:imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_pressed_background.png', craft.name..'::'..tabType..'::item_button')
|
||||
else
|
||||
craftsListForm
|
||||
:imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_background.png', craft.name..'::'..tabType..'::item_button')
|
||||
end
|
||||
|
||||
craftsListForm
|
||||
:itemImage(w+0.0625, h+0.0625, 1, 1, output)
|
||||
else
|
||||
local craft = craft[1]
|
||||
assert(craft ~= nil)
|
||||
|
||||
craftsListForm
|
||||
:imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_background.png', craft.group..'::'..tabType..'::group_button')
|
||||
:itemImage(w+0.0625, h+0.0625, 1, 1, craft.output)
|
||||
:image(w, h, 1.125, 1.125, 'player_inventory_craft_tab_group_button_overlay.png')
|
||||
end
|
||||
w = w + 1.125
|
||||
|
||||
if w >= 4 then
|
||||
w = 0
|
||||
h = h + 1.125
|
||||
end
|
||||
end
|
||||
|
||||
CraftTab
|
||||
:background(0, 0, 11, 9, 'player_inventory_craft_tab_background.png')
|
||||
:container(craftsListForm, 0.5, 0.5)
|
||||
:button(1.75, 7.75, 1, 0.5, tabType..'::page_back', '<')
|
||||
:button(2.75, 7.75, 1, 0.5, tabType..'::page_forward', '>')
|
||||
:label(2.5,8.5, ('%s/%s'):format(pageNumber, pagesMax))
|
||||
|
||||
if selectedCraft ~= '' then
|
||||
local craft = PrimitiveCraftHandler:getCraftByName(selectedCraft)
|
||||
local item = ItemStack(craft.output)
|
||||
local itemDef = item:get_definition()
|
||||
|
||||
local recipe = ''
|
||||
for _, itemName in ipairs(craft.recipe) do
|
||||
local group, count = itemName:match('group:(%S+)'), itemName:match('group:%S+ (%S+)') or 1
|
||||
|
||||
if group == nil then
|
||||
local recipeItem = ItemStack(itemName)
|
||||
recipe = recipe..'- '..core.strip_colors(recipeItem:get_definition()._title)..' x'..recipeItem:get_count()..'\n'
|
||||
else
|
||||
recipe = recipe..'- any item from the group "'..group..'" x'..count..'\n'
|
||||
end
|
||||
end
|
||||
|
||||
CraftTab
|
||||
:itemImage(5.5, 0.5, 2, 2, craft.output)
|
||||
:areaLabel(5.5, 3, 4, 4,
|
||||
itemDef._title..'\n'..
|
||||
itemDef._description..'\n\n'..
|
||||
'Needed:\n'..recipe)
|
||||
:areaLabel(5.5, 7, 4, 1, 'Craft:')
|
||||
:button(5.5, 7.5, 2, 1, tabType..'::craft_item', '1')
|
||||
:button(7.5, 7.5,2, 1, tabType..'::craft_item', ''..tostring(itemDef.stack_max))
|
||||
end
|
||||
|
||||
return CraftTab
|
||||
end
|
||||
|
||||
return getCraftTab
|
||||
@@ -0,0 +1,64 @@
|
||||
local Formspec, TileSheet = Smc.requireFormspec(), Smc.requireTileSheet()
|
||||
|
||||
local slotsOverlayTileSheet = TileSheet:new('player_inventory_equip_tab_armor_slots_overlay_sheet.png', 16, 16)
|
||||
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@param tabType PlayerInventoryUI.TabType
|
||||
---@return Formspec
|
||||
local function getEquipTab(self, playerName, tabType)
|
||||
local EquipTab = Formspec:new()
|
||||
|
||||
---The x coordinate for the equipment slot position
|
||||
local equipListsX = 4.5
|
||||
|
||||
EquipTab
|
||||
:image(0, 0, 11, 9, 'player_inventory_equip_tab_background.png')
|
||||
-- Equipment slots:
|
||||
:label(equipListsX, 0.75, 'cloth')
|
||||
:label(equipListsX+1.25, 0.75, 'armor')
|
||||
:list('current_player', 'equip_head', equipListsX, 1, 2, 1)
|
||||
:list('current_player', 'equip_torso', equipListsX, 2.25, 2, 1)
|
||||
:list('current_player', 'equip_legs', equipListsX, 3.5, 2, 1)
|
||||
:list('current_player', 'equip_feet', equipListsX, 4.75, 2, 1)
|
||||
-- Hidden equipment slot for correct listing
|
||||
-- (distribute equipment across its slots while holding shift):
|
||||
:list('current_player', 'listring_equip', 0, 0, 1, 1)
|
||||
:listring({
|
||||
{'current_player', 'main'},
|
||||
{'current_player', 'listring_equip'},
|
||||
{'current_player', 'main'},
|
||||
{'current_player', 'equip_head'},
|
||||
{'current_player', 'main'},
|
||||
{'current_player', 'equip_torso'},
|
||||
{'current_player', 'main'},
|
||||
{'current_player', 'equip_legs'},
|
||||
{'current_player', 'main'},
|
||||
{'current_player', 'equip_feet'},
|
||||
{'current_player', 'main'},
|
||||
})
|
||||
|
||||
local player = core.get_player_by_name(playerName)
|
||||
assert(player)
|
||||
|
||||
local inv = player:get_inventory()
|
||||
|
||||
-- If the equipment slots are empty, then we apply an overlay.
|
||||
-- TODO: оверлей одежды
|
||||
if inv:get_stack('equip_head', 2):is_empty() then
|
||||
EquipTab:image(equipListsX+1.25, 1, 1, 1, slotsOverlayTileSheet:t(0,0))
|
||||
end
|
||||
if inv:get_stack('equip_torso', 2):is_empty() then
|
||||
EquipTab:image(equipListsX+1.25, 2.25, 1, 1, slotsOverlayTileSheet:t(0,1))
|
||||
end
|
||||
if inv:get_stack('equip_legs', 2):is_empty() then
|
||||
EquipTab:image(equipListsX+1.25, 3.5, 1, 1, slotsOverlayTileSheet:t(0,2))
|
||||
end
|
||||
if inv:get_stack('equip_feet', 2):is_empty() then
|
||||
EquipTab:image(equipListsX+1.25, 4.75, 1, 1, slotsOverlayTileSheet:t(0,3))
|
||||
end
|
||||
|
||||
return EquipTab
|
||||
end
|
||||
|
||||
return getEquipTab
|
||||
@@ -0,0 +1,17 @@
|
||||
local Formspec = Smc.requireFormspec()
|
||||
|
||||
---@param self PlayerInventoryUI
|
||||
---@param playerName string
|
||||
---@param tabType PlayerInventoryUI.TabType
|
||||
---@return Formspec
|
||||
local function getRefTab(self, playerName, tabType)
|
||||
local RefTab = Formspec:new()
|
||||
|
||||
RefTab
|
||||
:image(0, 0, 11, 9, 'player_inventory_tab_background.png')
|
||||
:label(2,2, 'REFERENCE PANE')
|
||||
|
||||
return RefTab
|
||||
end
|
||||
|
||||
return getRefTab
|
||||
|
After Width: | Height: | Size: 266 KiB |
|
After Width: | Height: | Size: 199 B |
|
After Width: | Height: | Size: 176 KiB |
|
After Width: | Height: | Size: 709 B |
|
After Width: | Height: | Size: 709 B |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 66 KiB |