Compare commits
157 Commits
mapgen-opt
...
d5bd81f59b
| Author | SHA1 | Date | |
|---|---|---|---|
| d5bd81f59b | |||
| 836dfb5478 | |||
| db34945c5d | |||
| dc1a714848 | |||
| 365da6f3d6 | |||
| 28689f042e | |||
| 1799d6d32e | |||
| 60003eea73 | |||
| 6cec8806ed | |||
| 098f247928 | |||
| ce38f752f7 | |||
| 9252cf429c | |||
| fa4fb0cac1 | |||
| e515686487 | |||
| b10214edb9 | |||
| d3f583272d | |||
| ba4dc2db62 | |||
| ae20c94d91 | |||
| 90cf189b1a | |||
| 5146fd3e07 | |||
| 2528fc1075 | |||
| 71224de5ce | |||
| 44049de290 | |||
| 8307de77eb | |||
| 91cb3f1d6d | |||
| 9a3ea9d0c4 | |||
| cb6e046b81 | |||
| 21e0b8ec22 | |||
| 99b8c1d0b6 | |||
| 0a20ac8987 | |||
| 98dc1e17b7 | |||
| c0cbf86c8b | |||
| 592bbf9c58 | |||
| 3854410041 | |||
| 9ee71e9261 | |||
| 9389b02cda | |||
| 3eb8b375ec | |||
| 0a6d19102a | |||
| 78c1556f26 | |||
| c6e12ebb08 | |||
| 44952915e7 | |||
| dc0d5dc2c1 | |||
| 8a5b358d79 | |||
| 0051dea067 | |||
| 83aac87ab9 | |||
| bdef2fffaf | |||
| c578e6d5b1 | |||
| 85aaf470f7 | |||
| bd1059f9d7 | |||
| 73905c8bc6 | |||
| e410afaffc | |||
| ab140b4373 | |||
| 832ff491f6 | |||
| 9bbdbe4d2b | |||
| edd20882ed | |||
| 35de78bdec | |||
| 0ee21106d5 | |||
| ac8cb8a99f | |||
| 1a97abe49e | |||
| 3255b919e2 | |||
| 2b7600b745 | |||
| 5265024231 | |||
| 089105d3e9 | |||
| 88abb30041 | |||
| 566fbc36d7 | |||
| c143e95b27 | |||
| 35699c1489 | |||
| 17a2aabfcc | |||
| 4d11335470 | |||
| f60faa4293 | |||
| c902aff4af | |||
| 4a8a6245a6 | |||
| 08dde36326 | |||
| 964a60ed7c | |||
| 6c64e2fe27 | |||
| 3feefb2e96 | |||
| e8210924bf | |||
| bbaf18f352 | |||
| 95bba1b02d | |||
| b314f7adf8 | |||
| 0b372111cf | |||
| c2782dda61 | |||
| a9f96d97f2 | |||
| 18d152bfa2 | |||
| bbafab8e00 | |||
| c871b549d8 | |||
| 7c241af96a | |||
| e4f0799487 | |||
| 757221e668 | |||
| 3793afebbd | |||
| af3ce8c769 | |||
| fcae65e8f8 | |||
| 1b98571eae | |||
| 51394d1df6 | |||
| c6ec550ee4 | |||
| b881039368 | |||
| 1b5d122205 | |||
| 7c7a318d22 | |||
| 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 |
99
.emmyrc.json
99
.emmyrc.json
@@ -1,99 +0,0 @@
|
|||||||
{
|
|
||||||
"codeAction": {
|
|
||||||
"insertSpace": false
|
|
||||||
},
|
|
||||||
"codeLens": {
|
|
||||||
"enable": true
|
|
||||||
},
|
|
||||||
"completion": {
|
|
||||||
"autoRequire": false,
|
|
||||||
"autoRequireFunction": "require",
|
|
||||||
"autoRequireNamingConvention": "keep",
|
|
||||||
"autoRequireSeparator": ".",
|
|
||||||
"callSnippet": false,
|
|
||||||
"enable": true,
|
|
||||||
"postfix": "@"
|
|
||||||
},
|
|
||||||
"diagnostics": {
|
|
||||||
"diagnosticInterval": 1,
|
|
||||||
"disable": [
|
|
||||||
"unnecessary-if",
|
|
||||||
"redefined-local"
|
|
||||||
],
|
|
||||||
"enable": true,
|
|
||||||
"enables": [],
|
|
||||||
"globals": [
|
|
||||||
"core",
|
|
||||||
"Smc",
|
|
||||||
"table",
|
|
||||||
"Events",
|
|
||||||
"VoxelArea",
|
|
||||||
"VoxelManip",
|
|
||||||
"vector",
|
|
||||||
"Ensure",
|
|
||||||
"string",
|
|
||||||
"string_utf8",
|
|
||||||
"Profiler"
|
|
||||||
],
|
|
||||||
"globalsRegex": []
|
|
||||||
},
|
|
||||||
"documentColor": {
|
|
||||||
"enable": true
|
|
||||||
},
|
|
||||||
"hint": {
|
|
||||||
"enable": true,
|
|
||||||
"indexHint": true,
|
|
||||||
"localHint": true,
|
|
||||||
"overrideHint": true,
|
|
||||||
"paramHint": true
|
|
||||||
},
|
|
||||||
"hover": {
|
|
||||||
"enable": true
|
|
||||||
},
|
|
||||||
"references": {
|
|
||||||
"enable": true,
|
|
||||||
"fuzzySearch": true,
|
|
||||||
"shortStringSearch": false
|
|
||||||
},
|
|
||||||
"resource": {
|
|
||||||
"paths": []
|
|
||||||
},
|
|
||||||
"runtime": {
|
|
||||||
"classDefaultCall": {
|
|
||||||
"forceNonColon": false,
|
|
||||||
"forceReturnSelf": false,
|
|
||||||
"functionName": ""
|
|
||||||
},
|
|
||||||
"extensions": [],
|
|
||||||
"frameworkVersions": [],
|
|
||||||
"requireLikeFunction": [],
|
|
||||||
"requirePattern": [],
|
|
||||||
"version": "LuaJIT"
|
|
||||||
},
|
|
||||||
"semanticTokens": {
|
|
||||||
"enable": true
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"detailSignatureHelper": true
|
|
||||||
},
|
|
||||||
"strict": {
|
|
||||||
"arrayIndex": true,
|
|
||||||
"docBaseConstMatchBaseType": true,
|
|
||||||
"metaOverrideFileDefine": true,
|
|
||||||
"requirePath": false,
|
|
||||||
"typeCall": false
|
|
||||||
},
|
|
||||||
"workspace": {
|
|
||||||
"enableReindex": false,
|
|
||||||
"encoding": "utf-8",
|
|
||||||
"ignoreDir": [],
|
|
||||||
"ignoreGlobs": [],
|
|
||||||
"library": [
|
|
||||||
"util/ide-helper"
|
|
||||||
],
|
|
||||||
"moduleMap": [],
|
|
||||||
"preloadFileSize": 0,
|
|
||||||
"reindexDuration": 5000,
|
|
||||||
"workspaceRoots": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
|||||||
[submodule "util/ide-helper"]
|
[submodule "util/ide-helper"]
|
||||||
path = util/ide-helper
|
path = util/ide-helper
|
||||||
url = https://github.com/Voxrame/luanti-ide-helper.git
|
url = https://git.apancore.ru/Apancore.Studio/smc-luanti-ide-helper.git
|
||||||
[submodule "mods/SYSTEM/Utf8"]
|
[submodule "mods/SYSTEM/Utf8"]
|
||||||
path = mods/SYSTEM/Utf8
|
path = mods/SYSTEM/Utf8
|
||||||
url = https://git.apancore.ru/Apancore.Studio/utf8_api.git
|
url = https://git.apancore.ru/Apancore.Studio/utf8_api.git
|
||||||
|
|||||||
72
.luacheckrc
72
.luacheckrc
@@ -1,72 +0,0 @@
|
|||||||
unused_args = false
|
|
||||||
allow_defined_top = true
|
|
||||||
max_line_length = 150
|
|
||||||
|
|
||||||
std = "lua51"
|
|
||||||
|
|
||||||
globals = {
|
|
||||||
"core",
|
|
||||||
}
|
|
||||||
|
|
||||||
read_globals = {
|
|
||||||
table = { fields = {
|
|
||||||
-- MT Builtin:
|
|
||||||
"copy", "indexof", "insert_all", "key_value_swap",
|
|
||||||
-- our Core/helpers:
|
|
||||||
-- table:
|
|
||||||
"contains", "keyof", "has_value", "has_key", "merge", "join", "merge_values",
|
|
||||||
"is_empty", "overwrite", "keys_of", "count", "keys", "values",
|
|
||||||
"only", "except", "keys_has_one_of_values", "equals", "multiply_each_value",
|
|
||||||
"map", "add_values", "sub_values", "mul_values", "div_values"
|
|
||||||
} },
|
|
||||||
|
|
||||||
string = { fields = {
|
|
||||||
-- MT Builtin:
|
|
||||||
"split", "trim",
|
|
||||||
-- our Core/helpers:
|
|
||||||
"is_one_of", "replace",
|
|
||||||
-- TODO: "startsWith", "endsWith", ...
|
|
||||||
} },
|
|
||||||
|
|
||||||
math = { fields = {
|
|
||||||
-- MT Builtin:
|
|
||||||
"sign", "hypot", "factorial", "round",
|
|
||||||
-- Core/helpers:
|
|
||||||
"limit", "clamp"
|
|
||||||
} },
|
|
||||||
|
|
||||||
io = { fields = {
|
|
||||||
-- our Core/helpers:
|
|
||||||
"file_exists", "write_to_file", "read_from_file"
|
|
||||||
} },
|
|
||||||
|
|
||||||
os = { fields = {
|
|
||||||
-- our Core/helpers:
|
|
||||||
"DIRECTORY_SEPARATOR",
|
|
||||||
} },
|
|
||||||
|
|
||||||
-- Builtin
|
|
||||||
"vector", "nodeupdate", "PseudoRandom",
|
|
||||||
"VoxelManip", "VoxelArea",
|
|
||||||
"ItemStack", "Settings",
|
|
||||||
"dump", "DIR_DELIM",
|
|
||||||
|
|
||||||
-- Mods APIs
|
|
||||||
"intllib",
|
|
||||||
"screwdriver",
|
|
||||||
"armor", -- lottarmor
|
|
||||||
"multiskin", -- lottarmor
|
|
||||||
"mobs",
|
|
||||||
"worldedit",
|
|
||||||
"areas",
|
|
||||||
|
|
||||||
-- Functions:
|
|
||||||
"get_mail", -- mail_list из lord-server/lord_ext
|
|
||||||
"within_limits", -- mobs api
|
|
||||||
|
|
||||||
-- Legacy
|
|
||||||
"spawn_falling_node",
|
|
||||||
}
|
|
||||||
|
|
||||||
exclude_files = {
|
|
||||||
}
|
|
||||||
52
.luarc.json
Normal file
52
.luarc.json
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
|
||||||
|
"runtime": {
|
||||||
|
"version": "LuaJIT",
|
||||||
|
"fileEncoding": "utf8"
|
||||||
|
},
|
||||||
|
"workspace": {
|
||||||
|
"library": [
|
||||||
|
"${workspaceFolder}/",
|
||||||
|
"util/ide-helper"
|
||||||
|
],
|
||||||
|
"ignoreDir": [
|
||||||
|
".vscode",
|
||||||
|
".git",
|
||||||
|
".github",
|
||||||
|
".gitea",
|
||||||
|
"util"
|
||||||
|
],
|
||||||
|
"ignoreSubmodules": false
|
||||||
|
},
|
||||||
|
"diagnostics": {
|
||||||
|
"libraryFiles": "Enable",
|
||||||
|
"workspaceDelay": 1,
|
||||||
|
"disable": [
|
||||||
|
"inject-field"
|
||||||
|
],
|
||||||
|
"globals": [
|
||||||
|
// Smc globals:
|
||||||
|
"Smc",
|
||||||
|
"Events",
|
||||||
|
"Ensure",
|
||||||
|
"Profiler",
|
||||||
|
// Luanti globals:
|
||||||
|
"core",
|
||||||
|
"VoxelArea",
|
||||||
|
"VoxelManip",
|
||||||
|
"vector",
|
||||||
|
// Other:
|
||||||
|
"string_utf8"
|
||||||
|
],
|
||||||
|
"groupFileStatus": {
|
||||||
|
"ambiguity": "Any",
|
||||||
|
"duplicate": "Any",
|
||||||
|
"global": "Any",
|
||||||
|
"redefined": "Any",
|
||||||
|
"strict": "Any",
|
||||||
|
"type-check": "Any",
|
||||||
|
"unbalanced": "Any"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"completion.callSnippet": "Both"
|
||||||
|
}
|
||||||
26
LICENSE.md
26
LICENSE.md
@@ -1,8 +1,10 @@
|
|||||||
# Source code licensing
|
# SMC Licensing
|
||||||
|
|
||||||
|
## Source code licensing
|
||||||
|
|
||||||
**The MIT License (MIT)**
|
**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:
|
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:
|
||||||
|
|
||||||
@@ -10,15 +12,21 @@ The above copyright notice and this permission notice shall be included in all c
|
|||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
------------------------
|
## Assets licensing
|
||||||
|
|
||||||
# Sprites licensing
|
|
||||||
|
|
||||||
**CC BY 4.0**
|
**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.
|
All assets except those listed here are copyrighted by Van (varttist) and are distributed under the CC BY 4.0.
|
||||||
|
|
||||||
List of all textures and authors:
|
List of other assets and authors:
|
||||||
- ...
|
- *nothing*
|
||||||
|
|
||||||
|
## Submodules licenses
|
||||||
|
Submodules may contain their own licenses, different from the main project.
|
||||||
|
For details, see the `LICENSE.md` files in the corresponding modules.
|
||||||
|
|
||||||
|
List of submodules:
|
||||||
|
- `util/ide-helper` - MIT
|
||||||
|
- `mods/SYSTEM/Utf8` - BSD 3-Clause License
|
||||||
20
README.md
20
README.md
@@ -1,12 +1,16 @@
|
|||||||
|
# Simple Makes Complex Game
|
||||||

|

|
||||||
|
[](https://github.com/lord-server/lord?tab=readme-ov-file#contributors--%D1%83%D1%87%D0%B0%D1%81%D1%82%D0%BD%D0%B8%D0%BA%D0%B8)
|
||||||
|
|
||||||
# Simple Makes Complex
|
**Simple Makes Complex** is a [Luanti](https://www.luanti.org/en/) engine-based game focused on the multiplayer gameplay.
|
||||||
Simple Makes Complex is a Luanti engine-based game focused on the multiplayer gameplay.
|
|
||||||
|
|
||||||
# Licensing
|
## Licensing
|
||||||
- The project's core code is licensed under [MIT](/LICENSE).
|
- The project's core code is licensed under [MIT](/LICENSE.md#source-code-licensing).
|
||||||
- Submodules may contain their own license.
|
- Media assets are used and distributed under [CC-BY-4.0](/LICENSE.md#assets-licensing).
|
||||||
- Media assets are used and distributed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/).
|
- Submodules can contain their own [licenses](/LICENSE.md#submodules-licenses).
|
||||||
|
|
||||||
# Assets used
|
See [`LICENSE.md`](/LICENSE.md) file for details.
|
||||||
- Font used in the `/menu/last_header.png`: https://fontstruct.com/fontstructions/show/2722233/gbjve (danil_2461, [CC0](http://creativecommons.org/publicdomain/zero/1.0/))
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|

|
||||||
@@ -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: ""
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 7.3 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB |
4
mods/CORE/BaseProcessingStation/init.lua
Normal file
4
mods/CORE/BaseProcessingStation/init.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
local modInfo = Mod.getInfo('smc__core__base_processing_station')
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
return require('BaseProcessingStation')
|
||||||
2
mods/CORE/BaseProcessingStation/mod.conf
Normal file
2
mods/CORE/BaseProcessingStation/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__core__base_processing_station
|
||||||
|
depends = smc__core__craft_system, smc__core__node
|
||||||
100
mods/CORE/BaseProcessingStation/src/BaseProcessingStation.lua
Normal file
100
mods/CORE/BaseProcessingStation/src/BaseProcessingStation.lua
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
local TICKRATE = 1
|
||||||
|
|
||||||
|
local assert = assert
|
||||||
|
local coreGetMeta, coreGetTimer, coreSwapNode = core.get_meta, core.get_node_timer, core.swap_node
|
||||||
|
|
||||||
|
local CraftSystem = Smc.requireCraftSystem()
|
||||||
|
local PlayerInventoryUI = Smc.requirePlayerInventoryUI()
|
||||||
|
|
||||||
|
---An abstract class representing nodes that implement crafting of the `processing` type.
|
||||||
|
---@class BaseProcessingStation : Class, NodeSuperClass
|
||||||
|
---@field craftType CraftSystem.ProcessingCraftType
|
||||||
|
---@field handler CraftSystem.ProcessingCraftHandler
|
||||||
|
---@field tab PlayerInventoryUI.getTabFunc
|
||||||
|
---@field nodeName string?
|
||||||
|
---@field activeNodeName string?
|
||||||
|
local BaseProcessingStation = Class:extend({})
|
||||||
|
|
||||||
|
---Definition table for the `BaseProcessingStation`.
|
||||||
|
---
|
||||||
|
---**Only for EmmyLua.**
|
||||||
|
---@class BaseProcessingStationDef
|
||||||
|
---@field craftType CraftSystem.ProcessingCraftType
|
||||||
|
---@field tab PlayerInventoryUI.getTabFunc
|
||||||
|
|
||||||
|
---@alias BaseProcessingStation.NodesDefinition {settings:Node.Settings, activeSettings:Node.Settings?, callbacks:Node.Callbacks?}
|
||||||
|
|
||||||
|
---@param def BaseProcessingStationDef
|
||||||
|
---@param nodesDef BaseProcessingStation.NodesDefinition?
|
||||||
|
function BaseProcessingStation:new(def, nodesDef)
|
||||||
|
local handler = CraftSystem:getProcessingCraftHandler(def.craftType)
|
||||||
|
|
||||||
|
---@type BaseProcessingStation
|
||||||
|
local instance = self:getInstance({})
|
||||||
|
instance.craftType = def.craftType
|
||||||
|
instance.handler = handler
|
||||||
|
instance.tab = def.tab
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
---A wrapper around `core.get_meta()` for convenience
|
||||||
|
---and returning the correct `MetaDataRef` type.
|
||||||
|
---@static
|
||||||
|
---@param pos MapVector
|
||||||
|
---@return MetaDataRef
|
||||||
|
function BaseProcessingStation:getMeta(pos)
|
||||||
|
return coreGetMeta(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Opens the player's inventory, adding the node tab described in `self.tab`.
|
||||||
|
---@param pos MapVector
|
||||||
|
---@param player Player
|
||||||
|
function BaseProcessingStation:showForm(pos, player)
|
||||||
|
local playerName = player:get_player_name()
|
||||||
|
|
||||||
|
PlayerInventoryUI:addActiveNodeForm(pos, playerName)
|
||||||
|
PlayerInventoryUI:setContex(playerName, 'left_tab_name', 'node_tab')
|
||||||
|
PlayerInventoryUI:setContex(playerName, 'node_tab_pos', pos)
|
||||||
|
PlayerInventoryUI:setContex(playerName, 'node_tab', self.tab)
|
||||||
|
|
||||||
|
PlayerInventoryUI:showForm(playerName)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Starts the station timer only if it is not running.
|
||||||
|
---
|
||||||
|
---Returns `true` if the timer has been started.
|
||||||
|
---@static
|
||||||
|
---@param pos MapVector
|
||||||
|
---@param timeout number? If is `nil`, the global `TICKRATE` setting will be used.
|
||||||
|
---@return boolean
|
||||||
|
function BaseProcessingStation:startTimer(pos, timeout)
|
||||||
|
local timer = coreGetTimer(pos)
|
||||||
|
|
||||||
|
if not timer:is_started() then
|
||||||
|
timer:start(timeout or TICKRATE)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
---Replaces the node with active or inactive depending on the status of the process.
|
||||||
|
---
|
||||||
|
---If an active node is not specified for a station,
|
||||||
|
---then no replacement will occur regardless of the status of the process.
|
||||||
|
---@param isProcessing boolean The stations process status. If `true`, the process is running.
|
||||||
|
---@param pos MapVector
|
||||||
|
function BaseProcessingStation:swapNode(isProcessing, pos)
|
||||||
|
assert(self.nodeName ~= nil)
|
||||||
|
|
||||||
|
if self.activeNodeName ~= nil then
|
||||||
|
if isProcessing then
|
||||||
|
coreSwapNode(pos, {name = self.activeNodeName})
|
||||||
|
else
|
||||||
|
coreSwapNode(pos, {name = self.nodeName})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return BaseProcessingStation
|
||||||
@@ -24,13 +24,16 @@ function BaseUI:new(name, getFormSpecString, clearContex)
|
|||||||
instance.getFormSpecString = getFormSpecString
|
instance.getFormSpecString = getFormSpecString
|
||||||
|
|
||||||
if clearContex then
|
if clearContex then
|
||||||
core.log(name)
|
|
||||||
-- Ensure that when the form is closed, the context is cleared.
|
-- Ensure that when the form is closed, the context is cleared.
|
||||||
instance:registerOnFormQuit(function(player)
|
instance:registerOnFormQuit(function(player)
|
||||||
instance:clearContex(player)
|
instance:clearContex(player)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
instance:registerOnFormQuit(function(player)
|
||||||
|
Smc.clearActiveFormspec(player:get_player_name())
|
||||||
|
end)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -118,12 +121,14 @@ end
|
|||||||
---@param playerName string
|
---@param playerName string
|
||||||
function BaseUI:showForm(playerName, ...)
|
function BaseUI:showForm(playerName, ...)
|
||||||
core.show_formspec(playerName, self.name, self:getFormSpecString(playerName, ...))
|
core.show_formspec(playerName, self.name, self:getFormSpecString(playerName, ...))
|
||||||
|
Smc.setActiveFormspec(playerName, self.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Close the player the FormSpec registered by the instance of this UI.
|
---Close the player the FormSpec registered by the instance of this UI.
|
||||||
---@param playerName string
|
---@param playerName string
|
||||||
function BaseUI:closeForm(playerName)
|
function BaseUI:closeForm(playerName)
|
||||||
core.close_formspec(playerName, self.name)
|
core.close_formspec(playerName, self.name)
|
||||||
|
Smc.clearActiveFormspec(playerName)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
local modInfo = Mod.getInfo('smc__core__control')
|
|
||||||
local require = modInfo.require
|
|
||||||
|
|
||||||
return require('Control')
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
---@class Events.Control
|
|
||||||
local Control = {}
|
|
||||||
|
|
||||||
-- control.on_press
|
|
||||||
|
|
||||||
---@param callbackFunc fun(player:Player, controlName:string)
|
|
||||||
function Control.subcribeOnPress(callbackFunc)
|
|
||||||
Events.subscribe('control.on_press', callbackFunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- control.on_release
|
|
||||||
|
|
||||||
---@param callbackFunc fun(player:Player, controlName:string, holdTime:number)
|
|
||||||
function Control.subcribeOnRelease(callbackFunc)
|
|
||||||
Events.subscribe('control.on_release', callbackFunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- control.on_hold
|
|
||||||
|
|
||||||
---@param callbackFunc fun(player:Player, controlName:string, holdTime:number, dtime:number)
|
|
||||||
function Control.subcribeOnHold(callbackFunc)
|
|
||||||
Events.subscribe('control.on_hold', callbackFunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- control.on_wield_change
|
|
||||||
|
|
||||||
---@param callbackFunc fun(player:Player, player_wield_index:number, player_last_wield_index:number)
|
|
||||||
function Control.subcribeOnWieldChange(callbackFunc)
|
|
||||||
Events.subscribe('control.on_wield_change', callbackFunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- --- Call events ---
|
|
||||||
|
|
||||||
local ControlPressKeys = {
|
|
||||||
'up', 'down', 'left', 'right', 'jump', 'aux1', 'sneak', 'dig', 'place', 'zoom'
|
|
||||||
}
|
|
||||||
|
|
||||||
local ControlMovementKeys = {
|
|
||||||
'movement_x', 'movement_y'
|
|
||||||
}
|
|
||||||
|
|
||||||
local playersLastControl = {}
|
|
||||||
local playersControlTimer = {}
|
|
||||||
|
|
||||||
core.register_on_joinplayer(function(player, last_login)
|
|
||||||
local playerName = player:get_player_name()
|
|
||||||
if playerName == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local nowControl = player:get_player_control()
|
|
||||||
if nowControl == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local controlTimer = {}
|
|
||||||
for _, key in ipairs(ControlPressKeys) do
|
|
||||||
controlTimer[key] = 0.0
|
|
||||||
end
|
|
||||||
|
|
||||||
playersLastControl[playerName] = nowControl
|
|
||||||
playersControlTimer[playerName] = controlTimer
|
|
||||||
end)
|
|
||||||
|
|
||||||
core.register_on_leaveplayer(function(player, timed_out)
|
|
||||||
local playerName = player:get_player_name()
|
|
||||||
if playerName == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
playersLastControl[playerName] = nil
|
|
||||||
playersControlTimer[playerName] = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
Smc.registerGlobalStepForEachPlayer(0, function(deltaTime, player)
|
|
||||||
if player == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local playerName = player:get_player_name()
|
|
||||||
if playerName == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local lastControl = playersLastControl[playerName]
|
|
||||||
if lastControl == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local controlTimer = playersControlTimer[playerName]
|
|
||||||
if controlTimer == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local nowControl = player:get_player_control()
|
|
||||||
if nowControl == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, key in ipairs(ControlPressKeys) do
|
|
||||||
local lastPressed = lastControl[key]
|
|
||||||
local nowPressed = nowControl[key]
|
|
||||||
|
|
||||||
-- on_press
|
|
||||||
if not lastPressed and nowPressed then
|
|
||||||
Events.call('control.on_press', key)
|
|
||||||
|
|
||||||
controlTimer[key] = 0
|
|
||||||
|
|
||||||
-- on_release
|
|
||||||
elseif lastPressed and not nowPressed then
|
|
||||||
Events.call('control.on_release', key, controlTimer[key])
|
|
||||||
|
|
||||||
controlTimer[key] = 0
|
|
||||||
|
|
||||||
-- on_hold
|
|
||||||
elseif lastPressed and nowPressed then
|
|
||||||
Events.call('control.on_hold', key, controlTimer[key], deltaTime)
|
|
||||||
|
|
||||||
controlTimer[key] = controlTimer[key] + deltaTime
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--TODO: add player movement callbacks
|
|
||||||
|
|
||||||
--TODO: add mouse movement callbacks on dir
|
|
||||||
|
|
||||||
playersLastControl[playerName] = nowControl
|
|
||||||
playersControlTimer[playerName] = controlTimer
|
|
||||||
end)
|
|
||||||
|
|
||||||
return Control
|
|
||||||
4
mods/CORE/Controls/init.lua
Normal file
4
mods/CORE/Controls/init.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
local modInfo = Mod.getInfo('smc__core__controls')
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
return require('Controls')
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
name = smc__core__control
|
name = smc__core__controls
|
||||||
depends = smc__system__system_loader
|
depends = smc__system__system_loader
|
||||||
87
mods/CORE/Controls/src/Controls.lua
Normal file
87
mods/CORE/Controls/src/Controls.lua
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
local ControlsEvents = Smc.requireEvents('ControlsEvents') --[[@as Events.ControlsEvents]]
|
||||||
|
|
||||||
|
---@class Controls
|
||||||
|
local Controls = {}
|
||||||
|
|
||||||
|
---@alias Controls.PressKey 'up'|'down'|'left'|'right'|'jump'|'aux1'|'sneak'|'dig'|'place'|'zoom'
|
||||||
|
---@alias Controls.MovementKey 'movement_x'|'movement_y'
|
||||||
|
|
||||||
|
---@alias Controls.PlayerControls table<Player.controls_key, boolean>
|
||||||
|
---@alias Controls.PlayerControlsTimer table<Player.controls_key, number>
|
||||||
|
|
||||||
|
local ControlsPressKeys = { 'up', 'down', 'left', 'right', 'jump', 'aux1', 'sneak', 'dig', 'place', 'zoom' }
|
||||||
|
local ControlsMovementKeys = { 'movement_x', 'movement_y' }
|
||||||
|
|
||||||
|
---@type table<string, Controls.PlayerControls>
|
||||||
|
local playersLastControls = {}
|
||||||
|
---@type table<string, Controls.PlayerControlsTimer>
|
||||||
|
local playersControlsTimer = {}
|
||||||
|
---@type table<string, integer>
|
||||||
|
local playersWieldIndices = {}
|
||||||
|
|
||||||
|
core.register_on_joinplayer(function(player, last_login)
|
||||||
|
local playerName = player:get_player_name()
|
||||||
|
local nowControls = player:get_player_control()
|
||||||
|
|
||||||
|
local controlsTimer = {}
|
||||||
|
for _, key in ipairs(ControlsPressKeys) do
|
||||||
|
controlsTimer[key] = 0.0
|
||||||
|
end
|
||||||
|
|
||||||
|
playersLastControls[playerName] = nowControls
|
||||||
|
playersControlsTimer[playerName] = controlsTimer
|
||||||
|
playersWieldIndices[playerName] = player:get_wield_index()
|
||||||
|
end)
|
||||||
|
|
||||||
|
core.register_on_leaveplayer(function(player, timed_out)
|
||||||
|
local playerName = player:get_player_name()
|
||||||
|
|
||||||
|
playersLastControls[playerName] = nil
|
||||||
|
playersControlsTimer[playerName] = nil
|
||||||
|
playersWieldIndices[playerName] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
Smc.registerGlobalStepForEachPlayer(0, function(deltaTime, player)
|
||||||
|
local playerName = player:get_player_name()
|
||||||
|
|
||||||
|
local lastControls = playersLastControls[playerName]
|
||||||
|
local controlsTimer = playersControlsTimer[playerName]
|
||||||
|
local currentControls = player:get_player_control()
|
||||||
|
|
||||||
|
local lastWieldIndex = playersWieldIndices[playerName]
|
||||||
|
local currentWieldIndex = player:get_wield_index()
|
||||||
|
|
||||||
|
-- Press keys
|
||||||
|
for _, key in ipairs(ControlsPressKeys) do
|
||||||
|
local lastPressed = lastControls[key]
|
||||||
|
local currentPressed = currentControls[key]
|
||||||
|
|
||||||
|
-- on_press
|
||||||
|
if not lastPressed and currentPressed then
|
||||||
|
ControlsEvents:callOnPress(player, key)
|
||||||
|
controlsTimer[key] = 0
|
||||||
|
-- on_release
|
||||||
|
elseif lastPressed and not currentPressed then
|
||||||
|
ControlsEvents:callOnRelease(player, key, controlsTimer[key])
|
||||||
|
controlsTimer[key] = 0
|
||||||
|
-- on_hold
|
||||||
|
elseif lastPressed and currentPressed then
|
||||||
|
ControlsEvents:callOnHold(player, key, controlsTimer[key], deltaTime)
|
||||||
|
controlsTimer[key] = controlsTimer[key] + deltaTime
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--TODO: add player movement callbacks
|
||||||
|
|
||||||
|
-- Wield change
|
||||||
|
if lastWieldIndex ~= currentWieldIndex then
|
||||||
|
ControlsEvents:callOnWieldChange(player, currentWieldIndex, lastWieldIndex)
|
||||||
|
end
|
||||||
|
|
||||||
|
--TODO: add mouse movement callbacks on dir
|
||||||
|
|
||||||
|
playersLastControls[playerName] = currentControls
|
||||||
|
playersControlsTimer[playerName] = controlsTimer
|
||||||
|
end)
|
||||||
|
|
||||||
|
return Controls
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local tableJoin = table.join
|
||||||
|
|
||||||
local modInfo = Mod.getInfo('smc__core__craft_system')
|
local modInfo = Mod.getInfo('smc__core__craft_system')
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
|
|
||||||
@@ -5,24 +7,227 @@ local require = modInfo.require
|
|||||||
local PrimitiveCraftHandler = require('CraftSystem.PrimitiveCraftHandler')
|
local PrimitiveCraftHandler = require('CraftSystem.PrimitiveCraftHandler')
|
||||||
---@type CraftSystem.ImmersiveCraftHandler
|
---@type CraftSystem.ImmersiveCraftHandler
|
||||||
local ImmersiveCraftHandler= require('CraftSystem.ImmersiveCraftHandler')
|
local ImmersiveCraftHandler= require('CraftSystem.ImmersiveCraftHandler')
|
||||||
|
---@type CraftSystem.ProcessingCraftHandler
|
||||||
|
local ProcessingCraftHandler= require('CraftSystem.ProcessingCraftHandler')
|
||||||
|
|
||||||
---@alias CraftSystem.CraftGroup string
|
---@alias CraftSystem.CraftGroup string
|
||||||
---@alias CraftSystem.CraftRecipe string[]
|
---@alias CraftSystem.CraftRecipe ItemStackString[]
|
||||||
---@alias CraftSystem.CraftType 'primitive'|'immersive'
|
|
||||||
|
|
||||||
---@class CraftSystem
|
---@class CraftSystem
|
||||||
local CraftSystem = {}
|
---@field PrimitiveCraftHandlers table<string, CraftSystem.PrimitiveCraftHandler>
|
||||||
|
---@field ImmersiveCraftHandlers table<string, CraftSystem.ImmersiveCraftHandler>
|
||||||
|
---@field ProcessingCraftHandlers table<string, CraftSystem.ProcessingCraftHandler>
|
||||||
|
local CraftSystem = {
|
||||||
|
PrimitiveCraftHandlers = {},
|
||||||
|
ImmersiveCraftHandlers = {},
|
||||||
|
ProcessingCraftHandlers = {}
|
||||||
|
}
|
||||||
|
|
||||||
---@param craftName string
|
|
||||||
---@param def CraftSystem.PrimitiveCraftDef
|
--- Craft Types ---
|
||||||
function CraftSystem.registerPrimitiveCraft(craftName, def)
|
|
||||||
PrimitiveCraftHandler:registerCraft(craftName, def)
|
---@alias CraftSystem.BaseCraftType 'primitive'|'immersive'|'processing'
|
||||||
|
---@alias CraftSystem.PrimitiveCraftType 'inside_player_inventory'
|
||||||
|
---@alias CraftSystem.ImmersiveCraftType 'workbench' -- DEBUG
|
||||||
|
---@alias CraftSystem.ProcessingCraftType 'test' -- DEBUG
|
||||||
|
---@alias CraftSystem.CraftType CraftSystem.PrimitiveCraftType|CraftSystem.ImmersiveCraftType|CraftSystem.ProcessingCraftType
|
||||||
|
|
||||||
|
---@param type CraftSystem.PrimitiveCraftType
|
||||||
|
---@param def CraftSystem.PrimitiveCraftHandlerDef
|
||||||
|
local function registerPrimitiveCraftType(type, def)
|
||||||
|
assert(CraftSystem.PrimitiveCraftHandlers[type] == nil, ('A primitive craft type `%s` already exists.'):format(type))
|
||||||
|
|
||||||
|
local handler = PrimitiveCraftHandler:new('primitive', type, def)
|
||||||
|
CraftSystem.PrimitiveCraftHandlers[type] = handler
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.ImmersiveCraftType
|
||||||
|
---@param def CraftSystem.ImmersiveCraftHandlerDef
|
||||||
|
local function registerImmersiveCraftType(type, def)
|
||||||
|
assert(CraftSystem.ImmersiveCraftHandlers[type] == nil, ('A immersive craft type `%s` already exists.'):format(type))
|
||||||
|
|
||||||
|
local handler = ImmersiveCraftHandler:new('immersive', type, def)
|
||||||
|
CraftSystem.ImmersiveCraftHandlers[type] = handler
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.ProcessingCraftType
|
||||||
|
---@param def CraftSystem.ProcessingCraftHandlerDef
|
||||||
|
local function registerProcessingCraftType(type, def)
|
||||||
|
assert(CraftSystem.ProcessingCraftHandlers[type] == nil, ('A processing craft type `%s` already exists.'):format(type))
|
||||||
|
|
||||||
|
local handler = ProcessingCraftHandler:new('processing', type, def)
|
||||||
|
CraftSystem.ProcessingCraftHandlers[type] = handler
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.PrimitiveCraftType
|
||||||
|
---@return CraftSystem.PrimitiveCraftHandler
|
||||||
|
function CraftSystem:getPrimitiveCraftHandler(type)
|
||||||
|
local handler = self.PrimitiveCraftHandlers[type]
|
||||||
|
assert(handler ~= nil)
|
||||||
|
|
||||||
|
return handler
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.ImmersiveCraftType
|
||||||
|
---@return CraftSystem.ImmersiveCraftHandler
|
||||||
|
function CraftSystem:getImmersiveCraftHandler(type)
|
||||||
|
local handler = self.ImmersiveCraftHandlers[type]
|
||||||
|
assert(handler ~= nil)
|
||||||
|
|
||||||
|
return handler
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.ProcessingCraftType
|
||||||
|
---@return CraftSystem.ProcessingCraftHandler
|
||||||
|
function CraftSystem:getProcessingCraftHandler(type)
|
||||||
|
local handler = self.ProcessingCraftHandlers[type]
|
||||||
|
assert(handler ~= nil)
|
||||||
|
|
||||||
|
return handler
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Registration of craft types:
|
||||||
|
registerPrimitiveCraftType('inside_player_inventory', {})
|
||||||
|
-- Debug:
|
||||||
|
registerImmersiveCraftType('workbench', {})
|
||||||
|
registerProcessingCraftType('test', {})
|
||||||
|
|
||||||
|
|
||||||
|
--- Registration methods ---
|
||||||
|
|
||||||
|
---@param type CraftSystem.PrimitiveCraftType
|
||||||
|
---@param craftName string
|
||||||
|
---@param def CraftSystem.PrimitiveCraftDef
|
||||||
|
function CraftSystem:registerPrimitiveCraft(type, craftName, def)
|
||||||
|
local handler = self:getPrimitiveCraftHandler(type)
|
||||||
|
|
||||||
|
handler:registerCraft(craftName, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.ImmersiveCraftType
|
||||||
---@param craftName string
|
---@param craftName string
|
||||||
---@param def CraftSystem.ImmersiveCraftDef
|
---@param def CraftSystem.ImmersiveCraftDef
|
||||||
function CraftSystem.registerImmersiveCraft(craftName, def)
|
function CraftSystem:registerImmersiveCraft(type, craftName, def)
|
||||||
ImmersiveCraftHandler:registerCraft(craftName, def)
|
local handler = self:getImmersiveCraftHandler(type)
|
||||||
|
|
||||||
|
handler:registerCraft(craftName, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param type CraftSystem.ProcessingCraftType
|
||||||
|
---@param craftName string
|
||||||
|
---@param def CraftSystem.ProcessingCraftDef
|
||||||
|
function CraftSystem:registerProcessingCraft(type, craftName, def)
|
||||||
|
local handler = self:getProcessingCraftHandler(type)
|
||||||
|
|
||||||
|
handler:registerCraft(craftName, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Methods for performing crafting ---
|
||||||
|
|
||||||
|
---@param craft CraftSystem.BaseCraft
|
||||||
|
---@param recipeIndex integer
|
||||||
|
---@param count integer
|
||||||
|
---@return ItemStack[] materialStacks A table containing the items required for crafting.
|
||||||
|
---@return table<string, integer> materialGroups A table containing the item groups required for crafting.
|
||||||
|
local function getMaterials(craft, recipeIndex, count)
|
||||||
|
local materialStacks = {}
|
||||||
|
local materialGroups = {}
|
||||||
|
|
||||||
|
for _, itemName in ipairs(craft:getRecipe(recipeIndex)) do
|
||||||
|
local group = itemName:match('group:(%S+)')
|
||||||
|
local materialCount = itemName:match('group:%S+ (%S+)') or 1
|
||||||
|
|
||||||
|
if group == nil then
|
||||||
|
local item = ItemStack(itemName)
|
||||||
|
item:set_count(item:get_count() * count)
|
||||||
|
|
||||||
|
table.insert(materialStacks, item)
|
||||||
|
else
|
||||||
|
materialGroups[group] = (tonumber(materialCount) or 1) * count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return materialStacks, materialGroups
|
||||||
|
end
|
||||||
|
|
||||||
|
---Check if the player has the required items.
|
||||||
|
---@param materialStacks ItemStack[]
|
||||||
|
---@param inventory InvRef
|
||||||
|
---@return boolean
|
||||||
|
local function checkMaterialStacks(materialStacks, inventory)
|
||||||
|
for _, item in ipairs(materialStacks) do
|
||||||
|
if not inventory:contains_item('main', item) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
---Check whether the player has the required number of items with the required group for crafting.
|
||||||
|
---@param materialGroups table<string, integer>
|
||||||
|
---@param inventory InvRef
|
||||||
|
---@return boolean
|
||||||
|
---@return ItemStack[] materialStacks A list of item stacks that match the required material groups.
|
||||||
|
local function checkMaterialGroups(materialGroups, inventory)
|
||||||
|
local materialStacks = {}
|
||||||
|
|
||||||
|
local mainList = inventory:get_list('main')
|
||||||
|
for group, count in pairs(materialGroups) do
|
||||||
|
for _, item in ipairs(mainList) do
|
||||||
|
if core.get_item_group(item:get_name(), group) > 0 then
|
||||||
|
local itemCount = item:get_count()
|
||||||
|
if count > itemCount then
|
||||||
|
count = count - itemCount
|
||||||
|
table.insert(materialStacks, item)
|
||||||
|
else
|
||||||
|
item:set_count(count)
|
||||||
|
table.insert(materialStacks, item)
|
||||||
|
count = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if count > 0 then
|
||||||
|
return false, {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true, materialStacks
|
||||||
|
end
|
||||||
|
|
||||||
|
---Checks whether the player can perform crafting (whether he has the required materials in his inventory).
|
||||||
|
---@param player Player
|
||||||
|
---@param craft CraftSystem.BaseCraft
|
||||||
|
---@param recipeIndex integer
|
||||||
|
---@param count integer
|
||||||
|
---@return boolean check true if craft can be produced
|
||||||
|
---@return ItemStack[] materialStacks list of itemStacks for crafting
|
||||||
|
function CraftSystem:checkPossiblePlayerInventoryCrafting(player, craft, recipeIndex, count)
|
||||||
|
local inventory = player:get_inventory()
|
||||||
|
|
||||||
|
local OutputStack = ItemStack(craft.output)
|
||||||
|
OutputStack:set_count(OutputStack:get_count() * count)
|
||||||
|
|
||||||
|
local materialStacks, materialGroups = getMaterials(craft, recipeIndex, count)
|
||||||
|
|
||||||
|
local isHaveStacks = checkMaterialStacks(materialStacks, inventory)
|
||||||
|
if not isHaveStacks then
|
||||||
|
core.chat_send_player(player:get_player_name(), 'Not enough materials for crafting!')
|
||||||
|
return false, {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local isHaveGroups, materialGroupStacks = checkMaterialGroups(materialGroups, inventory)
|
||||||
|
if not isHaveGroups then
|
||||||
|
core.chat_send_player(player:get_player_name(), 'Not enough materials for crafting!')
|
||||||
|
return false, {}
|
||||||
|
end
|
||||||
|
|
||||||
|
materialStacks = tableJoin(materialStacks, materialGroupStacks)
|
||||||
|
|
||||||
|
|
||||||
|
return true, materialStacks
|
||||||
end
|
end
|
||||||
|
|
||||||
return CraftSystem
|
return CraftSystem
|
||||||
|
|||||||
@@ -1,13 +1,156 @@
|
|||||||
---Abstract class for craft.
|
---A text indicator of the presence or absence
|
||||||
---@class CraftSystem.BaseCraft
|
---of a material in the player's inventory.
|
||||||
---@field name string
|
local CHECK = {YES = '[x]', NO = '[ ]', EMPTY = '-'}
|
||||||
---@field group CraftSystem.CraftGroup
|
|
||||||
local BaseCraft = {}
|
---@class CraftSystem.BaseCraft : Class
|
||||||
|
---@field name string
|
||||||
|
---@field recipe ItemStackString[]
|
||||||
|
---@field altRecipes CraftSystem.CraftRecipe[]
|
||||||
|
---@field output ItemStackString
|
||||||
|
---@field group CraftSystem.CraftGroup
|
||||||
|
local BaseCraft = Class:extend({})
|
||||||
|
|
||||||
---Definition table for the `CraftSystem.BaseCraft`.
|
---Definition table for the `CraftSystem.BaseCraft`.
|
||||||
---
|
|
||||||
---**Only for EmmyLua.**
|
|
||||||
---@class CraftSystem.BaseCraftDef
|
---@class CraftSystem.BaseCraftDef
|
||||||
---@field group CraftSystem.CraftGroup
|
---@field recipe ItemStackString[]
|
||||||
|
---@field altRecipes CraftSystem.CraftRecipe[]?
|
||||||
|
---@field output ItemStackString
|
||||||
|
---@field group CraftSystem.CraftGroup?
|
||||||
|
|
||||||
|
---@param name string
|
||||||
|
---@param def CraftSystem.BaseCraftDef
|
||||||
|
---@return CraftSystem.BaseCraft
|
||||||
|
function BaseCraft:new(name, def)
|
||||||
|
---@type CraftSystem.BaseCraft
|
||||||
|
local instance = self:getInstance({})
|
||||||
|
instance.name = name
|
||||||
|
instance.recipe = def.recipe
|
||||||
|
instance.altRecipes = def.altRecipes or {}
|
||||||
|
instance.output = def.output
|
||||||
|
instance.group = def.group
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param material ItemStack
|
||||||
|
---@param count number
|
||||||
|
---@param list ItemStack[]?
|
||||||
|
---@return string
|
||||||
|
local function getCheckMaterialItem(material, count, list)
|
||||||
|
if list == nil then
|
||||||
|
return CHECK.EMPTY
|
||||||
|
end
|
||||||
|
|
||||||
|
local materialName = material:get_name()
|
||||||
|
|
||||||
|
for _, item in ipairs(list) do
|
||||||
|
if materialName == item:get_name() then
|
||||||
|
local itemCount = item:get_count()
|
||||||
|
if count > itemCount then
|
||||||
|
count = count - itemCount
|
||||||
|
else
|
||||||
|
return CHECK.YES
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return CHECK.NO
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param material string
|
||||||
|
---@param count number
|
||||||
|
---@param list ItemStack[]?
|
||||||
|
---@return string
|
||||||
|
local function getCheckMaterialGroup(material, count, list)
|
||||||
|
if list == nil then
|
||||||
|
return CHECK.EMPTY
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, item in ipairs(list) do
|
||||||
|
if core.get_item_group(item:get_name(), material) > 0 then
|
||||||
|
local itemCount = item:get_count()
|
||||||
|
if count > itemCount then
|
||||||
|
count = count - itemCount
|
||||||
|
else
|
||||||
|
return CHECK.YES
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return CHECK.NO
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns the crafting recipe corresponding to the index.
|
||||||
|
---@param index integer Recipe number. If `0` is specified,
|
||||||
|
--- the primary craft (`craft.recipe`) will be used;
|
||||||
|
--- if `1` or greater, the alternative craft
|
||||||
|
--- corresponding to the index will be used (`craft.altRecipes`).
|
||||||
|
---@return CraftSystem.CraftRecipe
|
||||||
|
function BaseCraft:getRecipe(index)
|
||||||
|
local recipe
|
||||||
|
if index == 0 or self.altRecipes == nil then
|
||||||
|
recipe = self.recipe
|
||||||
|
else
|
||||||
|
if index > #self.altRecipes then
|
||||||
|
recipe = self.altRecipes[#self.altRecipes]
|
||||||
|
else
|
||||||
|
recipe = self.altRecipes[index]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert(recipe ~= nil)
|
||||||
|
|
||||||
|
return recipe
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param recipeIndex integer?
|
||||||
|
---@param mainList ItemStack[]?
|
||||||
|
---@return string
|
||||||
|
function BaseCraft:recipeToString(recipeIndex, mainList)
|
||||||
|
local recipe
|
||||||
|
if recipeIndex == nil or recipeIndex == 0 or self.altRecipes == nil then
|
||||||
|
recipe = self.recipe
|
||||||
|
else
|
||||||
|
if recipeIndex > #self.altRecipes then
|
||||||
|
recipe = self.altRecipes[#self.altRecipes]
|
||||||
|
else
|
||||||
|
recipe = self.altRecipes[recipeIndex]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert(recipe ~= nil)
|
||||||
|
|
||||||
|
local recipeDesc = ''
|
||||||
|
for _, itemName in ipairs(recipe) do
|
||||||
|
local group, count = itemName:match('group:(%S+)'), itemName:match('group:%S+ (%S+)') or 1
|
||||||
|
|
||||||
|
if group == nil then
|
||||||
|
local recipeItem = ItemStack(itemName)
|
||||||
|
recipeDesc = recipeDesc..('%s %s x%s\n'):format(
|
||||||
|
getCheckMaterialItem(recipeItem, recipeItem:get_count(), mainList),
|
||||||
|
core.strip_colors(Smc.getItemDefinition(recipeItem).settings._title),
|
||||||
|
recipeItem:get_count())
|
||||||
|
else
|
||||||
|
recipeDesc = recipeDesc..('%s any item from the group %s x%s\n'):format(
|
||||||
|
getCheckMaterialGroup(group, count, mainList),
|
||||||
|
group,
|
||||||
|
count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return recipeDesc
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param recipeIndex integer?
|
||||||
|
---@param mainList ItemStack[]?
|
||||||
|
---@return string
|
||||||
|
function BaseCraft:toString(recipeIndex, mainList)
|
||||||
|
local outputItem = ItemStack(self.output)
|
||||||
|
local outputItemSettings = Smc.getItemDefinition(outputItem).settings
|
||||||
|
|
||||||
|
local craftDesc = ('%s\n\nNeeded:\n%s'):format(
|
||||||
|
outputItemSettings._title,
|
||||||
|
self:recipeToString(recipeIndex, mainList))
|
||||||
|
|
||||||
|
return craftDesc
|
||||||
|
end
|
||||||
|
|
||||||
return BaseCraft
|
return BaseCraft
|
||||||
|
|||||||
@@ -1,22 +1,52 @@
|
|||||||
|
local tableInsert = table.insert
|
||||||
|
local stringMatch = string.match
|
||||||
|
|
||||||
|
local PLAYERS_KNOW_ALL_RECIPES = true
|
||||||
|
|
||||||
---Abstract class for handling crafting.
|
---Abstract class for handling crafting.
|
||||||
---@class CraftSystem.BaseCraftHandler
|
---@class CraftSystem.BaseCraftHandler : Class
|
||||||
|
---@field baseType CraftSystem.BaseCraftType
|
||||||
|
---@field type CraftSystem.CraftType
|
||||||
|
---@field defaultCraftDef CraftSystem.BaseCraftDef
|
||||||
|
---
|
||||||
---@field craftsByName table<string, CraftSystem.BaseCraft>
|
---@field craftsByName table<string, CraftSystem.BaseCraft>
|
||||||
---@field craftsByGroup table<CraftSystem.CraftGroup, CraftSystem.BaseCraft[]>
|
---@field craftsByGroup table<CraftSystem.CraftGroup, CraftSystem.BaseCraft[]>
|
||||||
---@field craftsList CraftSystem.BaseCraft[]
|
---@field craftsList CraftSystem.BaseCraft[]
|
||||||
---@field learnedCrafts table<string, table<string, CraftSystem.BaseCraft>>
|
---@field groupedCrafts (CraftSystem.BaseCraft[]|CraftSystem.BaseCraft)[]
|
||||||
local BaseCraftHandler = {
|
---@field learnedCrafts table<string, CraftSystem.BaseCraft[]>
|
||||||
|
---@field learnedGroupedCrafts table<string, (CraftSystem.BaseCraft[]|CraftSystem.BaseCraft)[]>
|
||||||
|
local BaseCraftHandler = Class:extend({
|
||||||
craftsByName = {},
|
craftsByName = {},
|
||||||
craftsByGroup = {},
|
craftsByGroup = {},
|
||||||
craftsList = {},
|
craftsList = {},
|
||||||
|
groupedCrafts = {},
|
||||||
learnedCrafts = {},
|
learnedCrafts = {},
|
||||||
}
|
learnedGroupedCrafts = {},
|
||||||
|
})
|
||||||
|
|
||||||
|
---@class CraftSystem.BaseCraftHandlerDef
|
||||||
|
---@field defaultCraftDef CraftSystem.BaseCraftDef?
|
||||||
|
|
||||||
|
---@param baseType CraftSystem.BaseCraftType
|
||||||
|
---@param type CraftSystem.CraftType
|
||||||
|
---@param def CraftSystem.BaseCraftHandlerDef
|
||||||
|
---@return CraftSystem.BaseCraftHandler
|
||||||
|
function BaseCraftHandler:new(baseType, type, def)
|
||||||
|
---@type CraftSystem.BaseCraftHandler
|
||||||
|
local instance = self:getInstance({})
|
||||||
|
instance.baseType = baseType
|
||||||
|
instance.type = type
|
||||||
|
instance.defaultCraftDef = def.defaultCraftDef or {}
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
---@param craftName string
|
---@param craftName string
|
||||||
---@return CraftSystem.BaseCraft
|
---@return CraftSystem.BaseCraft
|
||||||
function BaseCraftHandler:getCraftByName(craftName)
|
function BaseCraftHandler:getCraftByName(craftName)
|
||||||
local craft = self.craftsByName[craftName]
|
local craft = self.craftsByName[craftName]
|
||||||
|
|
||||||
assert(craft ~= nil, ('There is no primitive craft named `%s`.'):format(
|
assert(craft ~= nil, ('A craft `%s` not exists.'):format(
|
||||||
craftName))
|
craftName))
|
||||||
|
|
||||||
return craft
|
return craft
|
||||||
@@ -27,21 +57,70 @@ end
|
|||||||
function BaseCraftHandler:getCraftsByGroup(craftGroup)
|
function BaseCraftHandler:getCraftsByGroup(craftGroup)
|
||||||
local crafts = self.craftsByGroup[craftGroup]
|
local crafts = self.craftsByGroup[craftGroup]
|
||||||
|
|
||||||
assert(crafts ~= nil, ('There are no primitive crafts with `%s` group'):format(
|
assert(crafts ~= nil, ('A craft with group `%s` not exists.'):format(
|
||||||
craftGroup))
|
craftGroup))
|
||||||
|
|
||||||
return crafts
|
return crafts
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param playerName string
|
---@param playerName string
|
||||||
---@return table<string, CraftSystem.BaseCraft>
|
---@return (CraftSystem.BaseCraft[]|CraftSystem.BaseCraft)[]
|
||||||
function BaseCraftHandler:getLearnedCrafts(playerName)
|
function BaseCraftHandler:getLearnedCrafts(playerName)
|
||||||
local crafts = self.learnedCrafts[playerName]
|
if PLAYERS_KNOW_ALL_RECIPES then
|
||||||
|
return self.groupedCrafts
|
||||||
|
end
|
||||||
|
|
||||||
assert(crafts ~= nil, ('There is no primitive crafting data for a player named `%s`.'):format(
|
local crafts = self.learnedGroupedCrafts[playerName]
|
||||||
playerName))
|
|
||||||
|
if crafts == nil then
|
||||||
|
crafts = {}
|
||||||
|
self.learnedGroupedCrafts[playerName] = crafts
|
||||||
|
end
|
||||||
|
|
||||||
return crafts
|
return crafts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param crafts CraftSystem.BaseCraft[]
|
||||||
|
---@param pattern string
|
||||||
|
---@return CraftSystem.BaseCraft[]
|
||||||
|
local function getMathedCrafts(crafts, pattern)
|
||||||
|
local pattern = string_utf8.lower(pattern)
|
||||||
|
local matchedCrafts = {}
|
||||||
|
|
||||||
|
for _, craft in ipairs(crafts) do
|
||||||
|
local outputItem = ItemStack(craft.output)
|
||||||
|
local itemSettings = Smc.getItemDefinition(outputItem).settings
|
||||||
|
local ruName = string_utf8.lower(core.get_translated_string('ru', itemSettings._title))
|
||||||
|
local enName = string_utf8.lower(core.get_translated_string('en', itemSettings._title))
|
||||||
|
|
||||||
|
if stringMatch(outputItem:get_name(), pattern) or
|
||||||
|
stringMatch(ruName, pattern) or
|
||||||
|
stringMatch(enName, pattern) then
|
||||||
|
tableInsert(matchedCrafts, craft)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return matchedCrafts
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param playerName string
|
||||||
|
---@param pattern string
|
||||||
|
---@return CraftSystem.BaseCraft[]
|
||||||
|
function BaseCraftHandler:getLearnedCraftsMatch(playerName, pattern)
|
||||||
|
if PLAYERS_KNOW_ALL_RECIPES then
|
||||||
|
return getMathedCrafts(self.craftsList, pattern)
|
||||||
|
end
|
||||||
|
|
||||||
|
local crafts = self.learnedCrafts[playerName]
|
||||||
|
|
||||||
|
if crafts == nil then
|
||||||
|
crafts = {}
|
||||||
|
self.learnedCrafts[playerName] = crafts
|
||||||
|
end
|
||||||
|
|
||||||
|
return crafts
|
||||||
|
end
|
||||||
|
|
||||||
|
--TODO: сохранять выученные крафты игроков в сторадже
|
||||||
|
|
||||||
return BaseCraftHandler
|
return BaseCraftHandler
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
local getInstance, extend = Class.getInstance, Class.extend
|
local v = vector.new
|
||||||
|
local assert, ipairs, tostring = assert, ipairs, tostring
|
||||||
|
local coreChatSendPlayer, coreItemDrop = core.chat_send_player, core.item_drop
|
||||||
|
|
||||||
local modInfo = Mod.getInfo('smc__core__craft_system')
|
local require = Mod.getInfo('smc__core__craft_system').require
|
||||||
local require = modInfo.require
|
|
||||||
|
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
|
||||||
|
|
||||||
---@type CraftSystem.BaseCraft
|
---@type CraftSystem.BaseCraft
|
||||||
local BaseCraft = require('CraftSystem.BaseCraft')
|
local BaseCraft = require('CraftSystem.BaseCraft')
|
||||||
@@ -18,78 +21,54 @@ local stageTypes = {
|
|||||||
---Immersive crafting aimed at a more logical process of crafting items.
|
---Immersive crafting aimed at a more logical process of crafting items.
|
||||||
---@class CraftSystem.ImmersiveCraft : CraftSystem.BaseCraft
|
---@class CraftSystem.ImmersiveCraft : CraftSystem.BaseCraft
|
||||||
---@field startStageName string
|
---@field startStageName string
|
||||||
---@field triggerItem string
|
|
||||||
---@field output ItemStackString
|
|
||||||
---@field stagesByName table<string, CraftSystem.ImmersiveCraftStage>
|
---@field stagesByName table<string, CraftSystem.ImmersiveCraftStage>
|
||||||
local ImmersiveCraft = extend(BaseCraft, {})
|
local ImmersiveCraft = BaseCraft:extend({})
|
||||||
|
|
||||||
---Definition table for the `CraftSystem.ImmersiveCraft`.
|
---Definition table for the `CraftSystem.ImmersiveCraft`.
|
||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class CraftSystem.ImmersiveCraftDef : CraftSystem.BaseCraftDef
|
---@class CraftSystem.ImmersiveCraftDef : CraftSystem.BaseCraftDef
|
||||||
---@field startStageName string
|
---@field startStageName string
|
||||||
---@field triggerItem string
|
|
||||||
---@field output string
|
|
||||||
---@field stages CraftSystem.ImmersiveCraftStageDef[]
|
---@field stages CraftSystem.ImmersiveCraftStageDef[]
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param def CraftSystem.ImmersiveCraftDef
|
---@param def CraftSystem.ImmersiveCraftDef
|
||||||
---@return CraftSystem.ImmersiveCraft
|
---@return CraftSystem.ImmersiveCraft
|
||||||
function ImmersiveCraft:new(name, def)
|
function ImmersiveCraft:new(name, def)
|
||||||
-- We create a table of crafting stages that the player needs to complete.
|
|
||||||
---@type table<string, CraftSystem.ImmersiveCraftStage>
|
---@type table<string, CraftSystem.ImmersiveCraftStage>
|
||||||
local stagesByName = {}
|
local stagesByName = {}
|
||||||
|
|
||||||
for _, stageDef in ipairs(def.stages) do
|
for _, stageDef in ipairs(def.stages) do
|
||||||
-- We get the stage class based on its type.
|
|
||||||
local StageClass = stageTypes[stageDef.type]
|
local StageClass = stageTypes[stageDef.type]
|
||||||
|
|
||||||
-- Create a stage and add the craft name to the instance.
|
|
||||||
stageDef.craftName = name
|
stageDef.craftName = name
|
||||||
|
|
||||||
|
---@cast stageDef CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
local stage = StageClass:new(stageDef)
|
local stage = StageClass:new(stageDef)
|
||||||
|
|
||||||
-- We add an instance of the stage to the table by name.
|
|
||||||
stagesByName[stageDef.name] = stage
|
stagesByName[stageDef.name] = stage
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type CraftSystem.ImmersiveCraft
|
---@type CraftSystem.ImmersiveCraft
|
||||||
local instance = getInstance(self, {})
|
local instance = self:getInstance(BaseCraft:new(name, def))
|
||||||
instance.name = name
|
|
||||||
instance.group = def.group
|
|
||||||
instance.startStageName = def.startStageName
|
instance.startStageName = def.startStageName
|
||||||
instance.triggerItem = def.triggerItem
|
|
||||||
instance.output = def.output
|
|
||||||
instance.stagesByName = stagesByName
|
instance.stagesByName = stagesByName
|
||||||
|
|
||||||
-- Subscribe to an event that will determine that the player has completed the crafting stage.
|
-- Subscribe to an event that will determine that the player has completed the crafting stage.
|
||||||
Events.subscribe('craft_system:next_immersive_stage:'..name,
|
ImmersiveCraftEvents:subscribeOnNextStage(name, function(stage, pos, player)
|
||||||
---@param eventName string
|
|
||||||
---@param stage CraftSystem.ImmersiveCraftStage
|
|
||||||
---@param pos MapPosition
|
|
||||||
---@param Player Player
|
|
||||||
function(eventName, stage, pos, Player)
|
|
||||||
-- From the current stage (which has been completed) we get the name of the next one.
|
|
||||||
local nextStageName = stage.nextStage
|
local nextStageName = stage.nextStage
|
||||||
|
|
||||||
-- If there is no next stage...
|
|
||||||
if nextStageName == nil then
|
if nextStageName == nil then
|
||||||
-- ...we are finishing the craft.
|
instance:endCraft(pos, player)
|
||||||
instance:endCraft(pos, Player)
|
|
||||||
else
|
else
|
||||||
-- ...else we start the next stage.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
|
assert(workStation ~= nil)
|
||||||
local nextStage = instance.stagesByName[nextStageName]
|
local nextStage = instance.stagesByName[nextStageName]
|
||||||
|
|
||||||
-- We get a table of temporary data.
|
local meta = workStation:getMeta(pos)
|
||||||
local craftData = Smc.getCraftDataByPos(pos)
|
meta:set_string('stage_name', nextStage.name)
|
||||||
assert(craftData ~= nil, 'Immersive crafting data is empty.')
|
|
||||||
|
|
||||||
-- We are updating the crafting stage in it.
|
nextStage:startHandler(pos, player)
|
||||||
craftData.stageName = nextStageName
|
|
||||||
-- We save it to the workstation metadata.
|
|
||||||
Smc.setCraftDataByPos(pos, craftData)
|
|
||||||
|
|
||||||
-- We are starting the next stage of crafting.
|
|
||||||
nextStage:startHandler(pos, Player)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -99,138 +78,129 @@ end
|
|||||||
---Initialize the start of the immersive crafting process.
|
---Initialize the start of the immersive crafting process.
|
||||||
---
|
---
|
||||||
---Returns `true` if the crafting process was running.
|
---Returns `true` if the crafting process was running.
|
||||||
---@param pos MapPosition
|
---@param pos MapVector
|
||||||
---@param player Player
|
---@param player Player
|
||||||
---@param amount integer
|
---@param amount integer
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function ImmersiveCraft:startCraft(pos, player, amount)
|
function ImmersiveCraft:startCraft(pos, player, amount)
|
||||||
-- Adding craft to the counter.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
-- If crafting has not been added...
|
assert(workStation ~= nil)
|
||||||
|
|
||||||
|
local meta = workStation:getMeta(pos)
|
||||||
|
local craftName = meta:get_string('craft_name')
|
||||||
|
if craftName ~= '' then
|
||||||
|
coreChatSendPlayer(player:get_player_name(), 'The workbench is occupied by another craft.')
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if not ImmersiveCraftCounter:addCraft(pos, player:get_player_name()) then
|
if not ImmersiveCraftCounter:addCraft(pos, player:get_player_name()) then
|
||||||
-- ...then we don't let the player start a new craft.
|
coreChatSendPlayer(player:get_player_name(),
|
||||||
core.chat_send_player(player:get_player_name(),
|
|
||||||
'The limit of simultaneously active crafts has been reached: '..
|
'The limit of simultaneously active crafts has been reached: '..
|
||||||
'complete or cancel active crafts to start a new one')
|
'complete or cancel active crafts to start a new one')
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- We get the material as an ItemStack.
|
|
||||||
---@type ItemStack
|
|
||||||
local stack = ItemStack(self.triggerItem)
|
|
||||||
-- We edit the amount of materials in accordance with the number of crafts being performed.
|
|
||||||
stack:set_count(stack:get_count() * amount)
|
|
||||||
|
|
||||||
-- We get the player's inventory, from where we must take the materials for crafting.
|
|
||||||
local playerInventory = player:get_inventory()
|
|
||||||
|
|
||||||
-- If the player does not have the necessary materials for crafting...
|
|
||||||
if not playerInventory:contains_item('main', stack) then
|
|
||||||
-- ...we inform him about this.
|
|
||||||
core.chat_send_player(player:get_player_name(),
|
|
||||||
'Not enough materials for crafting')
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If we have the materials, we take them and start initializing the craft.
|
|
||||||
playerInventory:remove_item('main', stack)
|
|
||||||
|
|
||||||
-- We get the first stage of crafting.
|
|
||||||
local stage = self.stagesByName[self.startStageName]
|
local stage = self.stagesByName[self.startStageName]
|
||||||
|
|
||||||
-- Create a temporary data table for crafting.
|
meta:set_string('player_name', player:get_player_name())
|
||||||
---@type ImmersiveCraftData
|
meta:set_string('craft_name', self.name)
|
||||||
local craftData = {
|
meta:set_string('stage_name', stage.name)
|
||||||
playerName = player:get_player_name(), -- The name of the player who started the craft.
|
meta:set_float('craft_amount', amount)
|
||||||
craftName = self.name,
|
|
||||||
stageName = stage.name,
|
|
||||||
amount = amount,
|
|
||||||
}
|
|
||||||
-- We save it to the workstation metadata.
|
|
||||||
Smc.setCraftDataByPos(pos, craftData)
|
|
||||||
|
|
||||||
-- We are starting the first stage of crafting.
|
|
||||||
stage:startHandler(pos, player)
|
stage:startHandler(pos, player)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---Complete the immersive crafting process.
|
---Complete the immersive crafting process.
|
||||||
---@param pos MapPosition
|
---@param pos MapVector
|
||||||
---@param player Player
|
---@param player Player
|
||||||
function ImmersiveCraft:endCraft(pos, player)
|
function ImmersiveCraft:endCraft(pos, player)
|
||||||
-- We get current data on crafting.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
---@type ImmersiveCraftData?
|
assert(workStation ~= nil)
|
||||||
local craftData = Smc.getCraftDataByPos(pos)
|
|
||||||
assert(craftData ~= nil, 'Immersive crafting data is empty.')
|
|
||||||
|
|
||||||
-- We drop the result of crafting.
|
local meta = workStation:getMeta(pos)
|
||||||
local dropPos = vector.new(pos) + vector.new(0, 0.9,0)
|
local playerName = meta:get_string('player_name')
|
||||||
for i=1, craftData.amount do
|
assert(playerName ~= '')
|
||||||
core.item_drop(ItemStack(self.output), nil, dropPos)
|
local amount = meta:get_float('craft_amount')
|
||||||
|
assert(amount ~= 0)
|
||||||
|
|
||||||
|
-- Drop the result of crafting.
|
||||||
|
local dropPos = v(pos) + v(0, 0.9,0)
|
||||||
|
for i=1, amount do
|
||||||
|
coreItemDrop(ItemStack(self.output), nil, dropPos)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove craft from the counter.
|
ImmersiveCraftCounter:removeCraft(pos, playerName)
|
||||||
ImmersiveCraftCounter:removeCraft(pos, craftData.playerName)
|
|
||||||
|
|
||||||
-- Clearing the temporary data table for crafting, freeing up the work station for new crafts.
|
-- Clear craft data
|
||||||
Smc.setCraftDataByPos(pos)
|
meta:set_string('player_name', '')
|
||||||
|
meta:set_string('craft_name', '')
|
||||||
|
meta:set_string('stage_name', '')
|
||||||
|
meta:set_float('craft_amount', 0)
|
||||||
|
meta:set_string('stage_data', '')
|
||||||
end
|
end
|
||||||
|
|
||||||
---Stop the crafting process and free up the workbench.
|
---Stop the crafting process and free up the workbench.
|
||||||
---@param pos MapPosition
|
---@param pos MapVector
|
||||||
function ImmersiveCraft:abortCraft(pos)
|
function ImmersiveCraft:abortCraft(pos)
|
||||||
-- We get current data on crafting.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
---@type ImmersiveCraftData?
|
assert(workStation ~= nil)
|
||||||
local craftData = Smc.getCraftDataByPos(pos)
|
|
||||||
assert(craftData ~= nil, 'Immersive crafting data is empty.')
|
|
||||||
|
|
||||||
-- We get the current stage and start the abort process.
|
local meta = workStation:getMeta(pos)
|
||||||
local stage = self.stagesByName[craftData.stageName]
|
local playerName = meta:get_string('player_name')
|
||||||
|
assert(playerName ~= '')
|
||||||
|
local stageName = meta:get_string('stage_name')
|
||||||
|
assert(stageName ~= '')
|
||||||
|
|
||||||
|
local stage = self.stagesByName[stageName]
|
||||||
stage:abortHandler(pos)
|
stage:abortHandler(pos)
|
||||||
|
|
||||||
-- Clearing the temporary data table for crafting, freeing up the work station for new crafts.
|
-- Clear craft data
|
||||||
Smc.setCraftDataByPos(pos)
|
meta:set_string('player_name', '')
|
||||||
|
meta:set_string('craft_name', '')
|
||||||
|
meta:set_string('stage_name', '')
|
||||||
|
meta:set_float('craft_amount', 0)
|
||||||
|
meta:set_string('stage_data', '')
|
||||||
|
|
||||||
-- Remove craft from the counter.
|
ImmersiveCraftCounter:removeCraft(pos, playerName)
|
||||||
ImmersiveCraftCounter:removeCraft(pos, craftData.playerName)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns a human-readable description of the crafting process.
|
---Returns a human-readable description of the crafting process.
|
||||||
---@return string
|
---@param recipeIndex integer?
|
||||||
function ImmersiveCraft:toString()
|
---@param mainList ItemStack[]?
|
||||||
-- We get the material as an ItemStack.
|
---@return string
|
||||||
---@type ItemStack
|
function ImmersiveCraft:recipeToString(recipeIndex, mainList)
|
||||||
local stack = ItemStack(self.triggerItem)
|
local recipeDesc = ''
|
||||||
-- We obtain a table of item parameters.
|
|
||||||
---@type ItemDefinition
|
|
||||||
local itemDef = stack:get_definition()
|
|
||||||
|
|
||||||
-- Let's start writing a description of the craft.
|
|
||||||
local craftDesc = ('Material: %s x%s\n\n'):format(itemDef._title, stack:get_count())..
|
|
||||||
'Crafting process:\n'
|
|
||||||
|
|
||||||
-- Let's start with the first crafting stage.
|
|
||||||
---@type string?
|
---@type string?
|
||||||
local stageName = self.startStageName
|
local stageName = self.startStageName
|
||||||
local stages = self.stagesByName
|
local stages = self.stagesByName
|
||||||
|
|
||||||
-- While we have a stage name...
|
|
||||||
local count = 1
|
local count = 1
|
||||||
while stageName ~= nil do
|
while stageName ~= nil do
|
||||||
-- We get a crafting stage...
|
|
||||||
local stage = stages[stageName]
|
local stage = stages[stageName]
|
||||||
|
|
||||||
-- ...and we add its description to the list of actions for crafting.
|
recipeDesc = recipeDesc..tostring(count)..'. '..stage:toString()..'\n'
|
||||||
craftDesc = craftDesc..tostring(count)..'. '..stage:toString()..'\n'
|
|
||||||
|
|
||||||
-- We also get the name of the next stage.
|
|
||||||
stageName = stage.nextStage
|
stageName = stage.nextStage
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If the cycle is interrupted, it means we have processed all the stages.
|
return recipeDesc
|
||||||
-- Return the craft description.
|
end
|
||||||
|
|
||||||
|
---@param recipeIndex integer?
|
||||||
|
---@param mainList ItemStack[]?
|
||||||
|
---@return string
|
||||||
|
function ImmersiveCraft:toString(recipeIndex, mainList)
|
||||||
|
local outputItem = ItemStack(self.output)
|
||||||
|
local outputItemSettings = Smc.getItemDefinition(outputItem).settings
|
||||||
|
|
||||||
|
local craftDesc = ('%s\n\nRecipe:\n%s\nActions:\n%s'):format(
|
||||||
|
outputItemSettings._title,
|
||||||
|
BaseCraft.recipeToString(self, recipeIndex, mainList),
|
||||||
|
self:recipeToString(recipeIndex, mainList))
|
||||||
|
|
||||||
return craftDesc
|
return craftDesc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ local ImmersiveCraftCounter = {
|
|||||||
---Add craft to the counter.
|
---Add craft to the counter.
|
||||||
---
|
---
|
||||||
---Returns `false` if the counter is already full.
|
---Returns `false` if the counter is already full.
|
||||||
---@param pos MapPosition
|
---@param pos MapVector
|
||||||
---@param playerName string
|
---@param playerName string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function ImmersiveCraftCounter:addCraft(pos, playerName)
|
function ImmersiveCraftCounter:addCraft(pos, playerName)
|
||||||
@@ -57,7 +57,7 @@ function ImmersiveCraftCounter:addCraft(pos, playerName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Remove craft from the counter.
|
---Remove craft from the counter.
|
||||||
---@param pos MapPosition
|
---@param pos MapVector
|
||||||
---@param playerName string
|
---@param playerName string
|
||||||
function ImmersiveCraftCounter:removeCraft(pos, playerName)
|
function ImmersiveCraftCounter:removeCraft(pos, playerName)
|
||||||
local playerCrafts = self.craftsCountForPlayers[playerName]
|
local playerCrafts = self.craftsCountForPlayers[playerName]
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
local extend = Class.extend
|
local tableInsert, tableSort, tableJoin = table.insert, table.sort, table.join
|
||||||
|
|
||||||
local tableInsert = table.insert
|
|
||||||
|
|
||||||
local modInfo = Mod.getInfo('smc__core__craft_system')
|
local modInfo = Mod.getInfo('smc__core__craft_system')
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
@@ -13,13 +11,16 @@ local ImmersiveCraft = require('CraftSystem.ImmersiveCraft')
|
|||||||
---A handler for immersive crafting that requires the player to complete
|
---A handler for immersive crafting that requires the player to complete
|
||||||
---crafting stages and interact with entities (crafting nodes)
|
---crafting stages and interact with entities (crafting nodes)
|
||||||
---@class CraftSystem.ImmersiveCraftHandler : CraftSystem.BaseCraftHandler
|
---@class CraftSystem.ImmersiveCraftHandler : CraftSystem.BaseCraftHandler
|
||||||
---@field craftsByTriggerItem table<string, CraftSystem.ImmersiveCraft[]>
|
---@field defaultCraftDef CraftSystem.BaseCraftDef
|
||||||
|
---
|
||||||
|
---@field new fun(self:CraftSystem.ImmersiveCraftHandler, baseType:CraftSystem.BaseCraftType, type:CraftSystem.ImmersiveCraftType, def:CraftSystem.ImmersiveCraftHandlerDef):CraftSystem.ImmersiveCraftHandler
|
||||||
---@field getCraftByName fun(self, craftName:string):CraftSystem.ImmersiveCraft
|
---@field getCraftByName fun(self, craftName:string):CraftSystem.ImmersiveCraft
|
||||||
---@field getCraftsByGroup fun(self, craftGroup):CraftSystem.ImmersiveCraft[]
|
---@field getCraftsByGroup fun(self, craftGroup):CraftSystem.ImmersiveCraft[]
|
||||||
---@field getLearnedCrafts fun(self, playerName):table<string, CraftSystem.ImmersiveCraft>
|
---@field getLearnedCrafts fun(self, playerName):table<string, CraftSystem.ImmersiveCraft>
|
||||||
local ImmersiveCraftHandler = extend(BaseCraftHandler, {
|
local ImmersiveCraftHandler = BaseCraftHandler:extend({})
|
||||||
craftsByTriggerItem = {},
|
|
||||||
})
|
---@class CraftSystem.ImmersiveCraftHandlerDef : CraftSystem.BaseCraftHandlerDef
|
||||||
|
---@field defaultCraftDef CraftSystem.ImmersiveCraftDef?
|
||||||
|
|
||||||
---Register an immersive crafting experience that requires the player to complete
|
---Register an immersive crafting experience that requires the player to complete
|
||||||
---one or more crafting stages that involve interaction with entities (crafting nodes)
|
---one or more crafting stages that involve interaction with entities (crafting nodes)
|
||||||
@@ -29,43 +30,51 @@ function ImmersiveCraftHandler:registerCraft(craftName, def)
|
|||||||
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
||||||
craftName))
|
craftName))
|
||||||
|
|
||||||
-- We obtain a crafting instance according to the given parameters.
|
local def = table.merge(def, self.defaultCraftDef)
|
||||||
local craft = ImmersiveCraft:new(craftName, def)
|
|
||||||
|
|
||||||
-- The craft group to which the craft belongs.
|
local group = 'craft_group:' .. (def.group or 'UNDEFINED')
|
||||||
local group = def.group
|
def.group = group
|
||||||
|
|
||||||
|
local craft = (ImmersiveCraft:new(craftName, def))
|
||||||
|
|
||||||
-- If no craft with this group has been registered before...
|
|
||||||
if self.craftsByGroup[group] == nil then
|
if self.craftsByGroup[group] == nil then
|
||||||
-- ...then we create a list for this group.
|
|
||||||
self.craftsByGroup[group] = {}
|
self.craftsByGroup[group] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The material from which crafting begins (also known as the starting item).
|
|
||||||
local triggerItem = def.triggerItem
|
|
||||||
|
|
||||||
-- If no crafting for such a starting item has been registered before...
|
|
||||||
if self.craftsByTriggerItem[triggerItem] == nil then
|
|
||||||
-- ...then we create a list for this item.
|
|
||||||
self.craftsByTriggerItem[triggerItem] = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Adding craft to the lists:
|
|
||||||
self.craftsByName[craftName] = craft
|
self.craftsByName[craftName] = craft
|
||||||
tableInsert(self.craftsByGroup[group], craft)
|
tableInsert(self.craftsByGroup[group], craft)
|
||||||
tableInsert(self.craftsByTriggerItem[triggerItem], craft)
|
|
||||||
tableInsert(self.craftsList, craft)
|
tableInsert(self.craftsList, craft)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns a list of crafts that use the given item as a starting material.
|
-- Sort the list of crafts in alphabetical order by product name and combine crafts into groups.
|
||||||
---
|
-- Provides a convenient list of crafting items in the player's inventory.
|
||||||
---Will return `nil` if the item is not used in any craft as a starting item.
|
core.register_on_mods_loaded(function()
|
||||||
---@param triggerItem string
|
for groupName, crafts in pairs(ImmersiveCraftHandler.craftsByGroup) do
|
||||||
---@return CraftSystem.ImmersiveCraft[]?
|
tableSort(crafts, function(a, b)
|
||||||
function ImmersiveCraftHandler:getCraftsByTriggerItem(triggerItem)
|
if a.output < b.output then
|
||||||
local crafts = self.craftsByTriggerItem[triggerItem]
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
return crafts
|
if groupName ~= 'craft_group:UNDEFINED' then
|
||||||
end
|
tableInsert(ImmersiveCraftHandler.groupedCrafts, crafts)
|
||||||
|
else
|
||||||
|
ImmersiveCraftHandler.groupedCrafts = tableJoin(ImmersiveCraftHandler.groupedCrafts, crafts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tableSort(ImmersiveCraftHandler.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
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
return ImmersiveCraftHandler
|
return ImmersiveCraftHandler
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local modInfo = Mod.getInfo('smc__core__craft_system')
|
local require = Mod.getInfo('smc__core__craft_system').require
|
||||||
local require = modInfo.require
|
|
||||||
|
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
|
||||||
|
|
||||||
---@type CraftSystem.ImmersiveCraftNode
|
---@type CraftSystem.ImmersiveCraftNode
|
||||||
local ImmersiveCraftNode = require('CraftSystem.ImmersiveCraftNode')
|
local ImmersiveCraftNode = require('CraftSystem.ImmersiveCraftNode')
|
||||||
@@ -14,7 +15,7 @@ local ImmersiveCraftNode = require('CraftSystem.ImmersiveCraftNode')
|
|||||||
---@field _set_item fun(self:CraftSystem.ImmersiveCraftNode.LuaTappingNode, itemName:ItemStackString?)
|
---@field _set_item fun(self:CraftSystem.ImmersiveCraftNode.LuaTappingNode, itemName:ItemStackString?)
|
||||||
---@field _craft_name string
|
---@field _craft_name string
|
||||||
---@field _stage_name string
|
---@field _stage_name string
|
||||||
---@field _work_station_pos MapPosition
|
---@field _work_station_pos MapVector
|
||||||
|
|
||||||
-- A crafting node (entity) that is used in the tapping crafting stage.
|
-- A crafting node (entity) that is used in the tapping crafting stage.
|
||||||
local tappingNode = ImmersiveCraftNode:new({
|
local tappingNode = ImmersiveCraftNode:new({
|
||||||
@@ -40,11 +41,9 @@ local tappingNode = ImmersiveCraftNode:new({
|
|||||||
callbacks = {
|
callbacks = {
|
||||||
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
|
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
|
||||||
on_activate = function(luaEntity, staticdata, dtime)
|
on_activate = function(luaEntity, staticdata, dtime)
|
||||||
-- We obtain a table of initial parameters for the craft node entity.
|
|
||||||
---@type CraftSystem.ImmersiveCraftStage.TappingNode.InitParams?
|
---@type CraftSystem.ImmersiveCraftStage.TappingNode.InitParams?
|
||||||
local params = core.deserialize(staticdata)
|
local params = core.deserialize(staticdata)
|
||||||
|
|
||||||
-- We enter parameters into the entity's custom fields.
|
|
||||||
if params ~= nil then
|
if params ~= nil then
|
||||||
luaEntity._item_name = params.targetItem
|
luaEntity._item_name = params.targetItem
|
||||||
luaEntity._craft_name = params.craftName
|
luaEntity._craft_name = params.craftName
|
||||||
@@ -61,15 +60,14 @@ local tappingNode = ImmersiveCraftNode:new({
|
|||||||
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
|
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
|
||||||
on_punch = function(luaEntity, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
on_punch = function(luaEntity, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
-- We simply trigger the event that the player hits the crafting node, bound to the work station with coordinates.
|
-- We simply trigger the event that the player hits the crafting node, bound to the work station with coordinates.
|
||||||
Events.call(('craft_system:punch_tapping_node:%s:%s'):format(
|
ImmersiveCraftEvents:callOnPunchTappingNode(luaEntity._craft_name, luaEntity._stage_name, luaEntity._work_station_pos, puncher, luaEntity)
|
||||||
luaEntity._craft_name, luaEntity._stage_name), luaEntity._work_station_pos, puncher, luaEntity)
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
|
---@param luaEntity CraftSystem.ImmersiveCraftNode.LuaTappingNode
|
||||||
get_staticdata = function(luaEntity)
|
get_staticdata = function(luaEntity)
|
||||||
---@type CraftSystem.ImmersiveCraftStage.TappingNode.InitParams?
|
---@type CraftSystem.ImmersiveCraftStage.TappingNode.InitParams
|
||||||
local params = {
|
local params = {
|
||||||
targetItem = luaEntity._item_name,
|
targetItem = luaEntity._item_name,
|
||||||
craftName = luaEntity._craft_name,
|
craftName = luaEntity._craft_name,
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
local v = vector.new
|
||||||
|
local assert = assert
|
||||||
local extend = Class.extend
|
local extend = Class.extend
|
||||||
|
local coreItemDrop = core.item_drop
|
||||||
local getStageDataByPos, setStageDataByPos = Smc.getStageDataByPos, Smc.setStageDataByPos
|
|
||||||
|
|
||||||
local require = Mod.getInfo('smc__core__craft_system').require
|
local require = Mod.getInfo('smc__core__craft_system').require
|
||||||
|
|
||||||
|
local ImmersiveCraftEvents = Smc.requireEvents('ImmersiveCraftEvents') --[[@as Events.ImmersiveCraftEvents]]
|
||||||
|
|
||||||
---@type CraftSystem.ImmersiveCraftStage
|
---@type CraftSystem.ImmersiveCraftStage
|
||||||
local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage')
|
local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage')
|
||||||
|
|
||||||
@@ -12,9 +15,9 @@ local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage')
|
|||||||
---@field targetItem string
|
---@field targetItem string
|
||||||
---@field clicksNeed string
|
---@field clicksNeed string
|
||||||
---@field toolGroup string?
|
---@field toolGroup string?
|
||||||
---@field startHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player)
|
---@field startHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapVector, Player:Player)
|
||||||
---@field processHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player)
|
---@field processHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapVector, Player:Player)
|
||||||
---@field endHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player)
|
---@field endHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapVector, Player:Player)
|
||||||
---@field toString fun(self:CraftSystem.ImmersiveCraftStage.TappingStage):string
|
---@field toString fun(self:CraftSystem.ImmersiveCraftStage.TappingStage):string
|
||||||
local TappingStage = extend(ImmersiveCraftStage, {})
|
local TappingStage = extend(ImmersiveCraftStage, {})
|
||||||
|
|
||||||
@@ -29,7 +32,7 @@ local TappingStage = extend(ImmersiveCraftStage, {})
|
|||||||
---Data table for transferring various time parameters between calls.
|
---Data table for transferring various time parameters between calls.
|
||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class ImmersiveStageData.TappingStageData : ImmersiveStageData
|
---@class CraftSystem.ImmersiveCraftStage.TappingStageData
|
||||||
---How many clicks were made by the player on the entity.
|
---How many clicks were made by the player on the entity.
|
||||||
---@field clickCount integer
|
---@field clickCount integer
|
||||||
---Unique identifier of the entity (craft node).
|
---Unique identifier of the entity (craft node).
|
||||||
@@ -37,18 +40,15 @@ local TappingStage = extend(ImmersiveCraftStage, {})
|
|||||||
|
|
||||||
---@param def CraftSystem.ImmersiveCraftStage.TappingStageDef
|
---@param def CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
function TappingStage:new(def)
|
function TappingStage:new(def)
|
||||||
---@type CraftSystem.ImmersiveCraftStage.TappingStage
|
local instance = ImmersiveCraftStage:new(def) --[[@as CraftSystem.ImmersiveCraftStage.TappingStage]]
|
||||||
local instance = ImmersiveCraftStage:new(def)
|
|
||||||
instance.targetItem = def.targetItem
|
instance.targetItem = def.targetItem
|
||||||
instance.clicksNeed = def.clicksNeed
|
instance.clicksNeed = def.clicksNeed
|
||||||
instance.toolGroup = def.toolGroup
|
instance.toolGroup = def.toolGroup
|
||||||
|
|
||||||
-- Registering the crafting stage start handler.
|
-- Registering the crafting stage start handler.
|
||||||
instance.startHandler = function(tappingStage , pos, player)
|
instance.startHandler = function(tappingStage , pos, player)
|
||||||
-- We determine the coordinate where we will create the crafting node (entity).
|
local entityPos = v(pos) + v(0,0.875,0)
|
||||||
local entityPos = vector.new(pos) + vector.new(0,0.875,0)
|
|
||||||
|
|
||||||
-- We create a table of initial parameters that we will pass to the entity.
|
|
||||||
---@class CraftSystem.ImmersiveCraftStage.TappingNode.InitParams
|
---@class CraftSystem.ImmersiveCraftStage.TappingNode.InitParams
|
||||||
local params = {
|
local params = {
|
||||||
targetItem = tappingStage.targetItem,
|
targetItem = tappingStage.targetItem,
|
||||||
@@ -57,90 +57,94 @@ function TappingStage:new(def)
|
|||||||
WorkStationPos = pos,
|
WorkStationPos = pos,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Adding an entity to the world.
|
|
||||||
local obj = core.add_entity(entityPos, 'craft_system:tapping_node', core.serialize(params))
|
local obj = core.add_entity(entityPos, 'craft_system:tapping_node', core.serialize(params))
|
||||||
|
|
||||||
-- If the entity was not returned, something went wrong.
|
|
||||||
if obj == nil then
|
if obj == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a temporary table of crafting stage data.
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageData
|
||||||
---@type ImmersiveStageData.TappingStageData
|
|
||||||
local stageData = {
|
local stageData = {
|
||||||
clickCount = 0,
|
clickCount = 0,
|
||||||
entityGUID = obj:get_guid()
|
entityGUID = obj:get_guid()
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Saving temporary data in work station metadata.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
setStageDataByPos(pos, stageData)
|
assert(workStation ~= nil)
|
||||||
|
|
||||||
|
local meta = workStation:getMeta(pos)
|
||||||
|
meta:set_string('stage_data', core.serialize(stageData))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Registering the crafting stage process handler.
|
-- Registering the crafting stage process handler.
|
||||||
-- Called when a player clicks on a crafting node (entity).
|
-- Called when a player clicks on a crafting node (entity).
|
||||||
instance.processHandler = function(tappingStage, pos, player)
|
instance.processHandler = function(tappingStage, pos, player)
|
||||||
-- Obtaining stage time data from work station metadata.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
---@type ImmersiveStageData.TappingStageData?
|
assert(workStation ~= nil)
|
||||||
local stageData = getStageDataByPos(pos)
|
local meta = workStation:getMeta(pos)
|
||||||
assert(stageData ~= nil, 'Immersive stage data is empty.')
|
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageData?
|
||||||
|
local stageData = core.deserialize(meta:get_string('stage_data'))
|
||||||
|
assert(stageData ~= nil)
|
||||||
|
|
||||||
-- Increasing the click counter
|
|
||||||
local clickCount = stageData.clickCount
|
local clickCount = stageData.clickCount
|
||||||
clickCount = clickCount + 1
|
clickCount = clickCount + 1
|
||||||
|
|
||||||
-- If the number of clicks is greater than required to complete the step...
|
|
||||||
if clickCount >= tappingStage.clicksNeed then
|
if clickCount >= tappingStage.clicksNeed then
|
||||||
-- ...we are completing the stage.
|
|
||||||
tappingStage:endHandler(pos, player)
|
tappingStage:endHandler(pos, player)
|
||||||
else
|
else
|
||||||
-- ...else we save the number of clicks in the temporary data table.
|
|
||||||
stageData.clickCount = clickCount
|
stageData.clickCount = clickCount
|
||||||
Smc.setStageDataByPos(pos, stageData)
|
meta:set_string('stage_data', core.serialize(stageData))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Registering the crafting stage end handler.
|
-- Registering the crafting stage end handler.
|
||||||
instance.endHandler = function(tappingStage, pos, player)
|
instance.endHandler = function(tappingStage, pos, player)
|
||||||
-- Obtaining stage time data from work station metadata.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
---@type ImmersiveStageData.TappingStageData?
|
assert(workStation ~= nil)
|
||||||
local stageData = getStageDataByPos(pos)
|
local meta = workStation:getMeta(pos)
|
||||||
assert(stageData ~= nil, 'Immersive stage data is empty.')
|
|
||||||
|
|
||||||
-- We get the entity object.
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageData?
|
||||||
local entity = Smc.getObjectByGUID(stageData.entityGUID)
|
local stageData = core.deserialize(meta:get_string('stage_data'))
|
||||||
|
assert(stageData ~= nil)
|
||||||
|
|
||||||
|
local entity = Smc.getObjectByGUID(stageData.entityGUID) --[[@as Entity?]]
|
||||||
assert(entity ~= nil, 'The entity for immersive crafting is nil.')
|
assert(entity ~= nil, 'The entity for immersive crafting is nil.')
|
||||||
|
|
||||||
-- Removing an entity from the world.
|
|
||||||
entity:remove()
|
entity:remove()
|
||||||
|
|
||||||
-- We trigger an event that the crafting stage has been completed.
|
ImmersiveCraftEvents:callOnNextStage(tappingStage.craftName, tappingStage, pos, player)
|
||||||
Events.call('craft_system:next_immersive_stage:'..tappingStage.craftName, tappingStage, pos, player)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Registering the aborting the crafting process handler.
|
-- Registering the aborting the crafting process handler.
|
||||||
---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage
|
---@param tappingStage CraftSystem.ImmersiveCraftStage.TappingStage
|
||||||
|
---@param pos MapVector
|
||||||
instance.abortHandler = function(tappingStage, pos)
|
instance.abortHandler = function(tappingStage, pos)
|
||||||
-- We receive current data on crafting.
|
local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]]
|
||||||
---@type ImmersiveCraftData?
|
assert(workStation ~= nil)
|
||||||
local craftData = Smc.getCraftDataByPos(pos)
|
local meta = workStation:getMeta(pos)
|
||||||
assert(craftData ~= nil, 'Immersive crafting data is empty.')
|
|
||||||
|
|
||||||
-- Obtaining stage time data from work station metadata.
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageData?
|
||||||
---@type ImmersiveStageData.TappingStageData?
|
local stageData = core.deserialize(meta:get_string('stage_data'))
|
||||||
local stageData = craftData.stageData
|
assert(stageData ~= nil)
|
||||||
|
|
||||||
|
local amount = meta:get_float('craft_amount')
|
||||||
|
assert(amount ~= 0)
|
||||||
|
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageData?
|
||||||
|
local stageData = stageData
|
||||||
assert(stageData ~= nil, 'Immersive stage data is empty.')
|
assert(stageData ~= nil, 'Immersive stage data is empty.')
|
||||||
|
|
||||||
-- We get the entity object.
|
---@type Entity?
|
||||||
local entity = Smc.getObjectByGUID(stageData.entityGUID)
|
local entity = Smc.getObjectByGUID(stageData.entityGUID) --[[@as Entity?]]
|
||||||
assert(entity ~= nil, 'The entity for immersive crafting is nil.')
|
assert(entity ~= nil, 'The entity for immersive crafting is nil.')
|
||||||
|
|
||||||
-- Removing an entity from the world.
|
|
||||||
entity:remove()
|
entity:remove()
|
||||||
|
|
||||||
-- We drop the item as it was before processing.
|
-- We drop the item as it was before processing.
|
||||||
local dropPos = vector.new(pos)+vector.new(0, 0.9,0)
|
local dropPos = v(pos) + v(0, 0.9,0)
|
||||||
for i=1, craftData.amount do
|
for i=1, amount do
|
||||||
core.item_drop(ItemStack(tappingStage.targetItem), nil, dropPos)
|
coreItemDrop(ItemStack(tappingStage.targetItem), nil, dropPos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -157,16 +161,11 @@ function TappingStage:new(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Subscribe to an event that means the player hit the entity.
|
-- Subscribe to an event that means the player hit the entity.
|
||||||
Events.subscribe(('craft_system:punch_tapping_node:%s:%s'):format(instance.craftName, instance.name),
|
ImmersiveCraftEvents:subscribeOnPunchTappingNode(instance.craftName, instance.name, function(pos, player, craftNode)
|
||||||
---@param craftNode LuaEntity
|
|
||||||
---@param player Player
|
|
||||||
function(eventName, pos, player, craftNode)
|
|
||||||
-- We get the item that the player clicked on the crafting node.
|
|
||||||
local toolDef = player:get_wielded_item():get_definition()
|
local toolDef = player:get_wielded_item():get_definition()
|
||||||
|
|
||||||
-- If a crafting stage requires a specific tool group and he doesn't have it...
|
-- If a crafting stage requires a specific tool group and he doesn't have it then we don't do anything.
|
||||||
if instance.toolGroup and (not toolDef.groups or not toolDef.groups[instance.toolGroup]) then
|
if instance.toolGroup and (not toolDef.groups or not toolDef.groups[instance.toolGroup]) then
|
||||||
-- ...then we don't do anything.
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,7 +173,7 @@ function TappingStage:new(def)
|
|||||||
-- Creating particles
|
-- Creating particles
|
||||||
for i=0, 10 do
|
for i=0, 10 do
|
||||||
core.add_particle({
|
core.add_particle({
|
||||||
pos = vector.new(pos)+vector.new(0,0.5,0),
|
pos = v(pos) + v(0,0.5,0),
|
||||||
velocity = {x=math.random(-1,1), y=4, z=math.random(-1,1)},
|
velocity = {x=math.random(-1,1), y=4, z=math.random(-1,1)},
|
||||||
acceleration = {x=0, y=-9.8, z=0},
|
acceleration = {x=0, y=-9.8, z=0},
|
||||||
expirationtime = 2,
|
expirationtime = 2,
|
||||||
@@ -184,12 +183,11 @@ function TappingStage:new(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Making the entity shake (silly method :P).
|
-- Making the entity shake (silly method :P).
|
||||||
craftNode.object:set_rotation(vector.new(0.01,0.1,0.01))
|
craftNode.object:set_rotation(v(0.01,0.1,0.01))
|
||||||
core.after(0.1, function() craftNode.object:set_rotation(vector.new(-0.01,-0.1,-0.01))end)
|
core.after(0.1, function() craftNode.object:set_rotation(v(-0.01,-0.1,-0.01))end)
|
||||||
core.after(0.2, function() craftNode.object:set_rotation(vector.new(0,0,0))end)
|
core.after(0.2, function() craftNode.object:set_rotation(v(0,0,0))end)
|
||||||
-- DRAFT END
|
-- DRAFT END
|
||||||
|
|
||||||
-- Calling the crafting stage process handler.
|
|
||||||
instance:processHandler(pos, player)
|
instance:processHandler(pos, player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -7,31 +7,22 @@ local require = modInfo.require
|
|||||||
local BaseCraft = require('CraftSystem.BaseCraft')
|
local BaseCraft = require('CraftSystem.BaseCraft')
|
||||||
|
|
||||||
---@class CraftSystem.PrimitiveCraft : CraftSystem.BaseCraft
|
---@class CraftSystem.PrimitiveCraft : CraftSystem.BaseCraft
|
||||||
---@field output string
|
---@field returnItems ItemStackString[]?
|
||||||
---@field recipe CraftSystem.CraftRecipe
|
local PrimitiveCraft = BaseCraft:extend({})
|
||||||
---@field returnItems ItemStackString[]
|
|
||||||
local PrimitiveCraft = extend(BaseCraft, {})
|
|
||||||
|
|
||||||
---Definition table for the `CraftSystem.PrimitiveCraft`.
|
---Definition table for the `CraftSystem.PrimitiveCraft`.
|
||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class CraftSystem.PrimitiveCraftDef : CraftSystem.BaseCraftDef
|
---@class CraftSystem.PrimitiveCraftDef : CraftSystem.BaseCraftDef
|
||||||
---@field output string
|
---@field returnItems ItemStackString[]?
|
||||||
---@field recipe CraftSystem.CraftRecipe
|
|
||||||
---@field returnItems ItemStackString[]
|
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param def CraftSystem.PrimitiveCraftDef
|
---@param def CraftSystem.PrimitiveCraftDef
|
||||||
---@return CraftSystem.PrimitiveCraft
|
---@return CraftSystem.PrimitiveCraft
|
||||||
function PrimitiveCraft:new(name, def)
|
function PrimitiveCraft:new(name, def)
|
||||||
---@type CraftSystem.PrimitiveCraft
|
---@type CraftSystem.PrimitiveCraft
|
||||||
local instance = getInstance(self, {
|
local instance = self:getInstance(BaseCraft:new(name, def))
|
||||||
name = name,
|
instance.returnItems = def.returnItems
|
||||||
group = def.group,
|
|
||||||
output = def.output,
|
|
||||||
recipe = def.recipe,
|
|
||||||
returnItems = def.returnItems or {}
|
|
||||||
})
|
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local extend = Class.extend
|
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 modInfo = Mod.getInfo('smc__core__craft_system')
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
@@ -14,10 +14,19 @@ local PrimitiveCraft = require('CraftSystem.PrimitiveCraft')
|
|||||||
---A primitive crafting processor that doesn't require much interaction and provides
|
---A primitive crafting processor that doesn't require much interaction and provides
|
||||||
---simple crafting based on a recipe-result scheme.
|
---simple crafting based on a recipe-result scheme.
|
||||||
---@class CraftSystem.PrimitiveCraftHandler : CraftSystem.BaseCraftHandler
|
---@class CraftSystem.PrimitiveCraftHandler : CraftSystem.BaseCraftHandler
|
||||||
|
---@field defaultCraftDef CraftSystem.PrimitiveCraftDef
|
||||||
|
---
|
||||||
|
---@field craftsByGroup table<CraftSystem.CraftGroup, CraftSystem.PrimitiveCraft[]>
|
||||||
|
---@field groupedCrafts (CraftSystem.PrimitiveCraft[]|CraftSystem.PrimitiveCraft)[]
|
||||||
|
---
|
||||||
|
---@field new fun(self:CraftSystem.PrimitiveCraftHandler, baseType:CraftSystem.BaseCraftType, type:CraftSystem.PrimitiveCraftType, def:CraftSystem.PrimitiveCraftHandlerDef):CraftSystem.PrimitiveCraftHandler
|
||||||
---@field getCraftByName fun(self, craftName:string):CraftSystem.PrimitiveCraft
|
---@field getCraftByName fun(self, craftName:string):CraftSystem.PrimitiveCraft
|
||||||
---@field getCraftsByGroup fun(self, craftGroup):CraftSystem.PrimitiveCraft[]
|
---@field getCraftsByGroup fun(self, craftGroup:string):CraftSystem.PrimitiveCraft[]
|
||||||
---@field getLearnedCrafts fun(self, playerName):table<string, CraftSystem.PrimitiveCraft>
|
---@field getLearnedCrafts fun(self, playerName:string):(CraftSystem.PrimitiveCraft[]|CraftSystem.PrimitiveCraft)[]
|
||||||
local PrimitiveCraftHandler = extend(BaseCraftHandler, {})
|
local PrimitiveCraftHandler = BaseCraftHandler:extend({})
|
||||||
|
|
||||||
|
---@class CraftSystem.PrimitiveCraftHandlerDef : CraftSystem.BaseCraftHandlerDef
|
||||||
|
---@field defaultCraftDef CraftSystem.PrimitiveCraftDef?
|
||||||
|
|
||||||
---Register a primitive craft that does not require special interaction.
|
---Register a primitive craft that does not require special interaction.
|
||||||
---@param craftName string
|
---@param craftName string
|
||||||
@@ -26,9 +35,12 @@ function PrimitiveCraftHandler:registerCraft(craftName, def)
|
|||||||
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
||||||
craftName))
|
craftName))
|
||||||
|
|
||||||
local craft = PrimitiveCraft:new(craftName, def)
|
local def = table.merge(def, self.defaultCraftDef)
|
||||||
|
|
||||||
local group = def.group
|
local group = 'craft_group:' .. (def.group or 'UNDEFINED')
|
||||||
|
def.group = group
|
||||||
|
|
||||||
|
local craft = PrimitiveCraft:new(craftName, def)
|
||||||
|
|
||||||
if self.craftsByGroup[group] == nil then
|
if self.craftsByGroup[group] == nil then
|
||||||
self.craftsByGroup[group] = {}
|
self.craftsByGroup[group] = {}
|
||||||
@@ -39,4 +51,46 @@ function PrimitiveCraftHandler:registerCraft(craftName, def)
|
|||||||
tableInsert(self.craftsList, craft)
|
tableInsert(self.craftsList, craft)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Adds alternative recipes to the craft with the specified name.
|
||||||
|
---
|
||||||
|
---If a craft with the specified name does not exist, an error will call.
|
||||||
|
---@param craftName string
|
||||||
|
---@param recipes CraftSystem.CraftRecipe[]
|
||||||
|
function PrimitiveCraftHandler:registerAlternativeRecipes(craftName, recipes)
|
||||||
|
local craft = PrimitiveCraftHandler:getCraftByName(craftName)
|
||||||
|
|
||||||
|
craft.altRecipes = tableJoin(craft.altRecipes or {}, recipes)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Sort the list of crafts in alphabetical order by product name and combine crafts into groups.
|
||||||
|
-- Provides a convenient list of crafting items in the player's inventory.
|
||||||
|
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
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
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
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
return PrimitiveCraftHandler
|
return PrimitiveCraftHandler
|
||||||
|
|||||||
41
mods/CORE/CraftSystem/src/CraftSystem/ProcessingCraft.lua
Normal file
41
mods/CORE/CraftSystem/src/CraftSystem/ProcessingCraft.lua
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
local getInstance, extend = Class.getInstance, Class.extend
|
||||||
|
|
||||||
|
local modInfo = Mod.getInfo('smc__core__craft_system')
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
---@type CraftSystem.BaseCraft
|
||||||
|
local BaseCraft = require('CraftSystem.BaseCraft')
|
||||||
|
|
||||||
|
---@class CraftSystem.ProcessingCraft : CraftSystem.BaseCraft
|
||||||
|
---@field recipe CraftSystem.CraftRecipe
|
||||||
|
---@field time number
|
||||||
|
---@field startHandler fun()
|
||||||
|
---@field processHandler fun()
|
||||||
|
---@field endHandler fun()
|
||||||
|
local ProcessingCraft = BaseCraft:extend({})
|
||||||
|
|
||||||
|
---Definition table for the `CraftSystem.ProcessingCraft`.
|
||||||
|
---
|
||||||
|
---**Only for EmmyLua.**
|
||||||
|
---@class CraftSystem.ProcessingCraftDef : CraftSystem.BaseCraftDef
|
||||||
|
---@field recipe CraftSystem.CraftRecipe
|
||||||
|
---@field time number
|
||||||
|
---@field startHandler fun()?
|
||||||
|
---@field processHandler fun()?
|
||||||
|
---@field endHandler fun()?
|
||||||
|
|
||||||
|
---@param name string
|
||||||
|
---@param def CraftSystem.ProcessingCraftDef
|
||||||
|
---@return CraftSystem.ProcessingCraft
|
||||||
|
function ProcessingCraft:new(name, def)
|
||||||
|
---@type CraftSystem.ProcessingCraft
|
||||||
|
local instance = self:getInstance(BaseCraft:new(name, def))
|
||||||
|
instance.time = def.time
|
||||||
|
instance.startHandler = def.startHandler or function() end
|
||||||
|
instance.processHandler = def.processHandler or function() end
|
||||||
|
instance.endHandler = def.endHandler or function() end
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
return ProcessingCraft
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
local HASH_SEPARATOR = ','
|
||||||
|
|
||||||
|
local tableInsert, tableCopy, tableSort, tableConcat, tableIsEmpty = table.insert, table.copy, table.sort, table.concat, table.is_empty
|
||||||
|
|
||||||
|
local modInfo = Mod.getInfo('smc__core__craft_system')
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
---@type CraftSystem.BaseCraftHandler
|
||||||
|
local BaseCraftHandler = require('CraftSystem.BaseCraftHandler')
|
||||||
|
|
||||||
|
---@type CraftSystem.ProcessingCraft
|
||||||
|
local ProcessingCraft = require('CraftSystem.ProcessingCraft')
|
||||||
|
|
||||||
|
---A primitive crafting processor that doesn't require much interaction and provides
|
||||||
|
---simple crafting based on a recipe-result scheme.
|
||||||
|
---@class CraftSystem.ProcessingCraftHandler : CraftSystem.BaseCraftHandler
|
||||||
|
---@field defaultCraftDef CraftSystem.ProcessingCraftDef
|
||||||
|
---
|
||||||
|
---@field craftsByHash table<string, CraftSystem.ProcessingCraft>
|
||||||
|
---
|
||||||
|
---@field new fun(self:CraftSystem.ProcessingCraftHandler, baseType:CraftSystem.BaseCraftType, type:CraftSystem.ProcessingCraftType, def:CraftSystem.ProcessingCraftHandlerDef):CraftSystem.ProcessingCraftHandler
|
||||||
|
---@field getCraftByName fun(self, craftName:string):CraftSystem.ProcessingCraft
|
||||||
|
---@field getCraftsByGroup fun(self, craftGroup:string):CraftSystem.ProcessingCraft[]
|
||||||
|
---@field getLearnedCrafts fun(self, playerName:string):(CraftSystem.ProcessingCraft[]|CraftSystem.ProcessingCraft)[]
|
||||||
|
local ProcessingCraftHandler = BaseCraftHandler:extend({
|
||||||
|
craftsByHash = {}
|
||||||
|
})
|
||||||
|
|
||||||
|
---@class CraftSystem.ProcessingCraftHandlerDef : CraftSystem.BaseCraftHandlerDef
|
||||||
|
---@field defaultCraftDef CraftSystem.ProcessingCraftDef?
|
||||||
|
|
||||||
|
---@param recipe CraftSystem.CraftRecipe
|
||||||
|
local function getCraftHash(recipe)
|
||||||
|
recipe = tableCopy(recipe)
|
||||||
|
|
||||||
|
tableSort(recipe)
|
||||||
|
return tableConcat(recipe, HASH_SEPARATOR)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Register a primitive craft that does not require special interaction.
|
||||||
|
---@param craftName string
|
||||||
|
---@param def CraftSystem.ProcessingCraftDef
|
||||||
|
function ProcessingCraftHandler:registerCraft(craftName, def)
|
||||||
|
assert(self.craftsByName[craftName] == nil, ('A craft named `%s` already exists.'):format(
|
||||||
|
craftName))
|
||||||
|
|
||||||
|
local def = table.merge(def, self.defaultCraftDef)
|
||||||
|
|
||||||
|
local group = 'craft_group:' .. (def.group or 'UNDEFINED')
|
||||||
|
def.group = group
|
||||||
|
|
||||||
|
local craft = ProcessingCraft:new(craftName, def)
|
||||||
|
|
||||||
|
if self.craftsByGroup[group] == nil then
|
||||||
|
self.craftsByGroup[group] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local craftHash = getCraftHash(craft.recipe)
|
||||||
|
assert(self.craftsByHash[craftHash] == nil, 'A craft with this recipe already exists.')
|
||||||
|
|
||||||
|
self.craftsByName[craftName] = craft
|
||||||
|
tableInsert(self.craftsByGroup[group], craft)
|
||||||
|
tableInsert(self.craftsList, craft)
|
||||||
|
self.craftsByHash[craftHash] = craft
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param input ItemStack[]
|
||||||
|
---@return CraftSystem.ProcessingCraft?
|
||||||
|
function ProcessingCraftHandler:getCraftByRecipe(input)
|
||||||
|
local recipe = {}
|
||||||
|
for _, item in ipairs(input) do
|
||||||
|
if not item:is_empty() then
|
||||||
|
tableInsert(recipe, item:get_name())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if tableIsEmpty(recipe) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: добавить поиск по группам крафтов
|
||||||
|
|
||||||
|
local craftHash = getCraftHash(recipe)
|
||||||
|
local craft = self.craftsByHash[craftHash]
|
||||||
|
|
||||||
|
return craft
|
||||||
|
end
|
||||||
|
|
||||||
|
return ProcessingCraftHandler
|
||||||
@@ -24,8 +24,7 @@ local function entityDefToLuantiDef(entityDef)
|
|||||||
local s = entityDef.settings
|
local s = entityDef.settings
|
||||||
local c = entityDef.callbacks or {}
|
local c = entityDef.callbacks or {}
|
||||||
|
|
||||||
---@type EntityDefinition
|
local luantiDef = tableMerge(s, c) --[[@as EntityDefinition]]
|
||||||
local luantiDef = tableMerge(s, c)
|
|
||||||
|
|
||||||
return luantiDef
|
return luantiDef
|
||||||
end
|
end
|
||||||
@@ -45,6 +44,7 @@ function Creature:new(entityDef)
|
|||||||
|
|
||||||
local s = entityDef.settings
|
local s = entityDef.settings
|
||||||
local c = entityDef.callbacks
|
local c = entityDef.callbacks
|
||||||
|
assert(c ~= nil)
|
||||||
|
|
||||||
-- Add the short mod name prefix to the entity name.
|
-- Add the short mod name prefix to the entity name.
|
||||||
if s._add_mod_name then
|
if s._add_mod_name then
|
||||||
@@ -66,8 +66,7 @@ function Creature:new(entityDef)
|
|||||||
initCustomFields.name = nil
|
initCustomFields.name = nil
|
||||||
initCustomFields.object = nil
|
initCustomFields.object = nil
|
||||||
|
|
||||||
---@type LuaEntity
|
self = tableMerge(self, initCustomFields) --[[@as LuaEntity]]
|
||||||
self = tableMerge(self, initCustomFields)
|
|
||||||
|
|
||||||
-- If an initialization callback was specified for the entity, then we call it.
|
-- If an initialization callback was specified for the entity, then we call it.
|
||||||
if c.on_activate ~= nil then
|
if c.on_activate ~= nil then
|
||||||
|
|||||||
@@ -197,12 +197,30 @@ end
|
|||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemIndex)
|
function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemIndex)
|
||||||
local element = ('list[%s;%s;%s,%s;%s,%s;%s]'):format(
|
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)
|
self:addElement(element)
|
||||||
return self
|
return self
|
||||||
end
|
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 MapVector
|
||||||
|
---@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.
|
---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[]`
|
---**Elements:** `listring[<inventory location>;<list name>]` or `listring[]`
|
||||||
@@ -296,7 +314,7 @@ end
|
|||||||
---@param w number
|
---@param w number
|
||||||
---@param h number
|
---@param h number
|
||||||
---@param textureName string
|
---@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
|
---@return Formspec
|
||||||
function Formspec:image(x, y, w, h, textureName, middle)
|
function Formspec:image(x, y, w, h, textureName, middle)
|
||||||
local element = ('image[%s,%s;%s,%s;%s;%s]'):format(
|
local element = ('image[%s,%s;%s,%s;%s;%s]'):format(
|
||||||
@@ -441,7 +459,7 @@ end
|
|||||||
--- * All numbers in middle are integers.
|
--- * All numbers in middle are integers.
|
||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:background9(x, y, w, h, textureName, autoClip, middle)
|
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)
|
x, y, w, h, textureName, autoClip, middle)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
@@ -491,7 +509,7 @@ end
|
|||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:field(x, y, w, h, name, label, default)
|
function Formspec:field(x, y, w, h, name, label, default)
|
||||||
local element = ('field[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('field[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name, label or '', default or '')
|
x, y, w, h, name, label or '', core.formspec_escape(default) or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
return self
|
return self
|
||||||
@@ -545,7 +563,7 @@ end
|
|||||||
--- Defaults to true when not specified (i.e. no tag for a field).
|
--- Defaults to true when not specified (i.e. no tag for a field).
|
||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:fieldCloseOnEnter(name, closeOnEnter)
|
function Formspec:fieldCloseOnEnter(name, closeOnEnter)
|
||||||
local element = ('field_enter_after_edit[%s;%s]'):format(
|
local element = ('field_close_on_enter[%s;%s]'):format(
|
||||||
name, closeOnEnter or false)
|
name, closeOnEnter or false)
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
@@ -572,7 +590,7 @@ end
|
|||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:textArea(x, y, w, h, name, label, default)
|
function Formspec:textArea(x, y, w, h, name, label, default)
|
||||||
local element = ('textarea[%s,%s;%s,%s;%s;%s;%s]'):format(
|
local element = ('textarea[%s,%s;%s,%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, name or '', label or '', default or '')
|
x, y, w, h, name or '', label or '', core.formspec_escape(default) or '')
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
return self
|
return self
|
||||||
@@ -592,7 +610,7 @@ end
|
|||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:label(x, y, label)
|
function Formspec:label(x, y, label)
|
||||||
local element = ('label[%s,%s;%s]'):format(
|
local element = ('label[%s,%s;%s]'):format(
|
||||||
x, y, label)
|
x, y, core.formspec_escape(label))
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
return self
|
return self
|
||||||
@@ -612,7 +630,7 @@ end
|
|||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:areaLabel(x, y, w, h, label)
|
function Formspec:areaLabel(x, y, w, h, label)
|
||||||
local element = ('label[%s,%s;%s,%s;%s]'):format(
|
local element = ('label[%s,%s;%s,%s;%s]'):format(
|
||||||
x, y, w, h, label)
|
x, y, w, h, core.formspec_escape(label))
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
return self
|
return self
|
||||||
@@ -646,7 +664,7 @@ end
|
|||||||
---@return Formspec
|
---@return Formspec
|
||||||
function Formspec:vertlabel(x, y, label)
|
function Formspec:vertlabel(x, y, label)
|
||||||
local element = ('vertlabel[%s,%s;%s]'):format(
|
local element = ('vertlabel[%s,%s;%s]'):format(
|
||||||
x, y, label)
|
x, y, core.formspec_escape(label))
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
return self
|
return self
|
||||||
@@ -700,7 +718,7 @@ end
|
|||||||
---
|
---
|
||||||
---**Elements:** `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]` or
|
---**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>]`
|
---`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 x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param w number
|
---@param w number
|
||||||
@@ -708,7 +726,7 @@ end
|
|||||||
---@param textureName string Is the filename of an image.
|
---@param textureName string Is the filename of an image.
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param label 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 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`
|
---@param drawborder boolean? Draw button border or not. Default `false`
|
||||||
---@return Formspec
|
---@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 '')
|
x, y, w, h, textureName, name, label or '')
|
||||||
else
|
else
|
||||||
element = ('image_button[%s,%s;%s,%s;%s;%s;%s;%s;%s;%s]'):format(
|
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
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
|||||||
4
mods/CORE/ImmersiveWorkStation/init.lua
Normal file
4
mods/CORE/ImmersiveWorkStation/init.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
local modInfo = Mod.getInfo('smc__core__immersive_work_station')
|
||||||
|
local require = modInfo.require
|
||||||
|
|
||||||
|
return require('ImmersiveWorkStation')
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
name = smc__core__work_station
|
name = smc__core__immersive_work_station
|
||||||
depends = smc__core__craft_system, smc__core__node, smc__ui__work_station
|
depends = smc__core__craft_system, smc__core__node, smc__ui__work_station
|
||||||
268
mods/CORE/ImmersiveWorkStation/src/ImmersiveWorkStation.lua
Normal file
268
mods/CORE/ImmersiveWorkStation/src/ImmersiveWorkStation.lua
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
local assert = assert
|
||||||
|
local coreNodePunch, coreNodeDig, coreChatSendPlayer, coreGetMeta, coreSwapNode = core.node_punch, core.node_dig, core.chat_send_player, core.get_meta, core.swap_node
|
||||||
|
|
||||||
|
local CraftSystem = Smc.requireCraftSystem()
|
||||||
|
local PlayerInventoryUI = Smc.requirePlayerInventoryUI()
|
||||||
|
local Node = Smc.requireNode()
|
||||||
|
|
||||||
|
local ImmersiveWorkStationNode = Node:getExtended({
|
||||||
|
settings = {
|
||||||
|
name = '',
|
||||||
|
drawtype = 'normal',
|
||||||
|
paramtype = 'light',
|
||||||
|
groups = { immersive_work_station = 1, dig_immediate = 2 }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
---A work station (node) that enables player interaction
|
||||||
|
---with the immersive crafting mechanics.
|
||||||
|
---@class ImmersiveWorkStation : Class, NodeSuperClass
|
||||||
|
---@field name string
|
||||||
|
---@field craftType CraftSystem.ImmersiveCraftType
|
||||||
|
---@field handler CraftSystem.ImmersiveCraftHandler
|
||||||
|
---@field tab PlayerInventoryUI.getTabFunc
|
||||||
|
---@field nodeName string?
|
||||||
|
---@field activeNodeName string?
|
||||||
|
local ImmersiveWorkStation = Class:extend({})
|
||||||
|
|
||||||
|
---Definition table for the `ImmersiveWorkStation`.
|
||||||
|
---
|
||||||
|
---**Only for EmmyLua.**
|
||||||
|
---@class ImmersiveWorkStationDef
|
||||||
|
---@field craftType CraftSystem.ImmersiveCraftType
|
||||||
|
---@field tab PlayerInventoryUI.getTabFunc
|
||||||
|
|
||||||
|
---@alias ImmersiveWorkStation.NodesDefinition {settings:Node.Settings, activeSettings:Node.Settings?, callbacks:Node.Callbacks?}
|
||||||
|
|
||||||
|
---@param def ImmersiveWorkStationDef
|
||||||
|
---@param nodesDef ImmersiveWorkStation.NodesDefinition
|
||||||
|
function ImmersiveWorkStation:new(def, nodesDef)
|
||||||
|
local handler = CraftSystem:getImmersiveCraftHandler(def.craftType)
|
||||||
|
|
||||||
|
---@type ImmersiveWorkStation
|
||||||
|
local instance = self:getInstance({})
|
||||||
|
instance.craftType = def.craftType
|
||||||
|
instance.handler = handler
|
||||||
|
instance.tab = def.tab
|
||||||
|
|
||||||
|
local settings = nodesDef.settings
|
||||||
|
local activeSettings = nodesDef.activeSettings
|
||||||
|
local callbacks = nodesDef.callbacks or {}
|
||||||
|
|
||||||
|
local oldCallback = callbacks.on_construct or function(...) end
|
||||||
|
callbacks.on_construct = function(pos)
|
||||||
|
oldCallback(pos)
|
||||||
|
|
||||||
|
instance:init(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
oldCallback = callbacks.on_rightclick or function(...) end
|
||||||
|
-- Callback for interaction with a work station (start of crafting)
|
||||||
|
callbacks.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
oldCallback(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
|
||||||
|
instance:showForm(pos, clicker)
|
||||||
|
end
|
||||||
|
|
||||||
|
oldCallback = callbacks.on_punch or function(...) end
|
||||||
|
-- Callback for interaction with a work station (abort of crafting)
|
||||||
|
callbacks.on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
|
oldCallback(pos, node, puncher, pointed_thing)
|
||||||
|
|
||||||
|
instance:abortCraft(pos)
|
||||||
|
coreNodePunch(pos, node, puncher, pointed_thing)
|
||||||
|
end
|
||||||
|
|
||||||
|
oldCallback = callbacks.on_dig or function(...) end
|
||||||
|
callbacks.on_dig = function(pos, node, digger)
|
||||||
|
oldCallback(pos, node, digger)
|
||||||
|
|
||||||
|
return instance:onDig(pos, node, digger)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Registering a nodes for Luanti.
|
||||||
|
local node = ImmersiveWorkStationNode:new({ settings = settings, callbacks = callbacks })
|
||||||
|
instance.nodeName = node.itemDef.settings.name
|
||||||
|
|
||||||
|
if activeSettings ~= nil then
|
||||||
|
local activeNode = ImmersiveWorkStationNode:new({ settings = activeSettings, callbacks = callbacks })
|
||||||
|
instance.activeNodeName = activeNode.itemDef.settings.name
|
||||||
|
|
||||||
|
Smc.addNodeSuperclass(instance.activeNodeName, instance)
|
||||||
|
end
|
||||||
|
|
||||||
|
Smc.addNodeSuperclass(instance.nodeName, instance)
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
---A wrapper around `core.get_meta()` for convenience
|
||||||
|
---and returning the correct `MetaDataRef` type.
|
||||||
|
---@static
|
||||||
|
---@param pos MapVector
|
||||||
|
---@return ImmersiveWorkStation.MetaData
|
||||||
|
function ImmersiveWorkStation:getMeta(pos)
|
||||||
|
return coreGetMeta(pos) --[[@as ImmersiveWorkStation.MetaData]]
|
||||||
|
end
|
||||||
|
|
||||||
|
function ImmersiveWorkStation:showForm(pos, player)
|
||||||
|
local playerName = player:get_player_name()
|
||||||
|
local meta = self:getMeta(pos)
|
||||||
|
|
||||||
|
local craftName = meta:get_string('craft_name')
|
||||||
|
if craftName ~= '' then
|
||||||
|
coreChatSendPlayer(playerName, 'The workbench is occupied by another craft.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
PlayerInventoryUI:addActiveNodeForm(pos, playerName)
|
||||||
|
PlayerInventoryUI:setContex(playerName, 'left_tab_name', 'node_tab')
|
||||||
|
PlayerInventoryUI:setContex(playerName, 'node_tab_pos', pos)
|
||||||
|
PlayerInventoryUI:setContex(playerName, 'node_tab', self.tab)
|
||||||
|
|
||||||
|
PlayerInventoryUI:showForm(playerName)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param pos MapVector
|
||||||
|
function ImmersiveWorkStation:init(pos)
|
||||||
|
local meta = self:getMeta(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Replaces the node with active or inactive depending on the status of the craft.
|
||||||
|
---
|
||||||
|
---If an active node is not specified for a station,
|
||||||
|
---then no replacement will occur regardless of the status of the process.
|
||||||
|
---@param isCrafting boolean The stations process status. If `true`, the process is running.
|
||||||
|
---@param pos MapVector
|
||||||
|
function ImmersiveWorkStation:swapNode(isCrafting, pos)
|
||||||
|
assert(self.nodeName ~= nil)
|
||||||
|
|
||||||
|
if self.activeNodeName ~= nil then
|
||||||
|
if isCrafting then
|
||||||
|
coreSwapNode(pos, {name = self.activeNodeName})
|
||||||
|
else
|
||||||
|
coreSwapNode(pos, {name = self.nodeName})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param pos MapVector
|
||||||
|
---@param node NodeTable
|
||||||
|
---@param digger Player
|
||||||
|
---@return boolean
|
||||||
|
function ImmersiveWorkStation:onDig(pos, node, digger)
|
||||||
|
local meta = self:getMeta(pos)
|
||||||
|
|
||||||
|
local craftName = meta:get_string('craft_name')
|
||||||
|
if craftName == '' then
|
||||||
|
return coreNodeDig(pos, node, digger)
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param pos MapVector
|
||||||
|
function ImmersiveWorkStation:abortCraft(pos)
|
||||||
|
local meta = self:getMeta(pos)
|
||||||
|
|
||||||
|
local craftName = meta:get_string('craft_name')
|
||||||
|
if craftName == '' then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local craft = self.handler:getCraftByName(craftName)
|
||||||
|
craft:abortCraft(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- --- DEBUG ---
|
||||||
|
|
||||||
|
local handler = CraftSystem:getImmersiveCraftHandler('workbench')
|
||||||
|
|
||||||
|
local require = Mod.getInfo('smc__ui__player_inventory').require
|
||||||
|
local baseGetCraftTab = require('PlayerInventoryUI.baseGetCraftTab')
|
||||||
|
|
||||||
|
---@param self PlayerInventoryUI
|
||||||
|
---@param playerName string
|
||||||
|
---@param tabType PlayerInventoryUI.TabType
|
||||||
|
---@return Formspec
|
||||||
|
local function tab(self, playerName, tabType)
|
||||||
|
return baseGetCraftTab(self, playerName, tabType, 'node_tab', handler)
|
||||||
|
end
|
||||||
|
|
||||||
|
ImmersiveWorkStation:new({
|
||||||
|
craftType = 'workbench',
|
||||||
|
tab = tab,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
settings = {
|
||||||
|
name = 'test_station',
|
||||||
|
tiles = {'test_station.png'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
handler:registerCraft('bricks', {
|
||||||
|
output = 'rocks:sylite_bricks',
|
||||||
|
recipe = {'rocks:sylite'},
|
||||||
|
startStageName = 'tapping',
|
||||||
|
group = 'test',
|
||||||
|
stages = {
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
|
{
|
||||||
|
name = 'tapping',
|
||||||
|
targetItem = 'rocks:sylite',
|
||||||
|
type = 'tapping',
|
||||||
|
clicksNeed = 3,
|
||||||
|
nextStage = 'tapping_2',
|
||||||
|
},
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
|
{
|
||||||
|
name = 'tapping_2',
|
||||||
|
targetItem = 'rocks:sylite_block',
|
||||||
|
type = 'tapping',
|
||||||
|
clicksNeed = 5,
|
||||||
|
nextStage = 'tapping_3',
|
||||||
|
},
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
|
{
|
||||||
|
name = 'tapping_3',
|
||||||
|
targetItem = 'rocks:sylite_bricks',
|
||||||
|
type = 'tapping',
|
||||||
|
clicksNeed = 1,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
handler:registerCraft('block', {
|
||||||
|
output = 'rocks:sylite_block',
|
||||||
|
recipe = {'rocks:sylite'},
|
||||||
|
startStageName = 'tapping',
|
||||||
|
group = 'test',
|
||||||
|
stages = {
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
|
{
|
||||||
|
name = 'tapping',
|
||||||
|
targetItem = 'rocks:sylite',
|
||||||
|
type = 'tapping',
|
||||||
|
clicksNeed = 5,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
handler:registerCraft('marentine_planks', {
|
||||||
|
output = 'wood:marentine_planks',
|
||||||
|
recipe = {'rocks:sylite'},
|
||||||
|
startStageName = 'tapping',
|
||||||
|
group = 'test',
|
||||||
|
stages = {
|
||||||
|
---@type CraftSystem.ImmersiveCraftStage.TappingStageDef
|
||||||
|
{
|
||||||
|
name = 'tapping',
|
||||||
|
targetItem = 'wood:marentine_log',
|
||||||
|
type = 'tapping',
|
||||||
|
clicksNeed = 5,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
--]]
|
||||||
|
return ImmersiveWorkStation
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---@alias ImmersiveWorkStation.MetaData.StringKey 'player_name'|'craft_name'|'stage_name'|'stage_data'
|
||||||
|
---@alias ImmersiveWorkStation.MetaData.FloatKey 'craft_amount'
|
||||||
|
|
||||||
|
---**Only for EmmyLua.**
|
||||||
|
---@class ImmersiveWorkStation.MetaData : NodeMetaRef
|
||||||
|
---@field get_string fun(self, key:ImmersiveWorkStation.MetaData.StringKey):string
|
||||||
|
---@field set_string fun(self, key:ImmersiveWorkStation.MetaData.StringKey, value:string)
|
||||||
|
---@field get_float fun(self, key:ImmersiveWorkStation.MetaData.FloatKey):number
|
||||||
|
---@field set_float fun(self, key:ImmersiveWorkStation.MetaData.FloatKey, value:number)
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -1,9 +1,15 @@
|
|||||||
local getInstance, extend = Class.getInstance, Class.extend
|
|
||||||
|
|
||||||
local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
|
local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
|
||||||
|
|
||||||
local ItemFactory = Smc.requireItemFactory()
|
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.
|
---Determines whether common rarity will be shown in item descriptions or not.
|
||||||
local SHOW_COMMON_RARITY = true
|
local SHOW_COMMON_RARITY = true
|
||||||
|
|
||||||
@@ -31,12 +37,12 @@ local RARITY_INDEX = {
|
|||||||
['unique'] = 0
|
['unique'] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class Item
|
---@class Item : Class
|
||||||
---@field itemDef Item.ItemDefinition
|
---@field itemDef Item.ItemDefinition
|
||||||
---@field luantiDef ItemDefinition
|
---@field luantiDef ItemDefinition
|
||||||
---@field getType fun():string
|
---@field getType fun(self:Item):string
|
||||||
---@field defaultDef Item.ItemDefinition
|
---@field defaultDef Item.ItemDefinition
|
||||||
local Item = {
|
local Item = Class:extend({
|
||||||
defaultDef = {
|
defaultDef = {
|
||||||
settings = {
|
settings = {
|
||||||
name = '',
|
name = '',
|
||||||
@@ -50,13 +56,17 @@ local Item = {
|
|||||||
},
|
},
|
||||||
callbacks = {}
|
callbacks = {}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
---Adds an item's rarity tag to the description.
|
---Adds an item's rarity tag to the description.
|
||||||
---@param rarity Item.Rarity
|
---@param rarity Item.Rarity
|
||||||
---@param desc string
|
---@param desc string
|
||||||
---@return string
|
---@return string
|
||||||
local function addRarityToDesc(rarity, desc)
|
local function addRarityToDesc(rarity, desc)
|
||||||
|
if not SHOW_RARITY then
|
||||||
|
return desc
|
||||||
|
end
|
||||||
|
|
||||||
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
||||||
return desc
|
return desc
|
||||||
end
|
end
|
||||||
@@ -98,22 +108,26 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
||||||
|
|
||||||
if s._title_color ~= nil and s._description_color ~= nil then
|
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))
|
description = colorize(s._description_color, S(description))
|
||||||
else
|
else
|
||||||
error('Item description color parameters cannot be empty.')
|
error('Item description color parameters cannot be empty.')
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
|
||||||
|
|
||||||
local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description)
|
local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description)
|
||||||
|
|
||||||
s._title = title
|
s._title = title
|
||||||
s._description = description
|
s._description = description
|
||||||
s.description = luantiDescription..core.get_background_escape_sequence('#110F13')
|
s.description = luantiDescription..core.get_background_escape_sequence('#110F13')
|
||||||
|
|
||||||
local luantiDef = defMerge(s, c)
|
local luantiDef = defMerge(s, c, true)
|
||||||
|
|
||||||
return luantiDef
|
return luantiDef
|
||||||
end
|
end
|
||||||
@@ -142,12 +156,6 @@ local function registerTool(luantiDef)
|
|||||||
core.register_tool(':'..name, luantiDef)
|
core.register_tool(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
---The alias `table.merge` for EmmyLua
|
|
||||||
---@type fun(...):(Item.ItemDefinition)
|
|
||||||
local defMerge = function(...)
|
|
||||||
return tableMerge(...)
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param itemDef Item.ItemDefinition|Node.NodeDefinition
|
---@param itemDef Item.ItemDefinition|Node.NodeDefinition
|
||||||
---@return Item
|
---@return Item
|
||||||
function Item:new(itemDef)
|
function Item:new(itemDef)
|
||||||
@@ -158,8 +166,9 @@ function Item:new(itemDef)
|
|||||||
|
|
||||||
itemDef = tableCopy(itemDef)
|
itemDef = tableCopy(itemDef)
|
||||||
|
|
||||||
-- Adding default parameters
|
-- Adding default parameterss
|
||||||
itemDef = defMerge(itemDef, self.defaultDef, true)
|
---@type Item.ItemDefinition
|
||||||
|
itemDef = tableMerge(itemDef, self.defaultDef, true)
|
||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
|
|
||||||
local shortModName = Mod.getInfo().shortName
|
local shortModName = Mod.getInfo().shortName
|
||||||
@@ -169,7 +178,7 @@ function Item:new(itemDef)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type Item
|
---@type Item
|
||||||
local instance = getInstance(self, {})
|
local instance = self:getInstance({})
|
||||||
|
|
||||||
local luantiDef = itemDefToLuantiDef(itemDef)
|
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||||
local type = itemDef.settings._type
|
local type = itemDef.settings._type
|
||||||
@@ -207,10 +216,10 @@ end
|
|||||||
---@param defaultDef Item.ItemDefinition
|
---@param defaultDef Item.ItemDefinition
|
||||||
---@return Item
|
---@return Item
|
||||||
function Item:getExtended(defaultDef)
|
function Item:getExtended(defaultDef)
|
||||||
defaultDef = defMerge(defaultDef, self.defaultDef, true)
|
defaultDef = tableMerge(defaultDef, self.defaultDef, true)
|
||||||
|
|
||||||
---@type Item
|
---@type Item
|
||||||
local ChildClass = extend(self, {
|
local ChildClass = self:extend({
|
||||||
defaultDef = defaultDef,
|
defaultDef = defaultDef,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -224,7 +233,7 @@ function Item:getFactory(defaultDef)
|
|||||||
if defaultDef == nil then
|
if defaultDef == nil then
|
||||||
defaultDef = self.defaultDef
|
defaultDef = self.defaultDef
|
||||||
else
|
else
|
||||||
defaultDef = defMerge(self.defaultDef, defaultDef, true)
|
defaultDef = tableMerge(self.defaultDef, defaultDef, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type ItemFactory
|
---@type ItemFactory
|
||||||
|
|||||||
@@ -48,6 +48,27 @@ Settings._rarity = nil
|
|||||||
---@type table<string,number>?
|
---@type table<string,number>?
|
||||||
Settings.groups = nil
|
Settings.groups = nil
|
||||||
|
|
||||||
|
---The number of inventory slots that can be stored in an ItemStack.
|
||||||
|
---@type integer?
|
||||||
|
Settings._itemstack_inventory_size = nil
|
||||||
|
|
||||||
|
---The name of the texture that will be displayed as the background
|
||||||
|
---for the item when it is equipped on the player as a bag.
|
||||||
|
---@type string?
|
||||||
|
Settings._itemstack_inventory_background = nil
|
||||||
|
|
||||||
|
---Defines a list of group names that items
|
||||||
|
---with which can be placed in an item's inventory.
|
||||||
|
---
|
||||||
|
---If it is `nil`, then any items will be allowed except those disallowed in `_itemstack_inventory_disallowed_groups`.
|
||||||
|
---@type string[]?
|
||||||
|
Settings._itemstack_inventory_allowed_groups = nil
|
||||||
|
|
||||||
|
---Defines a list of group names that items
|
||||||
|
---with which cannot be placed in an item's inventory.
|
||||||
|
---@type string[]?
|
||||||
|
Settings._itemstack_inventory_disallowed_groups = nil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---Texture shown in the inventory GUI.
|
---Texture shown in the inventory GUI.
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ end
|
|||||||
|
|
||||||
---@param itemDefs Item.ItemDefinition[]|Node.NodeDefinition[] List of nodes with parameters unique to them.
|
---@param itemDefs Item.ItemDefinition[]|Node.NodeDefinition[] List of nodes with parameters unique to them.
|
||||||
function ItemFactory:registerItems(itemDefs)
|
function ItemFactory:registerItems(itemDefs)
|
||||||
---@param nodeDef Item.ItemDefinition | Node.NodeDefinition
|
---@param itemDef Item.ItemDefinition | Node.NodeDefinition
|
||||||
for _, itemDef in ipairs(itemDefs) do
|
for _, itemDef in ipairs(itemDefs) do
|
||||||
itemDef = defMerge(itemDef, self.defaultDef, true)
|
itemDef = defMerge(itemDef, self.defaultDef, true)
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ local defMerge = function(...)
|
|||||||
return table.merge(...)
|
return table.merge(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param shortNodeDefs [string, (string[]|TileDefinition[])?][] Format list {{name, tiles}, {name, tiles}, ...}
|
---@param shortNodeDefs [string, (string[]|TileDefinition[]|nil)][] Format list {{name, tiles}, {name, tiles}, ...}
|
||||||
function ItemFactory:registerNodesByShortDef(shortNodeDefs)
|
function ItemFactory:registerNodesByShortDef(shortNodeDefs)
|
||||||
for _, shortNodeDef in ipairs(shortNodeDefs) do
|
for _, shortNodeDef in ipairs(shortNodeDefs) do
|
||||||
---@type Node.NodeDefinition
|
---@type Node.NodeDefinition
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
name = smc__core__map_gen
|
name = smc__core__map_gen
|
||||||
depends = smc__system__system_loader
|
depends = smc__system__system_loader, smc__core__node
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
local mathRound, mathRandom, mathClamp, tableInsert
|
local mathRound, mathRandom, mathClamp, tableInsert
|
||||||
= math.round, math.random, math.clamp, table.insert
|
= math.round, math.random, math.clamp, table.insert
|
||||||
|
|
||||||
local posToString, getUsTime = core.pos_to_string, core.get_us_time
|
local corePosToString, coreGetUsTime = core.pos_to_string, core.get_us_time
|
||||||
|
|
||||||
local pairs, ipairs, assert = pairs, ipairs, assert
|
local pairs, ipairs, assert = pairs, ipairs, assert
|
||||||
|
|
||||||
@@ -44,22 +44,30 @@ local Biome = require('MapGen.Biome')
|
|||||||
local Cavern = require('MapGen.Cavern')
|
local Cavern = require('MapGen.Cavern')
|
||||||
---@type MapGen.Region
|
---@type MapGen.Region
|
||||||
local Region = require('MapGen.Region')
|
local Region = require('MapGen.Region')
|
||||||
|
---@type MapGen.Tree
|
||||||
|
local Tree = require('MapGen.Tree')
|
||||||
|
|
||||||
---@class MapGen
|
---@class MapGen
|
||||||
---@field layersByName table<string, MapGen.Layer>
|
---@field layersByName table<string, MapGen.Layer>
|
||||||
---@field layersList MapGen.Layer[]
|
---@field layersList MapGen.Layer[]
|
||||||
---@field staticsByName table<string, MapGen.StaticLayer>
|
---
|
||||||
---@field staticsList MapGen.StaticLayer[]
|
---@field staticsByName table<string, MapGen.StaticLayer>
|
||||||
|
---@field staticsList MapGen.StaticLayer[]
|
||||||
|
---
|
||||||
|
---@field treesByName table<string, MapGen.Tree>
|
||||||
|
---
|
||||||
---@field isLayersNoisesInitialized boolean Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
---@field isLayersNoisesInitialized boolean Is the fractal noise of the layer initialized? This is necessary for a one-time noise initialization.
|
||||||
---@field isCavernsNoiseInitialized boolean Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
---@field isCavernsNoiseInitialized boolean Is the fractal noise of the caverns initialized? This is necessary for a one-time noise initialization.
|
||||||
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||||
---@field nodes table<string, string>
|
---
|
||||||
---@field nodeIDs table<string, number>
|
---@field nodes table<string, string>
|
||||||
|
---@field nodeIDs table<string, number>
|
||||||
local MapGen = {
|
local MapGen = {
|
||||||
layersByName = {},
|
layersByName = {},
|
||||||
layersList = {},
|
layersList = {},
|
||||||
staticsByName = {},
|
staticsByName = {},
|
||||||
staticsList = {},
|
staticsList = {},
|
||||||
|
treesByName = {},
|
||||||
isLayersNoisesInitialized = false,
|
isLayersNoisesInitialized = false,
|
||||||
isCavernsNoiseInitialized = false,
|
isCavernsNoiseInitialized = false,
|
||||||
isRunning = false,
|
isRunning = false,
|
||||||
@@ -87,6 +95,8 @@ function MapGen:new(def)
|
|||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- --- API METHODS ---
|
||||||
|
|
||||||
---Returns a layer by name. If such a layer does not exist, an error will be raised.
|
---Returns a layer by name. If such a layer does not exist, an error will be raised.
|
||||||
---@param layerName string The name of the layer to be retrieved.
|
---@param layerName string The name of the layer to be retrieved.
|
||||||
---@return MapGen.Layer
|
---@return MapGen.Layer
|
||||||
@@ -136,7 +146,7 @@ end
|
|||||||
|
|
||||||
---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`.
|
---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`.
|
||||||
---@param layer string|MapGen.Layer The layer or name of the layer in which the peak is located.
|
---@param layer string|MapGen.Layer The layer or name of the layer in which the peak is located.
|
||||||
---@param pos MapPosition Coordinate of the desired peak.
|
---@param pos MapVector Coordinate of the desired peak.
|
||||||
---@return MapGen.Peak?
|
---@return MapGen.Peak?
|
||||||
function MapGen:getPeakByPos(layer, pos)
|
function MapGen:getPeakByPos(layer, pos)
|
||||||
if type(layer) == 'string' then
|
if type(layer) == 'string' then
|
||||||
@@ -147,6 +157,184 @@ function MapGen:getPeakByPos(layer, pos)
|
|||||||
return layer:getPeakByPos(pos)
|
return layer:getPeakByPos(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Checks if a point is inside a region.
|
||||||
|
---
|
||||||
|
---If the point is inside the region, it will also return the distance to the nearest border.
|
||||||
|
---@param layer MapGen.Layer The name of the layer in which the region is located.
|
||||||
|
---@param regionName string The name of the region in which the location of the point is checked.
|
||||||
|
---@param point MapVector Point position.
|
||||||
|
---@return boolean, number?
|
||||||
|
function MapGen:pointInRegion2D(layer, regionName, point)
|
||||||
|
local region = layer.regionsByName[regionName]
|
||||||
|
|
||||||
|
assert(region ~= nil, ('There is no region named `%s` registered.'):format(regionName))
|
||||||
|
|
||||||
|
return region:pointInRegion(point)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
|
---@param layer MapGen.Layer
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
---@return boolean
|
||||||
|
function MapGen:isCavern(layer, x, y, z)
|
||||||
|
for _, cavern in ipairs(layer.cavernsList) do
|
||||||
|
if cavern.isRegional then
|
||||||
|
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, v(x, y, z) --[[@as MapVector]])
|
||||||
|
|
||||||
|
if inRegion and distance ~= nil then
|
||||||
|
if cavern:isCavern(x, y, z, distance) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if cavern:isLayeredCavern(x, y, z) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param name string
|
||||||
|
---@return MapGen.Tree
|
||||||
|
function MapGen:getTree(name)
|
||||||
|
assert(self.treesByName[name] ~= nil, ('There is no tree named `%s` registered.'):format(name))
|
||||||
|
|
||||||
|
return self.treesByName[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- --- API METHODS: REGISTRATION ---
|
||||||
|
|
||||||
|
---Mark the world area between two heights as a `MapGen.Layer`.
|
||||||
|
---
|
||||||
|
---Note: layers must not overlap.
|
||||||
|
---@param name string The name that will be assigned to the layer. The name must be unique for each layer.
|
||||||
|
---@param def MapGen.LayerDef Layer description table, see details `MapGen.LayerDef`.
|
||||||
|
function MapGen:registerLayer(name, def)
|
||||||
|
-- Layers with the same name cannot exist.
|
||||||
|
assert(self.layersByName[name] == nil, ('A layer named `%s` is already registered.'):format(name))
|
||||||
|
|
||||||
|
-- Layers cannot overlap.
|
||||||
|
assert(self:getLayerByHeight(def.minY) == nil and self:getLayerByHeight(def.maxY) == nil, 'Registered layers must not overlap!')
|
||||||
|
|
||||||
|
---@type MapGen.Layer
|
||||||
|
local layer = Layer:new(name, def)
|
||||||
|
|
||||||
|
self.layersByName[name] = layer
|
||||||
|
tableInsert(self.layersList, layer)
|
||||||
|
|
||||||
|
pastNoiseValues[name] = {}
|
||||||
|
|
||||||
|
-- Sort layers by maxY descending for processing priority.
|
||||||
|
table.sort(self.layersList, function(a, b)
|
||||||
|
return a.maxY > b.maxY
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Register the color and the noise parameters that correspond to it.
|
||||||
|
---@param layerName string The name of the layer for which the color will be registered.
|
||||||
|
---@param category MapGen.Layer.Category Category indicating what will be generated by noise.
|
||||||
|
---@param color ColorString Noise color. Must be unique.
|
||||||
|
---@param noiseParams NoiseParams Fractal noise parameters.
|
||||||
|
function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams)
|
||||||
|
local layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
|
layer:addNoiseParamsColor(category, color, noiseParams)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Mark the world area between two heights as a `MapGen.StaticLayer`.
|
||||||
|
---
|
||||||
|
---Note: layers must not overlap.
|
||||||
|
---@param name string The name that will be assigned to the static layer. The name must be unique for each layer.
|
||||||
|
---@param def MapGen.StaticLayerDef Static layer description table, see details `MapGen.StaticLayerDef`.
|
||||||
|
function MapGen:registerStaticLayer(name, def)
|
||||||
|
-- Static layer with the same name cannot exist.
|
||||||
|
assert(self.staticsByName[name] == nil, ('A static layer named `%s` is already registered.'):format(name))
|
||||||
|
|
||||||
|
-- Static layers cannot overlap.
|
||||||
|
assert(self:getStaticByHeight(def.minY) == nil and self:getLayerByHeight(def.maxY) == nil, 'Registered static layers must not overlap!')
|
||||||
|
|
||||||
|
---@type MapGen.StaticLayer
|
||||||
|
local static = StaticLayer:new(name, def)
|
||||||
|
|
||||||
|
self.staticsByName[name] = static
|
||||||
|
tableInsert(self.staticsList, static)
|
||||||
|
|
||||||
|
-- Sort srtatics by maxY descending for processing priority.
|
||||||
|
table.sort(self.staticsList, function(a, b)
|
||||||
|
return a.maxY > b.maxY
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Mark a point on the biomes diagram and constrain the world area by height to mark it as `MapGen.Biome`.
|
||||||
|
---@param layerName string The name of the layer in which the new biome will be included.
|
||||||
|
---@param biomeName string The name to be assigned to the biome. The name must be unique for each biome.
|
||||||
|
---@param def MapGen.BiomeDef Biome description table, see details `MapGen.BiomeDef`
|
||||||
|
function MapGen:registerBiome(layerName, biomeName, def)
|
||||||
|
local layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
|
local biome = Biome:new(biomeName, def)
|
||||||
|
|
||||||
|
layer:addBiome(biomeName, biome)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Mark the world area between two heights as a `MapGen.Cavern` and assign the noise that the cave will be generated from.
|
||||||
|
---@param layerName string The name of the layer in which the new cavern will be included.
|
||||||
|
---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern.
|
||||||
|
---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef`
|
||||||
|
---@param regionVertices MapVector[]? The region to which the cave generation will be limited.
|
||||||
|
function MapGen:registerCavern(layerName, cavernName, def, regionVertices)
|
||||||
|
local layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
|
if regionVertices ~= nil then
|
||||||
|
self:registerRegion(layerName, cavernName, {
|
||||||
|
vertices = regionVertices
|
||||||
|
})
|
||||||
|
|
||||||
|
def.isRegional = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local cavern = Cavern:new(cavernName, def)
|
||||||
|
|
||||||
|
layer:addCavern(cavernName, cavern)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Mark the world region between the vertices as `MapGen.Region` and give it a name.
|
||||||
|
---@param layerName string The name of the layer in which the new region will be included.
|
||||||
|
---@param regionName string The name to be assigned to the region. The name must be unique for each region.
|
||||||
|
---@param def MapGen.RegionDef Region description table, see details `MapGen.RegionDef`
|
||||||
|
function MapGen:registerRegion(layerName, regionName, def)
|
||||||
|
if regionName == 'landscape_boundary' or
|
||||||
|
regionName == 'temp_boundary' or
|
||||||
|
regionName == 'humidity_boundary' then
|
||||||
|
error(('The name `%s` is reserved for special regions and cannot be used.'):format(regionName))
|
||||||
|
end
|
||||||
|
|
||||||
|
local layer = self:getLayerByName(layerName)
|
||||||
|
|
||||||
|
local region = Region:new(regionName, def)
|
||||||
|
|
||||||
|
layer:addRegion(regionName, region)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param name string
|
||||||
|
---@param def MapGen.TreeDef
|
||||||
|
function MapGen:registerTree(name, def)
|
||||||
|
assert(self.treesByName[name] == nil, ('A tree named `%s` is already registered.'):format(name))
|
||||||
|
local tree = Tree:new(name, def)
|
||||||
|
|
||||||
|
self.treesByName[name] = tree
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- --- HELPER METHODS ---
|
||||||
|
|
||||||
---Checks if a point is inside a triangle using the vector product method.
|
---Checks if a point is inside a triangle using the vector product method.
|
||||||
---
|
---
|
||||||
---If the point is inside the triangle, it will return the triangle itself;
|
---If the point is inside the triangle, it will return the triangle itself;
|
||||||
@@ -206,53 +394,12 @@ function MapGen:findTriangle(layer, x, z, triangle)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
isFound, triangle = self:isPointInTriangle(triangle, v(x, 0, z))
|
isFound, triangle = self:isPointInTriangle(triangle, v(x, 0, z) --[[@as MapVector]])
|
||||||
end
|
end
|
||||||
|
|
||||||
return triangle
|
return triangle
|
||||||
end
|
end
|
||||||
|
|
||||||
---Checks if a point is inside a region.
|
|
||||||
---
|
|
||||||
---If the point is inside the region, it will also return the distance to the nearest border.
|
|
||||||
---@param layer MapGen.Layer The name of the layer in which the region is located.
|
|
||||||
---@param regionName string The name of the region in which the location of the point is checked.
|
|
||||||
---@param point MapPosition Point position.
|
|
||||||
---@return boolean, number?
|
|
||||||
function MapGen:pointInRegion2D(layer, regionName, point)
|
|
||||||
local region = layer.regionsByName[regionName]
|
|
||||||
|
|
||||||
assert(region ~= nil, ('There is no region named `%s` registered.'):format(regionName))
|
|
||||||
|
|
||||||
return region:pointInRegion(point)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
|
||||||
---@param layer MapGen.Layer
|
|
||||||
---@param x integer
|
|
||||||
---@param y integer
|
|
||||||
---@param z integer
|
|
||||||
---@return boolean
|
|
||||||
function MapGen:isCavern(layer, x, y, z)
|
|
||||||
for _, cavern in ipairs(layer.cavernsList) do
|
|
||||||
if cavern.isRegional then
|
|
||||||
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, {x=x,y=y,z=z})
|
|
||||||
|
|
||||||
if inRegion and distance ~= nil then
|
|
||||||
if cavern:isCavern(x, y, z, distance) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if cavern:isLayeredCavern(x, y, z) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
---Creates a unique key for a vertex (using X and Z coordinates).
|
---Creates a unique key for a vertex (using X and Z coordinates).
|
||||||
---@param peak MapGen.Peak
|
---@param peak MapGen.Peak
|
||||||
---@return string
|
---@return string
|
||||||
@@ -336,7 +483,7 @@ function MapGen:getTriangulateBoundaryVertices(triangles)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Walk along boundary edges to create ordered vertex list
|
-- Walk along boundary edges to create ordered vertex list
|
||||||
---@type MapPosition[]
|
---@type MapVector[]
|
||||||
local boundary = {}
|
local boundary = {}
|
||||||
---@type table<string, boolean>
|
---@type table<string, boolean>
|
||||||
local visited = {}
|
local visited = {}
|
||||||
@@ -376,122 +523,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- --- REGISTRATION METHODS ---
|
|
||||||
|
|
||||||
---Mark the world area between two heights as a `MapGen.Layer`.
|
|
||||||
---
|
|
||||||
---Note: layers must not overlap.
|
|
||||||
---@param name string The name that will be assigned to the layer. The name must be unique for each layer.
|
|
||||||
---@param def MapGen.LayerDef Layer description table, see details `MapGen.LayerDef`.
|
|
||||||
function MapGen:registerLayer(name, def)
|
|
||||||
-- Layers with the same name cannot exist.
|
|
||||||
assert(self.layersByName[name] == nil, ('A layer named `%s` is already registered.'):format(name))
|
|
||||||
|
|
||||||
-- Layers cannot overlap.
|
|
||||||
assert(self:getLayerByHeight(def.minY) == nil and self:getLayerByHeight(def.maxY) == nil, 'Registered layers must not overlap!')
|
|
||||||
|
|
||||||
---@type MapGen.Layer
|
|
||||||
local layer = Layer:new(name, def)
|
|
||||||
|
|
||||||
self.layersByName[name] = layer
|
|
||||||
tableInsert(self.layersList, layer)
|
|
||||||
|
|
||||||
pastNoiseValues[name] = {}
|
|
||||||
|
|
||||||
-- Sort layers by maxY descending for processing priority.
|
|
||||||
table.sort(self.layersList, function(a, b)
|
|
||||||
return a.maxY > b.maxY
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Register the color and the noise parameters that correspond to it.
|
|
||||||
---@param layerName string The name of the layer for which the color will be registered.
|
|
||||||
---@param category MapGen.Layer.Category Category indicating what will be generated by noise.
|
|
||||||
---@param color ColorString Noise color. Must be unique.
|
|
||||||
---@param noiseParams NoiseParams Fractal noise parameters.
|
|
||||||
function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams)
|
|
||||||
local layer = self:getLayerByName(layerName)
|
|
||||||
|
|
||||||
layer:addNoiseParamsColor(category, color, noiseParams)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Mark the world area between two heights as a `MapGen.StaticLayer`.
|
|
||||||
---
|
|
||||||
---Note: layers must not overlap.
|
|
||||||
---@param name string The name that will be assigned to the static layer. The name must be unique for each layer.
|
|
||||||
---@param def MapGen.StaticLayerDef Static layer description table, see details `MapGen.StaticLayerDef`.
|
|
||||||
function MapGen:registerStaticLayer(name, def)
|
|
||||||
-- Static layer with the same name cannot exist.
|
|
||||||
assert(self.staticsByName[name] == nil, ('A static layer named `%s` is already registered.'):format(name))
|
|
||||||
|
|
||||||
-- Static layers cannot overlap.
|
|
||||||
assert(self:getStaticByHeight(def.minY) == nil and self:getLayerByHeight(def.maxY) == nil, 'Registered static layers must not overlap!')
|
|
||||||
|
|
||||||
---@type MapGen.StaticLayer
|
|
||||||
local static = StaticLayer:new(name, def)
|
|
||||||
|
|
||||||
self.staticsByName[name] = static
|
|
||||||
tableInsert(self.staticsList, static)
|
|
||||||
|
|
||||||
-- Sort srtatics by maxY descending for processing priority.
|
|
||||||
table.sort(self.staticsList, function(a, b)
|
|
||||||
return a.maxY > b.maxY
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Mark a point on the biomes diagram and constrain the world area by height to mark it as `MapGen.Biome`.
|
|
||||||
---@param layerName string The name of the layer in which the new biome will be included.
|
|
||||||
---@param biomeName string The name to be assigned to the biome. The name must be unique for each biome.
|
|
||||||
---@param def MapGen.BiomeDef Biome description table, see details `MapGen.BiomeDef`
|
|
||||||
function MapGen:registerBiome(layerName, biomeName, def)
|
|
||||||
local layer = self:getLayerByName(layerName)
|
|
||||||
|
|
||||||
local biome = Biome:new(biomeName, def)
|
|
||||||
|
|
||||||
layer:addBiome(biomeName, biome)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Mark the world area between two heights as a `MapGen.Cavern` and assign the noise that the cave will be generated from.
|
|
||||||
---@param layerName string The name of the layer in which the new cavern will be included.
|
|
||||||
---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern.
|
|
||||||
---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef`
|
|
||||||
---@param regionVertices MapPosition[]? The region to which the cave generation will be limited.
|
|
||||||
function MapGen:registerCavern(layerName, cavernName, def, regionVertices)
|
|
||||||
local layer = self:getLayerByName(layerName)
|
|
||||||
|
|
||||||
if regionVertices ~= nil then
|
|
||||||
self:registerRegion(layerName, cavernName, {
|
|
||||||
vertices = regionVertices
|
|
||||||
})
|
|
||||||
|
|
||||||
def.isRegional = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local cavern = Cavern:new(cavernName, def)
|
|
||||||
|
|
||||||
layer:addCavern(cavernName, cavern)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Mark the world region between the vertices as `MapGen.Region` and give it a name.
|
|
||||||
---@param layerName string The name of the layer in which the new region will be included.
|
|
||||||
---@param regionName string The name to be assigned to the region. The name must be unique for each region.
|
|
||||||
---@param def MapGen.RegionDef Region description table, see details `MapGen.RegionDef`
|
|
||||||
function MapGen:registerRegion(layerName, regionName, def)
|
|
||||||
if regionName == 'landscape_boundary' or
|
|
||||||
regionName == 'temp_boundary' or
|
|
||||||
regionName == 'humidity_boundary' then
|
|
||||||
error(('The name `%s` is reserved for special regions and cannot be used.'):format(regionName))
|
|
||||||
end
|
|
||||||
|
|
||||||
local layer = self:getLayerByName(layerName)
|
|
||||||
|
|
||||||
local region = Region:new(regionName, def)
|
|
||||||
|
|
||||||
layer:addRegion(regionName, region)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- --- INITIALIZATION METHODS ---
|
-- --- INITIALIZATION METHODS ---
|
||||||
|
|
||||||
---Initialize the boundary region for a layer and category.
|
---Initialize the boundary region for a layer and category.
|
||||||
@@ -536,7 +567,6 @@ function MapGen:initCavernsNoise()
|
|||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
for _, layer in ipairs(self.layersList) do
|
for _, layer in ipairs(self.layersList) do
|
||||||
|
|
||||||
---@param peak MapGen.Peak
|
|
||||||
for _, cavern in ipairs(layer.cavernsList) do
|
for _, cavern in ipairs(layer.cavernsList) do
|
||||||
cavern:initNoise()
|
cavern:initNoise()
|
||||||
end
|
end
|
||||||
@@ -551,36 +581,48 @@ end
|
|||||||
-- --- GENERATION METHODS ---
|
-- --- GENERATION METHODS ---
|
||||||
|
|
||||||
---@alias MapGen.nodeType 'AIR'|'WATER'|'CAVERN_AIR'|'TURF'|'SOIL'|'ROCK'|'BOTTOM'
|
---@alias MapGen.nodeType 'AIR'|'WATER'|'CAVERN_AIR'|'TURF'|'SOIL'|'ROCK'|'BOTTOM'
|
||||||
---@alias MapGen.postProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
---@alias MapGen.dataPostProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
||||||
|
---@alias MapGen.vmPostProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
||||||
|
|
||||||
---@type table<number, MapGen.postProcessingData>
|
|
||||||
local postProcessing = {}
|
---@type table<number, MapGen.dataPostProcessingData>
|
||||||
|
local dataPostProcessing = {}
|
||||||
|
---@type table<number, MapGen.vmPostProcessingData>
|
||||||
|
local vmPostProcessing = {}
|
||||||
|
|
||||||
---@param biome MapGen.Biome
|
---@param biome MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
---@param z integer
|
---@param z integer
|
||||||
---@param nodeType MapGen.nodeType
|
---@param nodeType MapGen.nodeType
|
||||||
local function addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, nodeType)
|
local function addPostProccessing(biome, mapGenerator, factors, index, x, y, z, nodeType)
|
||||||
if biome.postProcessing == nil then
|
if biome.dataPostProcessing ~= nil then
|
||||||
return
|
dataPostProcessing[index] = {
|
||||||
|
biome = biome,
|
||||||
|
mapGenerator = mapGenerator,
|
||||||
|
factors = factors,
|
||||||
|
index = index,
|
||||||
|
x = x,
|
||||||
|
y = y,
|
||||||
|
z = z,
|
||||||
|
nodeType = nodeType
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
postProcessing[index] = {
|
if biome.vmPostProcessing ~= nil then
|
||||||
biome = biome,
|
vmPostProcessing[index] = {
|
||||||
mapGenerator = mapGenerator,
|
biome = biome,
|
||||||
factors = factors,
|
mapGenerator = mapGenerator,
|
||||||
data = data,
|
factors = factors,
|
||||||
index = index,
|
x = x,
|
||||||
x = x,
|
y = y,
|
||||||
y = y,
|
z = z,
|
||||||
z = z,
|
nodeType = nodeType
|
||||||
nodeType = nodeType
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
||||||
@@ -589,11 +631,12 @@ end
|
|||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
---@param z integer
|
---@param z integer
|
||||||
local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
local function generateNode(mapGenerator, layer, factors, data, data2, index, x, y, z)
|
||||||
|
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
local waterLevel = layer.waterLevel
|
local waterLevel = layer.waterLevel
|
||||||
@@ -629,39 +672,39 @@ local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
|||||||
-- If the block is above surface height and above water level...
|
-- If the block is above surface height and above water level...
|
||||||
if y > height and y > waterLevel then
|
if y > height and y > waterLevel then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateAir(mapGenerator, factors, data, index, x, y, z)
|
biome:generateAir(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'AIR')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'AIR')
|
||||||
|
|
||||||
-- If the block is above the surface height BUT below the water level...
|
-- If the block is above the surface height BUT below the water level...
|
||||||
elseif y > height and y <= waterLevel then
|
elseif y > height and y <= waterLevel then
|
||||||
-- ... then underwater space is generated.
|
-- ... then underwater space is generated.
|
||||||
biome:generateWater(mapGenerator, factors, data, index, x, y, z)
|
biome:generateWater(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'WATER')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'WATER')
|
||||||
|
|
||||||
-- If the block is below the surface height...
|
-- If the block is below the surface height...
|
||||||
elseif y <= height then
|
elseif y <= height then
|
||||||
-- ... and a cavern is generated in the block...
|
-- ... and a cavern is generated in the block...
|
||||||
if mapGenerator:isCavern(layer, x, y, z) then
|
if mapGenerator:isCavern(layer, x, y, z) then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateCavernAir(mapGenerator, factors, data, index, x, y, z)
|
biome:generateCavernAir(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'CAVERN_AIR')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'CAVERN_AIR')
|
||||||
|
|
||||||
-- ... or if the surface height is above the water level...
|
-- ... or if the surface height is above the water level...
|
||||||
elseif height > waterLevel then
|
elseif height > waterLevel then
|
||||||
--- ... and the height of the block is equal to the height of the surface...
|
--- ... and the height of the block is equal to the height of the surface...
|
||||||
if y == height then
|
if y == height then
|
||||||
-- ... then turf is generated.
|
-- ... then turf is generated.
|
||||||
biome:generateTurf(mapGenerator, factors, data, index, x, y, z)
|
biome:generateTurf(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'TURF')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'TURF')
|
||||||
-- ... or if the height of the block falls within the thickness of the soil layer...
|
-- ... or if the height of the block falls within the thickness of the soil layer...
|
||||||
elseif y > height - biome.soilHeight then
|
elseif y > height - biome.soilHeight then
|
||||||
-- ... then soil is generated.
|
-- ... then soil is generated.
|
||||||
biome:generateSoil(mapGenerator, factors, data, index, x, y, z)
|
biome:generateSoil(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'SOIL')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'SOIL')
|
||||||
else
|
else
|
||||||
-- ... else a stone is generated.
|
-- ... else a stone is generated.
|
||||||
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
biome:generateRock(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'ROCK')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ... or if the surface height is below the water level...
|
-- ... or if the surface height is below the water level...
|
||||||
@@ -669,12 +712,12 @@ local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
|||||||
-- ... and if the height of the block falls within the thickness of the soil layer...
|
-- ... and if the height of the block falls within the thickness of the soil layer...
|
||||||
if y > height - biome.soilHeight then
|
if y > height - biome.soilHeight then
|
||||||
-- ... then the river/ocean bottom is generated.
|
-- ... then the river/ocean bottom is generated.
|
||||||
biome:generateBottom(mapGenerator, factors, data, index, x, y, z)
|
biome:generateBottom(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'BOTTOM')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'BOTTOM')
|
||||||
else
|
else
|
||||||
-- ... else a stone is generated.
|
-- ... else a stone is generated.
|
||||||
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
biome:generateRock(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'ROCK')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -767,7 +810,7 @@ end
|
|||||||
---@param z integer
|
---@param z integer
|
||||||
---@return number?, number?, number?
|
---@return number?, number?, number?
|
||||||
function MapGen:getFactors(layer, x, y, z)
|
function MapGen:getFactors(layer, x, y, z)
|
||||||
local posString = posToString({x=x,y=0,z=z})
|
local posString = corePosToString({x=x,y=0,z=z})
|
||||||
|
|
||||||
local factors = pastNoiseValues[layer.name][posString]
|
local factors = pastNoiseValues[layer.name][posString]
|
||||||
if factors ~= nil then
|
if factors ~= nil then
|
||||||
@@ -775,7 +818,7 @@ function MapGen:getFactors(layer, x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: это сильно тормозит обычные чанки, но ускоряет те, что находятся за границей
|
-- TODO: это сильно тормозит обычные чанки, но ускоряет те, что находятся за границей
|
||||||
if not self:pointInRegion2D(layer, 'triangles_boundary', {x=x, y=y, z=z}) then
|
if not self:pointInRegion2D(layer, 'triangles_boundary', v(x, y, z) --[[@as MapVector]]) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -789,7 +832,7 @@ function MapGen:getFactors(layer, x, y, z)
|
|||||||
|
|
||||||
---@param triangle MapGen.Triangle
|
---@param triangle MapGen.Triangle
|
||||||
for _, triangle in ipairs(triangles) do
|
for _, triangle in ipairs(triangles) do
|
||||||
if self:isPointInTriangle(triangle, v(x, 0, z)) then
|
if self:isPointInTriangle(triangle, v(x, 0, z) --[[@as MapVector]]) then
|
||||||
local height = calcNoise2dValue('landscape', layer, triangle, x, y, z)
|
local height = calcNoise2dValue('landscape', layer, triangle, x, y, z)
|
||||||
local temp = calcNoise2dValue('temp', layer, triangle, x, y, z)
|
local temp = calcNoise2dValue('temp', layer, triangle, x, y, z)
|
||||||
local humidity = calcNoise2dValue('humidity', layer, triangle, x, y, z)
|
local humidity = calcNoise2dValue('humidity', layer, triangle, x, y, z)
|
||||||
@@ -828,15 +871,16 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param layer MapGen.Layer?
|
---@param layer MapGen.Layer?
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
---@param z integer
|
---@param z integer
|
||||||
local function generatorHandler(mapGenerator, layer, data, index, x, y, z)
|
local function generatorHandler(mapGenerator, layer, data, data2, index, x, y, z)
|
||||||
-- If the node belongs to a static layer, then a static node is generated.
|
-- If the node belongs to a static layer, then a static node is generated.
|
||||||
local static = mapGenerator:getStaticByHeight(y)
|
local static = mapGenerator:getStaticByHeight(y)
|
||||||
if static ~= nil then
|
if static ~= nil then
|
||||||
static:generateStaticNode(mapGenerator, data, index, x, y, z)
|
static:generateStaticNode(mapGenerator, data, data2, index, x, y, z)
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -848,7 +892,7 @@ local function generatorHandler(mapGenerator, layer, data, index, x, y, z)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local endGetLayerTime = getUsTime()
|
local endGetLayerTime = coreGetUsTime()
|
||||||
local startNoiseCalcTime = endGetLayerTime
|
local startNoiseCalcTime = endGetLayerTime
|
||||||
-- If the value of the noise is `nil`,
|
-- If the value of the noise is `nil`,
|
||||||
-- then the point does not fall within any of the triangles.
|
-- then the point does not fall within any of the triangles.
|
||||||
@@ -870,16 +914,16 @@ local function generatorHandler(mapGenerator, layer, data, index, x, y, z)
|
|||||||
humidity = humidity,
|
humidity = humidity,
|
||||||
}
|
}
|
||||||
|
|
||||||
generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
generateNode(mapGenerator, layer, factors, data, data2, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Chunk generation handler.
|
---Chunk generation handler.
|
||||||
---@param voxelManip VoxelManip
|
---@param voxelManip VoxelManip
|
||||||
---@param minPos MapPosition
|
---@param minPos MapVector
|
||||||
---@param maxPos MapPosition
|
---@param maxPos MapVector
|
||||||
---@param blockseed number
|
---@param blockseed number
|
||||||
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||||
local minPosStr, maxPosStr = posToString(minPos), posToString(maxPos)
|
local minPosStr, maxPosStr = corePosToString(minPos), corePosToString(maxPos)
|
||||||
local startTime, endTime = 0.0, 0.0
|
local startTime, endTime = 0.0, 0.0
|
||||||
|
|
||||||
if LOG_PROFILE then
|
if LOG_PROFILE then
|
||||||
@@ -887,7 +931,7 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
|||||||
'min_pos: %s\n'..
|
'min_pos: %s\n'..
|
||||||
'max_pos: %s\n',
|
'max_pos: %s\n',
|
||||||
minPosStr, maxPosStr)
|
minPosStr, maxPosStr)
|
||||||
startTime = getUsTime()
|
startTime = coreGetUsTime()
|
||||||
end
|
end
|
||||||
|
|
||||||
local eMin, eMax = voxelManip:get_emerged_area()
|
local eMin, eMax = voxelManip:get_emerged_area()
|
||||||
@@ -900,7 +944,7 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
|||||||
self:initCavernsNoise()
|
self:initCavernsNoise()
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = voxelManip:get_data()
|
local data, data2 = voxelManip:get_data(), voxelManip:get_param2_data()
|
||||||
-- local param2_data = voxelManip:get_param2_data()
|
-- local param2_data = voxelManip:get_param2_data()
|
||||||
local area = VoxelArea:new({MinEdge = eMin, MaxEdge = eMax})
|
local area = VoxelArea:new({MinEdge = eMin, MaxEdge = eMax})
|
||||||
|
|
||||||
@@ -917,19 +961,19 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
|||||||
index = area:index(x, y, z)
|
index = area:index(x, y, z)
|
||||||
|
|
||||||
if data[index] == AIR_ID then
|
if data[index] == AIR_ID then
|
||||||
generatorHandler(self, layer, data, index, x, y, z)
|
generatorHandler(self, layer, data, data2, index, x, y, z)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Data post-proccesing generation
|
||||||
-- Post-proccesing generation
|
for _, ppdata in pairs(dataPostProcessing) do
|
||||||
for _, ppdata in pairs(postProcessing) do
|
if ppdata.biome.dataPostProcessing ~= nil then
|
||||||
if ppdata.biome.postProcessing ~= nil then
|
ppdata.biome:dataPostProcessing(ppdata.mapGenerator,
|
||||||
ppdata.biome:postProcessing(ppdata.mapGenerator,
|
|
||||||
ppdata.factors,
|
ppdata.factors,
|
||||||
ppdata.data,
|
data,
|
||||||
|
data2,
|
||||||
ppdata.index,
|
ppdata.index,
|
||||||
ppdata.x,
|
ppdata.x,
|
||||||
ppdata.y,
|
ppdata.y,
|
||||||
@@ -939,21 +983,32 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- We make changes back to LVM and recalculate light & liquids
|
|
||||||
voxelManip:set_data(data)
|
voxelManip:set_data(data)
|
||||||
|
voxelManip:set_param2_data(data2)
|
||||||
|
|
||||||
|
-- VoxelManip Post-proccesing generation
|
||||||
|
for _, ppdata in pairs(vmPostProcessing) do
|
||||||
|
if ppdata.biome.vmPostProcessing ~= nil then
|
||||||
|
ppdata.biome:vmPostProcessing(ppdata.mapGenerator,
|
||||||
|
ppdata.factors,
|
||||||
|
voxelManip,
|
||||||
|
ppdata.x,
|
||||||
|
ppdata.y,
|
||||||
|
ppdata.z,
|
||||||
|
ppdata.nodeType,
|
||||||
|
area)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
core.generate_ores(voxelManip, minPos, maxPos)
|
core.generate_ores(voxelManip, minPos, maxPos)
|
||||||
core.generate_decorations(voxelManip, minPos, maxPos)
|
core.generate_decorations(voxelManip, minPos, maxPos)
|
||||||
|
|
||||||
--voxelManip:set_param2_data()
|
|
||||||
voxelManip:set_lighting({ day = 14, night = 0})
|
voxelManip:set_lighting({ day = 14, night = 0})
|
||||||
voxelManip:calc_lighting()
|
voxelManip:calc_lighting()
|
||||||
voxelManip:update_liquids()
|
voxelManip:update_liquids()
|
||||||
|
|
||||||
pastTriangle = nil
|
|
||||||
|
|
||||||
if PROFILE_CHUNK then
|
if PROFILE_CHUNK then
|
||||||
endTime = getUsTime()
|
endTime = coreGetUsTime()
|
||||||
mglog('Chunk end:\n'..
|
mglog('Chunk end:\n'..
|
||||||
'min_pos: %s\n'..
|
'min_pos: %s\n'..
|
||||||
'max_pos: %s\n'..
|
'max_pos: %s\n'..
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ local id = core.get_content_id
|
|||||||
local getInstance = Class.getInstance
|
local getInstance = Class.getInstance
|
||||||
|
|
||||||
---@class MapGen.Biome
|
---@class MapGen.Biome
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field tempPoint number
|
---@field tempPoint number
|
||||||
---@field humidityPoint number
|
---@field humidityPoint number
|
||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field groundNodes MapGen.Biome.GroundNodes
|
---@field groundNodes MapGen.Biome.GroundNodes
|
||||||
---@field groundNodesIDs MapGen.Biome.GroundNodesIDs
|
---@field groundNodesIDs MapGen.Biome.GroundNodesIDs
|
||||||
---@field soilHeight number
|
---@field soilHeight number
|
||||||
|
---
|
||||||
---@field generateAir generateFunc
|
---@field generateAir generateFunc
|
||||||
---@field generateCavernAir generateFunc
|
---@field generateCavernAir generateFunc
|
||||||
---@field generateWater generateFunc
|
---@field generateWater generateFunc
|
||||||
@@ -18,21 +19,24 @@ local getInstance = Class.getInstance
|
|||||||
---@field generateTurf generateFunc
|
---@field generateTurf generateFunc
|
||||||
---@field generateSoil generateFunc
|
---@field generateSoil generateFunc
|
||||||
---@field generateBottom generateFunc
|
---@field generateBottom generateFunc
|
||||||
---@field postProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
---
|
||||||
|
---@field dataPostProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], data2:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
|
---@field vmPostProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, voxelManip:VoxelManip, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
local Biome = {}
|
local Biome = {}
|
||||||
|
|
||||||
---@alias generateFunc fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number)
|
---@alias generateFunc fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], data2:number[], index:number, x:number, y:number, z:number)
|
||||||
|
|
||||||
---Definition table for the `MapGen.Biome`.
|
---Definition table for the `MapGen.Biome`.
|
||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class MapGen.BiomeDef
|
---@class MapGen.BiomeDef
|
||||||
---@field tempPoint number
|
---@field tempPoint number
|
||||||
---@field humidityPoint number
|
---@field humidityPoint number
|
||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field groundNodes MapGen.Biome.GroundNodes
|
---@field groundNodes MapGen.Biome.GroundNodes
|
||||||
---@field soilHeight number
|
---@field soilHeight number
|
||||||
|
---
|
||||||
---@field generateAir generateFunc?
|
---@field generateAir generateFunc?
|
||||||
---@field generateCavernAir generateFunc?
|
---@field generateCavernAir generateFunc?
|
||||||
---@field generateWater generateFunc?
|
---@field generateWater generateFunc?
|
||||||
@@ -40,7 +44,9 @@ local Biome = {}
|
|||||||
---@field generateTurf generateFunc?
|
---@field generateTurf generateFunc?
|
||||||
---@field generateSoil generateFunc?
|
---@field generateSoil generateFunc?
|
||||||
---@field generateBottom generateFunc?
|
---@field generateBottom generateFunc?
|
||||||
---@field postProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
---
|
||||||
|
---@field dataPostProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], data2:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
|
---@field vmPostProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, voxelManip:VoxelManip, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
|
|
||||||
-- Default generate functions
|
-- Default generate functions
|
||||||
|
|
||||||
@@ -48,11 +54,12 @@ local Biome = {}
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateAir = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateAir = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
data[index] = mapGenerator.nodeIDs.air
|
data[index] = mapGenerator.nodeIDs.air
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -60,23 +67,25 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateCavernAir = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateCavernAir = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
self:generateAir(mapGenerator, factors, data, index, x, y, z)
|
self:generateAir(mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateWater = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateWater = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
data[index] = mapGenerator.nodeIDs.water
|
data[index] = mapGenerator.nodeIDs.water
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -84,11 +93,12 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateRock = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateRock = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.rock
|
data[index] = self.groundNodesIDs.rock
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -96,11 +106,12 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateTurf = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateTurf = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.turf
|
data[index] = self.groundNodesIDs.turf
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -108,11 +119,12 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateSoil = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateSoil = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.soil
|
data[index] = self.groundNodesIDs.soil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -120,11 +132,12 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param factors MapGen.factors
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateBottom = function(self, mapGenerator, factors, data, index, x, y, z)
|
local defaultGenerateBottom = function(self, mapGenerator, factors, data, data2, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.bottom
|
data[index] = self.groundNodesIDs.bottom
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -176,14 +189,15 @@ function Biome:new(name, def)
|
|||||||
|
|
||||||
---@type MapGen.Biome
|
---@type MapGen.Biome
|
||||||
local instance = getInstance(self, {})
|
local instance = getInstance(self, {})
|
||||||
instance.name = name
|
instance.name = name
|
||||||
instance.tempPoint = def.tempPoint
|
instance.tempPoint = def.tempPoint
|
||||||
instance.humidityPoint = def.humidityPoint
|
instance.humidityPoint = def.humidityPoint
|
||||||
instance.minY = def.minY
|
instance.minY = def.minY
|
||||||
instance.maxY = def.maxY
|
instance.maxY = def.maxY
|
||||||
instance.groundNodes = def.groundNodes
|
instance.groundNodes = def.groundNodes
|
||||||
instance.groundNodesIDs = groundNodesIDs
|
instance.groundNodesIDs = groundNodesIDs
|
||||||
instance.soilHeight = def.soilHeight
|
instance.soilHeight = def.soilHeight
|
||||||
|
|
||||||
instance.generateAir = def.generateAir
|
instance.generateAir = def.generateAir
|
||||||
instance.generateCavernAir = def.generateCavernAir
|
instance.generateCavernAir = def.generateCavernAir
|
||||||
instance.generateWater = def.generateWater
|
instance.generateWater = def.generateWater
|
||||||
@@ -191,7 +205,9 @@ function Biome:new(name, def)
|
|||||||
instance.generateSoil = def.generateSoil
|
instance.generateSoil = def.generateSoil
|
||||||
instance.generateTurf = def.generateTurf
|
instance.generateTurf = def.generateTurf
|
||||||
instance.generateBottom = def.generateBottom
|
instance.generateBottom = def.generateBottom
|
||||||
instance.postProcessing = def.postProcessing
|
|
||||||
|
instance.dataPostProcessing = def.dataPostProcessing
|
||||||
|
instance.vmPostProcessing = def.vmPostProcessing
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,31 +1,45 @@
|
|||||||
local mathMin, mathMax, mathAbs, mathClamp
|
local assert = assert
|
||||||
= math.min, math.max, math.abs, math.clamp
|
|
||||||
|
local mathMin, mathAbs, mathClamp
|
||||||
|
= math.min, math.abs, math.clamp
|
||||||
|
|
||||||
local getInstance = Class.getInstance
|
local getInstance = Class.getInstance
|
||||||
|
|
||||||
|
---@alias MapGen.Cavern.Type 'cheesed'|'warped'
|
||||||
|
|
||||||
---@class MapGen.Cavern
|
---@class MapGen.Cavern
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field isRegional boolean
|
---@field isRegional boolean?
|
||||||
|
---@field type MapGen.Cavern.Type
|
||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field smoothDistance number
|
---@field smoothDistance number
|
||||||
---@field threshold number
|
---@field threshold number
|
||||||
---@field getNoise fun():ValueNoise
|
---
|
||||||
---@field initNoise fun()
|
---@field step integer?
|
||||||
---@field getGroups fun():table<string, number>
|
---@field warpStrength number
|
||||||
|
---
|
||||||
|
---@field getNoise fun(self:MapGen.Cavern):MapGen.Cavern.ValueNoise
|
||||||
|
---@field initNoise fun(self:MapGen.Cavern)
|
||||||
local Cavern = {}
|
local Cavern = {}
|
||||||
|
|
||||||
|
---@alias MapGen.Cavern.NoiseParams {baseNoise:NoiseParams, xNoise?:NoiseParams, yNoise?:NoiseParams, zNoise?:NoiseParams}
|
||||||
|
---@alias MapGen.Cavern.ValueNoise {baseNoise:ValueNoise, xNoise?:ValueNoise, yNoise?:ValueNoise, zNoise?:ValueNoise}
|
||||||
|
|
||||||
---Definition table for the `MapGen.Cavern`.
|
---Definition table for the `MapGen.Cavern`.
|
||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class MapGen.CavernDef
|
---@class MapGen.CavernDef
|
||||||
---@field isRegional boolean?
|
---@field isRegional boolean?
|
||||||
|
---@field type MapGen.Cavern.Type
|
||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field noiseParams NoiseParams
|
---@field noiseParams MapGen.Cavern.NoiseParams
|
||||||
---@field smoothDistance number
|
---@field smoothDistance number
|
||||||
---@field threshold number?
|
---@field threshold number?
|
||||||
---@field groups table<string, number>?
|
---
|
||||||
|
---@field step integer?
|
||||||
|
---@field warpStrength number
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param def MapGen.CavernDef
|
---@param def MapGen.CavernDef
|
||||||
@@ -34,49 +48,41 @@ function Cavern:new(name, def)
|
|||||||
assert(def.maxY > def.minY, 'maxY there should be more minY')
|
assert(def.maxY > def.minY, 'maxY there should be more minY')
|
||||||
assert(def.smoothDistance < mathAbs(def.maxY - def.minY)/2, 'The smoothing distance cannot be greater than half the distance between minY and maxY')
|
assert(def.smoothDistance < mathAbs(def.maxY - def.minY)/2, 'The smoothing distance cannot be greater than half the distance between minY and maxY')
|
||||||
|
|
||||||
---@type NoiseParams
|
if def.type == 'warped' then
|
||||||
|
local noises = def.noiseParams
|
||||||
|
assert(def.step ~= nil, 'The cavern cannot be `warped` but has no `step`')
|
||||||
|
assert(def.warpStrength ~= nil, 'The cavern cannot be `warped` but has no `warpStrength`')
|
||||||
|
assert(noises.xNoise ~= nil, 'The cavern cannot be `warped` but has no `xNoise`')
|
||||||
|
assert(noises.yNoise ~= nil, 'The cavern cannot be `warped` but has no `yNoise`')
|
||||||
|
assert(noises.zNoise ~= nil, 'The cavern cannot be `warped` but has no `zNoise`')
|
||||||
|
end
|
||||||
|
|
||||||
|
---@type MapGen.Cavern.NoiseParams
|
||||||
local _noiseParams = def.noiseParams
|
local _noiseParams = def.noiseParams
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@type MapGen.Cavern.ValueNoise
|
||||||
---@type ValueNoise
|
|
||||||
local _noise = {} -- note: must be nil until luanti mapgen objects are loaded.
|
local _noise = {} -- note: must be nil until luanti mapgen objects are loaded.
|
||||||
|
|
||||||
if def.threshold == nil then
|
|
||||||
def.threshold = 0.1
|
|
||||||
end
|
|
||||||
|
|
||||||
local _groups
|
|
||||||
|
|
||||||
if def.groups == nil then
|
|
||||||
_groups = {}
|
|
||||||
else
|
|
||||||
_groups = def.groups
|
|
||||||
end
|
|
||||||
|
|
||||||
---@type MapGen.Cavern
|
---@type MapGen.Cavern
|
||||||
local instance = getInstance(self, {
|
local instance = getInstance(self, {})
|
||||||
name = name,
|
instance.name = name
|
||||||
minY = def.minY,
|
instance.isRegional = def.isRegional
|
||||||
maxY = def.maxY,
|
instance.type = def.type
|
||||||
smoothDistance = def.smoothDistance,
|
instance.minY = def.minY
|
||||||
threshold = def.threshold,
|
instance.maxY = def.maxY
|
||||||
isRegional = def.isRegional or false,
|
instance.smoothDistance = def.smoothDistance
|
||||||
})
|
instance.threshold = def.threshold or 0.1
|
||||||
|
instance.step = def.step
|
||||||
|
instance.warpStrength = def.warpStrength
|
||||||
|
|
||||||
function instance:getNoise()
|
function instance:getNoise()
|
||||||
return _noise
|
return _noise
|
||||||
end
|
end
|
||||||
|
|
||||||
function instance:initNoise()
|
function instance:initNoise()
|
||||||
if not table.is_empty(_noise) then
|
for noiseName, noiseParams in pairs(_noiseParams) do
|
||||||
minetest.log('warning', 'Cavern noise has already been initialized. Re-initialization is not recommended.')
|
_noise[noiseName] = core.get_value_noise(_noiseParams[noiseName])
|
||||||
end
|
end
|
||||||
|
|
||||||
_noise = core.get_value_noise(_noiseParams)
|
|
||||||
end
|
|
||||||
|
|
||||||
function instance:getGroups()
|
|
||||||
return table.copy_with_metatables(_groups)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
@@ -88,6 +94,40 @@ function Cavern:calcCavernWeight(distance)
|
|||||||
return mathClamp(distance / self.smoothDistance, 0, 1)
|
return mathClamp(distance / self.smoothDistance, 0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
---@param weight number
|
||||||
|
---@return boolean
|
||||||
|
function Cavern:isCheesedCavern(x, y, z, weight)
|
||||||
|
local noises = self:getNoise()
|
||||||
|
|
||||||
|
return noises.baseNoise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
---@param weight number
|
||||||
|
---@return boolean
|
||||||
|
function Cavern:isWarpedCavern(x, y, z, weight)
|
||||||
|
local noises = self:getNoise()
|
||||||
|
assert(noises.xNoise ~= nil and noises.yNoise ~= nil and noises.zNoise ~= nil )
|
||||||
|
local warpX = noises.xNoise:get_3d({x = x, y = y, z = z})
|
||||||
|
local warpY = noises.yNoise:get_3d({x = x, y = y, z = z})
|
||||||
|
local warpZ = noises.zNoise:get_3d({x = x, y = y, z = z})
|
||||||
|
|
||||||
|
local warpStrength = self.warpStrength
|
||||||
|
|
||||||
|
local warpedX = x + warpX * warpStrength
|
||||||
|
local warpedY = y + warpY * warpStrength
|
||||||
|
local warpedZ = z + warpZ * warpStrength
|
||||||
|
|
||||||
|
local value = noises.baseNoise:get_3d({x = warpedX, y = warpedY, z = warpedZ})
|
||||||
|
|
||||||
|
return value * weight > self.threshold
|
||||||
|
end
|
||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
@@ -103,10 +143,15 @@ function Cavern:isCavern(x, y, z, distance)
|
|||||||
|
|
||||||
distance = mathMin(maxY - y, y - minY, distance)
|
distance = mathMin(maxY - y, y - minY, distance)
|
||||||
|
|
||||||
local noise = self:getNoise()
|
|
||||||
local weight = self:calcCavernWeight(distance)
|
local weight = self:calcCavernWeight(distance)
|
||||||
|
|
||||||
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
if self.type == 'warped' then
|
||||||
|
return self:isWarpedCavern(x, y, z, weight)
|
||||||
|
elseif self.type == 'cheesed' then
|
||||||
|
return self:isCheesedCavern(x, y, z, weight)
|
||||||
|
else
|
||||||
|
error(('unknown type of cave `%s`'):format(self.type))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
@@ -123,10 +168,15 @@ function Cavern:isLayeredCavern(x, y, z)
|
|||||||
|
|
||||||
local distance = mathMin(maxY - y, y - minY)
|
local distance = mathMin(maxY - y, y - minY)
|
||||||
|
|
||||||
local noise = self:getNoise()
|
|
||||||
local weight = self:calcCavernWeight(distance)
|
local weight = self:calcCavernWeight(distance)
|
||||||
|
|
||||||
return noise:get_3d({x = x, y = y, z = z}) * weight > self.threshold
|
if self.type == 'warped' then
|
||||||
|
return self:isWarpedCavern(x, y, z, weight)
|
||||||
|
elseif self.type == 'cheesed' then
|
||||||
|
return self:isCheesedCavern(x, y, z, weight)
|
||||||
|
else
|
||||||
|
error(('unknown type of cave `%s`'):format(self.type))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Cavern
|
return Cavern
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ local FakePeak = Class.extend(Peak, {})
|
|||||||
|
|
||||||
---Returns a fake `MapGen.Peak` that has no noise parameters.
|
---Returns a fake `MapGen.Peak` that has no noise parameters.
|
||||||
---Note that the initialized peak should not be used in generation.
|
---Note that the initialized peak should not be used in generation.
|
||||||
---@param peakPos MapPosition|vector
|
---@param peakPos MapVector
|
||||||
---@return MapGen.Peak
|
---@return MapGen.Peak
|
||||||
function FakePeak:new(peakPos)
|
function FakePeak:new(peakPos)
|
||||||
local instance = Peak:new({pos = peakPos, color = '#000000'})
|
local instance = Peak:new({pos = peakPos, color = '#000000'})
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ local Layer = {
|
|||||||
---@field triangulationLandscapeFile string
|
---@field triangulationLandscapeFile string
|
||||||
---@field triangulationTempFile string
|
---@field triangulationTempFile string
|
||||||
---@field triangulationHumidityFile string
|
---@field triangulationHumidityFile string
|
||||||
---@field landscapeMapScale number
|
---@field landscapeMapScale integer
|
||||||
---@field tempMapScale number
|
---@field tempMapScale integer
|
||||||
---@field humidityMapScale number
|
---@field humidityMapScale integer
|
||||||
|
|
||||||
---@param self MapGen.Layer
|
---@param self MapGen.Layer
|
||||||
---@param value number
|
---@param value number
|
||||||
@@ -91,7 +91,7 @@ end
|
|||||||
---**Note:** If the colors of the new peak and the existing one at the same coordinates
|
---**Note:** If the colors of the new peak and the existing one at the same coordinates
|
||||||
---are different, an error will be called.
|
---are different, an error will be called.
|
||||||
---@param def MapGen.PeakDef
|
---@param def MapGen.PeakDef
|
||||||
---@param scale number
|
---@param scale integer
|
||||||
---@return MapGen.Peak
|
---@return MapGen.Peak
|
||||||
function Layer:registerPeak(def, scale)
|
function Layer:registerPeak(def, scale)
|
||||||
assert(def.pos ~= nil)
|
assert(def.pos ~= nil)
|
||||||
@@ -130,7 +130,7 @@ end
|
|||||||
|
|
||||||
---@param fileName string
|
---@param fileName string
|
||||||
---@param category MapGen.Layer.Category
|
---@param category MapGen.Layer.Category
|
||||||
---@param scale number
|
---@param scale integer
|
||||||
function Layer:getTriaglesFromFile(fileName, category, scale)
|
function Layer:getTriaglesFromFile(fileName, category, scale)
|
||||||
local file = io.open(core.get_modpath(core.get_current_modname())..'/maps/'..fileName, 'r')
|
local file = io.open(core.get_modpath(core.get_current_modname())..'/maps/'..fileName, 'r')
|
||||||
assert(file ~= nil)
|
assert(file ~= nil)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ local Peak = {
|
|||||||
---
|
---
|
||||||
---**Only for EmmyLua.**
|
---**Only for EmmyLua.**
|
||||||
---@class MapGen.PeakDef
|
---@class MapGen.PeakDef
|
||||||
---@field pos MapPosition|vector
|
---@field pos MapVector
|
||||||
---@field color ColorString
|
---@field color ColorString
|
||||||
---@field groups? table<string, number>
|
---@field groups? table<string, number>
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ function Peak:new(def)
|
|||||||
if def.groups == nil then
|
if def.groups == nil then
|
||||||
_groups = {}
|
_groups = {}
|
||||||
else
|
else
|
||||||
|
---@type table<string, number>
|
||||||
_groups = def.groups
|
_groups = def.groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ local getInstance = Class.getInstance
|
|||||||
|
|
||||||
---@class MapGen.Region
|
---@class MapGen.Region
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field vertices MapPosition[]
|
---@field vertices MapVector[]
|
||||||
local Region = {}
|
local Region = {}
|
||||||
|
|
||||||
---@class MapGen.RegionDef
|
---@class MapGen.RegionDef
|
||||||
---@field vertices MapPosition[]
|
---@field vertices MapVector[]
|
||||||
|
|
||||||
---@param def MapGen.RegionDef
|
---@param def MapGen.RegionDef
|
||||||
---@return MapGen.Region
|
---@return MapGen.Region
|
||||||
@@ -50,7 +50,7 @@ local function calcDistanceSq(px, pz, x1, z1, x2, z2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Checks if a point is inside a `MapGen.Region` (2D check using x and z coordinates).
|
---Checks if a point is inside a `MapGen.Region` (2D check using x and z coordinates).
|
||||||
---@param point MapPosition
|
---@param point MapVector
|
||||||
---@return boolean, number?
|
---@return boolean, number?
|
||||||
function Region:pointInRegion(point)
|
function Region:pointInRegion(point)
|
||||||
local vertices = self.vertices
|
local vertices = self.vertices
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local getInstance = Class.getInstance
|
|||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field staticNode string
|
---@field staticNode string
|
||||||
---@field staticNodeID number
|
---@field staticNodeID number
|
||||||
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], data2:number[], index:number, x:number, y:number, z:number)
|
||||||
local StaticLayer = {}
|
local StaticLayer = {}
|
||||||
|
|
||||||
---Definition table for the `MapGen.StaticLayer`.
|
---Definition table for the `MapGen.StaticLayer`.
|
||||||
@@ -18,16 +18,17 @@ local StaticLayer = {}
|
|||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field staticNode string
|
---@field staticNode string
|
||||||
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], data2:number[], index:number, x:number, y:number, z:number)
|
||||||
|
|
||||||
---@param self MapGen.StaticLayer
|
---@param self MapGen.StaticLayer
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
|
---@param data2 number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateStaticNode = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateStaticNode = function(self, mapGenerator, data, data2, index, x, y, z)
|
||||||
data[index] = self.staticNodeID
|
data[index] = self.staticNodeID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
131
mods/CORE/MapGen/src/MapGen/Tree.lua
Normal file
131
mods/CORE/MapGen/src/MapGen/Tree.lua
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
local v = vector.new
|
||||||
|
local mathFloor = math.floor
|
||||||
|
local corePlaceSchematic, corePlaceSchematicOnVM, coreEmergeArea = core.place_schematic, core.place_schematic_on_vmanip, core.emerge_area
|
||||||
|
local CONTENT_IGNORE = core.CONTENT_IGNORE
|
||||||
|
local VoxelManip, VoxelArea = VoxelManip, VoxelArea
|
||||||
|
|
||||||
|
local Node
|
||||||
|
|
||||||
|
if not Smc.isAsync then
|
||||||
|
Node = Smc.requireNode()
|
||||||
|
end
|
||||||
|
|
||||||
|
local getInstance = Class.getInstance
|
||||||
|
|
||||||
|
---@class MapGen.Tree
|
||||||
|
---@field name string
|
||||||
|
---@field path string
|
||||||
|
---@field placerName string
|
||||||
|
local Tree = {}
|
||||||
|
|
||||||
|
---Definition table for the `MapGen.Tree`.
|
||||||
|
---
|
||||||
|
---**Only for EmmyLua.**
|
||||||
|
---@class MapGen.TreeDef
|
||||||
|
---@field path string
|
||||||
|
|
||||||
|
---@param name string
|
||||||
|
---@param def MapGen.TreeDef
|
||||||
|
---@return MapGen.Tree
|
||||||
|
function Tree:new(name, def)
|
||||||
|
local intance = getInstance(self, {})
|
||||||
|
intance.name = name
|
||||||
|
intance.path = def.path
|
||||||
|
intance.placerName = Mod.getInfo().shortName..':'..name..'_placer'
|
||||||
|
|
||||||
|
intance:registerPlacer()
|
||||||
|
|
||||||
|
return intance
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return Node?
|
||||||
|
function Tree:registerPlacer()
|
||||||
|
if Node == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local node = Node:new({
|
||||||
|
settings = {
|
||||||
|
name = self.name..'_placer'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
self.placerName = node.itemDef.settings.name
|
||||||
|
|
||||||
|
core.register_abm({
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
nodenames = {node.itemDef.settings.name},
|
||||||
|
action = function(pos, node, dtime)
|
||||||
|
self:place(pos)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param pos MapVector
|
||||||
|
---@return '0'|'90'|'180'|'270
|
||||||
|
local function getRotation(pos)
|
||||||
|
local rotation = mathFloor((pos.x + pos.y + pos.z) % 4)
|
||||||
|
|
||||||
|
if rotation == 0 then
|
||||||
|
return '0'
|
||||||
|
elseif rotation == 1 then
|
||||||
|
return '90'
|
||||||
|
elseif rotation == 2 then
|
||||||
|
return '180'
|
||||||
|
elseif rotation == 3 then
|
||||||
|
return '270'
|
||||||
|
else
|
||||||
|
error()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param pos1 MapVector
|
||||||
|
---@param pos2 MapVector
|
||||||
|
---@return boolean
|
||||||
|
local function isAreaGenerated(pos1, pos2)
|
||||||
|
local voxelManip = VoxelManip(pos1, pos2)
|
||||||
|
local eMin, eMax = voxelManip:get_emerged_area()
|
||||||
|
local area = VoxelArea:new({MinEdge = eMin, MaxEdge = eMax})
|
||||||
|
|
||||||
|
local index
|
||||||
|
local data = voxelManip:get_data()
|
||||||
|
for z = pos1.z, pos2.z, 16 do
|
||||||
|
for y = pos1.y, pos2.y, 16 do
|
||||||
|
for x = pos1.x, pos2.x, 16 do
|
||||||
|
index = area:index(x, y, z)
|
||||||
|
|
||||||
|
if data[index] == CONTENT_IGNORE then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param pos MapVector
|
||||||
|
function Tree:place(pos)
|
||||||
|
local pos1, pos2 = pos - v(16, 0, 16), pos + v(16, 80, 16) --[[@as MapVector]]
|
||||||
|
|
||||||
|
if isAreaGenerated(pos1, pos2) then
|
||||||
|
corePlaceSchematic(pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z')
|
||||||
|
else
|
||||||
|
coreEmergeArea(pos1, pos2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param voxelManip VoxelManip
|
||||||
|
---@param pos MapVector
|
||||||
|
function Tree:placeOnVM(voxelManip, pos)
|
||||||
|
local result = corePlaceSchematicOnVM(voxelManip, pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z')
|
||||||
|
|
||||||
|
if not result then
|
||||||
|
voxelManip:set_node_at(pos, {name = self.placerName, force_place = true})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return Tree
|
||||||
@@ -181,7 +181,7 @@ function Triangle:getHeight(p1, p2, p3)
|
|||||||
-- When * the dot product.
|
-- When * the dot product.
|
||||||
local t = w:dot(v) / v:dot(v)
|
local t = w:dot(v) / v:dot(v)
|
||||||
|
|
||||||
local posP = pos2 + v * t
|
local posP = pos2 + v * t --[[@as IntegerVector]]
|
||||||
|
|
||||||
return Edge:new(p1, FakePeak:new(posP))
|
return Edge:new(p1, FakePeak:new(posP))
|
||||||
end
|
end
|
||||||
@@ -211,7 +211,7 @@ function Triangle:getHeight2D(p1, p2, p3)
|
|||||||
-- When * the dot product.
|
-- When * the dot product.
|
||||||
local t = w:dot(v) / v:dot(v)
|
local t = w:dot(v) / v:dot(v)
|
||||||
|
|
||||||
local posP = pos2 + v * t
|
local posP = pos2 + v * t --[[@as IntegerVector]]
|
||||||
|
|
||||||
return Edge:new(p1, FakePeak:new(posP))
|
return Edge:new(p1, FakePeak:new(posP))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
-- A method for converting an image with colored dots (pixels) into a Lua table grouped by color.
|
|
||||||
-- Author: @ssdaniel24 (github)
|
|
||||||
|
|
||||||
---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}, ... },
|
|
||||||
--- ...
|
|
||||||
---}
|
|
||||||
---```
|
|
||||||
---@alias ColoredDotsTable table<string,table>
|
|
||||||
|
|
||||||
---@param uintb string unsigned int bytes
|
|
||||||
---@return number
|
|
||||||
local function uintb2num(uintb)
|
|
||||||
local num = 0
|
|
||||||
local len = string.len(uintb)
|
|
||||||
|
|
||||||
for i = 1,len do
|
|
||||||
num = num*256 + string.byte(uintb, i)
|
|
||||||
end
|
|
||||||
|
|
||||||
return num
|
|
||||||
end
|
|
||||||
|
|
||||||
---Converts (scaling) 16-bit unsigned integer to 8-bit unsigned integer.
|
|
||||||
---Why? Because hex codes of colors are 8-bit: #ffffff -> ff = 256 (8 bit). Not 65536 (16 bit).
|
|
||||||
---@param num number 16-bit number
|
|
||||||
---@return number 8-bit number
|
|
||||||
local function uint16ToUint8(num)
|
|
||||||
return math.floor(num / 256)
|
|
||||||
end
|
|
||||||
|
|
||||||
---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/)
|
|
||||||
---@param filepath string image in farbfeld format
|
|
||||||
---@param backgroundColor string? ColorString, will be ignored while processing image. Default: `#000000FF`
|
|
||||||
---@return ColoredDotsTable
|
|
||||||
local function ff2luat(filepath, backgroundColor)
|
|
||||||
local file = io.open(filepath, 'rb')
|
|
||||||
if not file then error('Can\'t open farbfeld image: ' .. dump(filepath)) end
|
|
||||||
local ff = file:read('*a') -- binary!
|
|
||||||
file:close()
|
|
||||||
-- TODO: make it decompressing gzip format -> https://en.wikipedia.org/wiki/Gzip
|
|
||||||
-- I should skip 10 bytes in a beginning, read how many extra fields after it, skip them too, and skip last 8 bytes
|
|
||||||
-- (read wiki for information).
|
|
||||||
-- if filepath:sub(-3) == '.gz' then ff = core.decompress(ff, 'deflate') end
|
|
||||||
if not ff:sub(1,8) == 'farbfeld' then error('Not farbfeld image: ' .. dump(filepath)) end
|
|
||||||
|
|
||||||
if not backgroundColor then backgroundColor = '#000000FF' end
|
|
||||||
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
|
|
||||||
backgroundColor = Smc.fixColorString(backgroundColor)
|
|
||||||
|
|
||||||
---@type ColoredDotsTable
|
|
||||||
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
|
|
||||||
|
|
||||||
local cursor
|
|
||||||
for i = 1,dots.size.h do
|
|
||||||
for j = 1,dots.size.w do
|
|
||||||
cursor = 16 + ((i-1)*dots.size.w + j-1)*8 + 1
|
|
||||||
local colorT = {
|
|
||||||
r = uint16ToUint8(uintb2num(ff:sub(cursor, cursor+1))),
|
|
||||||
g = uint16ToUint8(uintb2num(ff:sub(cursor+2,cursor+3))),
|
|
||||||
b = uint16ToUint8(uintb2num(ff:sub(cursor+4,cursor+5))),
|
|
||||||
a = uint16ToUint8(uintb2num(ff:sub(cursor+6,cursor+7)))
|
|
||||||
}
|
|
||||||
|
|
||||||
---@type string @ColorString
|
|
||||||
local color = core.colorspec_to_colorstring(colorT) or ''
|
|
||||||
|
|
||||||
if color ~= backgroundColor then
|
|
||||||
if not dots[color] then
|
|
||||||
dots[color] = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(dots[color], { x=j, y=i })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return dots
|
|
||||||
end
|
|
||||||
|
|
||||||
return ff2luat
|
|
||||||
@@ -1,25 +1,95 @@
|
|||||||
|
local tableMerge = table.merge
|
||||||
|
|
||||||
local Item, ItemFactory = Smc.requireItem(), Smc.requireItemFactory()
|
local Item, ItemFactory = Smc.requireItem(), Smc.requireItemFactory()
|
||||||
|
|
||||||
---@class Node : Item
|
---@class Node : Item
|
||||||
---@field defaultDef Node.NodeDefinition
|
---@field defaultDef Node.NodeDefinition
|
||||||
local Node = Class.extend(Item, {})
|
local Node = Item:extend({})
|
||||||
|
|
||||||
---The alias `table.merge` for EmmyLua
|
---@param nodeDef Node.NodeDefinition
|
||||||
---@type fun(...):(Node.NodeDefinition)
|
local function registerSlab(nodeDef)
|
||||||
local defMerge = function(...)
|
nodeDef = table.copy_with_metatables(nodeDef)
|
||||||
return table.merge(...)
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
---@param nodeDef Node.NodeDefinition
|
---@param nodeDef Node.NodeDefinition
|
||||||
---@return Node
|
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)
|
function Node:new(nodeDef)
|
||||||
---Adding default parameters
|
-- Adding default parameters.
|
||||||
nodeDef = defMerge(nodeDef, self.defaultDef, true)
|
nodeDef = tableMerge(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
|
||||||
|
|
||||||
|
local instance = Item:new(nodeDef) --[[@as Node]]
|
||||||
|
|
||||||
---@type Node
|
|
||||||
local instance = Item:new(nodeDef)
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -29,10 +99,10 @@ end
|
|||||||
---@param defaultDef Node.NodeDefinition
|
---@param defaultDef Node.NodeDefinition
|
||||||
---@return Node
|
---@return Node
|
||||||
function Node:getExtended(defaultDef)
|
function Node:getExtended(defaultDef)
|
||||||
defaultDef = defMerge(defaultDef, self.defaultDef)
|
defaultDef = tableMerge(defaultDef, self.defaultDef, true)
|
||||||
|
|
||||||
---@type Node
|
---@type Node
|
||||||
local ChildClass = Class.extend(self, {
|
local ChildClass = self:extend({
|
||||||
defaultDef = defaultDef,
|
defaultDef = defaultDef,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -46,7 +116,7 @@ function Node:getFactory(defaultDef)
|
|||||||
if defaultDef == nil then
|
if defaultDef == nil then
|
||||||
defaultDef = self.defaultDef
|
defaultDef = self.defaultDef
|
||||||
else
|
else
|
||||||
defaultDef = defMerge(self.defaultDef, defaultDef)
|
defaultDef = tableMerge(self.defaultDef, defaultDef, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type ItemFactory
|
---@type ItemFactory
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local Callbacks = Class.extend(ItemCallbacks, {})
|
|||||||
---
|
---
|
||||||
---default: nil
|
---default: nil
|
||||||
---* `pos`: node position
|
---* `pos`: node position
|
||||||
---@type fun(pos:Position)?
|
---@type fun(pos:MapVector)?
|
||||||
Callbacks.on_construct = nil
|
Callbacks.on_construct = nil
|
||||||
|
|
||||||
---Node destructor; called before removing node.
|
---Node destructor; called before removing node.
|
||||||
@@ -21,7 +21,7 @@ Callbacks.on_construct = nil
|
|||||||
---
|
---
|
||||||
---default: nil
|
---default: nil
|
||||||
---* `pos`: node position
|
---* `pos`: node position
|
||||||
---@type fun(pos:Position)?
|
---@type fun(pos:MapVector)?
|
||||||
Callbacks.on_destruct = nil
|
Callbacks.on_destruct = nil
|
||||||
|
|
||||||
---Node destructor; called after removing node.
|
---Node destructor; called after removing node.
|
||||||
@@ -30,7 +30,7 @@ Callbacks.on_destruct = nil
|
|||||||
---default: nil
|
---default: nil
|
||||||
---* `pos`: node position
|
---* `pos`: node position
|
||||||
---* `oldnode`: node table of node before it was deleted
|
---* `oldnode`: node table of node before it was deleted
|
||||||
---@type fun(pos:Position, old_node)?
|
---@type fun(pos:MapVector, old_node)?
|
||||||
Callbacks.after_destruct = nil
|
Callbacks.after_destruct = nil
|
||||||
|
|
||||||
---Called when a liquid (newnode) is about to flood oldnode, if it has
|
---Called when a liquid (newnode) is about to flood oldnode, if it has
|
||||||
@@ -45,7 +45,7 @@ Callbacks.after_destruct = nil
|
|||||||
---* `pos`: table node position
|
---* `pos`: table node position
|
||||||
---* `oldnode`: table node table of node before it was deleted
|
---* `oldnode`: table node table of node before it was deleted
|
||||||
---* `newnode`: TODO: какой тут тип?
|
---* `newnode`: TODO: какой тут тип?
|
||||||
---@type fun(pos:Position, old_node, new_node)?
|
---@type fun(pos:MapVector, old_node, new_node)?
|
||||||
Callbacks.on_flood = nil
|
Callbacks.on_flood = nil
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ Callbacks.on_flood = nil
|
|||||||
---* `drops`: a table of `ItemStack`s, so any metadata to be preserved can
|
---* `drops`: a table of `ItemStack`s, so any metadata to be preserved can
|
||||||
--- be added directly to one or more of the dropped items. See
|
--- be added directly to one or more of the dropped items. See
|
||||||
--- "ItemStackMetaRef".
|
--- "ItemStackMetaRef".
|
||||||
---@type fun(pos:Position, old_node, new_node, old_meta, drops:ItemStack[])?
|
---@type fun(pos:MapVector, old_node, new_node, old_meta, drops:ItemStack[])?
|
||||||
Callbacks.preserve_metadata = nil
|
Callbacks.preserve_metadata = nil
|
||||||
|
|
||||||
---Called after constructing node when node was placed using
|
---Called after constructing node when node was placed using
|
||||||
@@ -73,7 +73,7 @@ Callbacks.preserve_metadata = nil
|
|||||||
---* `placer`: may be any valid ObjectRef or nil
|
---* `placer`: may be any valid ObjectRef or nil
|
||||||
---* `itemstack`: TODO: сделать описание
|
---* `itemstack`: TODO: сделать описание
|
||||||
---* `pointed_thing`: Vector of the direction of the gaze of the person who placed the block
|
---* `pointed_thing`: Vector of the direction of the gaze of the person who placed the block
|
||||||
---@type fun(pos:Position, placer:Player|ObjectRef|nil, itemstack:ItemStack, pointed_thing:pointed_thing)?
|
---@type fun(pos:MapVector, placer:Player|ObjectRef|nil, itemstack:ItemStack, pointed_thing:pointed_thing)?
|
||||||
Callbacks.after_place_node = nil
|
Callbacks.after_place_node = nil
|
||||||
|
|
||||||
---Called after destructing the node when node was dug using
|
---Called after destructing the node when node was dug using
|
||||||
@@ -92,7 +92,7 @@ Callbacks.after_dig_node = nil
|
|||||||
---default: nil
|
---default: nil
|
||||||
---* `pos`: node position
|
---* `pos`: node position
|
||||||
---* player: ObjectRef of digger
|
---* player: ObjectRef of digger
|
||||||
---@type fun(pos:Position, player:Player|ObjectRef|nil)?
|
---@type fun(pos:MapVector, player:Player|ObjectRef|nil)?
|
||||||
Callbacks.can_dig = nil
|
Callbacks.can_dig = nil
|
||||||
|
|
||||||
---Called when puncher (an ObjectRef) punches the node at pos.
|
---Called when puncher (an ObjectRef) punches the node at pos.
|
||||||
@@ -103,7 +103,7 @@ Callbacks.can_dig = nil
|
|||||||
---* `node`: node being hit
|
---* `node`: node being hit
|
||||||
---* `puncher`: ObjectRef of punch
|
---* `puncher`: ObjectRef of punch
|
||||||
---* `pointed_thing`: Vector of the direction of the gaze of the person who placed the block
|
---* `pointed_thing`: Vector of the direction of the gaze of the person who placed the block
|
||||||
---@type fun(pos:Position, node:NodeTable, puncher:Player|ObjectRef|nil, pointed_thing:pointed_thing)?
|
---@type fun(pos:MapVector, node:NodeTable, puncher:Player|ObjectRef, pointed_thing:pointed_thing)?
|
||||||
Callbacks.on_punch = nil
|
Callbacks.on_punch = nil
|
||||||
|
|
||||||
---Called when clicker (an ObjectRef) used the 'place/build' key
|
---Called when clicker (an ObjectRef) used the 'place/build' key
|
||||||
@@ -115,7 +115,7 @@ Callbacks.on_punch = nil
|
|||||||
---Note: pointed_thing can be nil, if a mod calls this function.
|
---Note: pointed_thing can be nil, if a mod calls this function.
|
||||||
---
|
---
|
||||||
---default: nil
|
---default: nil
|
||||||
---@type (fun(pos:Position, node:NodeTable, clicker:Player|ObjectRef, itemstack:ItemStack, pointed_thing:pointed_thing|nil):ItemStack|nil)?
|
---@type (fun(pos:MapVector, node:NodeTable, clicker:Player|ObjectRef, itemstack:ItemStack, pointed_thing:pointed_thing|nil):ItemStack|nil)?
|
||||||
Callbacks.on_rightclick = core.node_punch
|
Callbacks.on_rightclick = core.node_punch
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ Callbacks.on_rightclick = core.node_punch
|
|||||||
---Deprecated: returning nil is the same as returning true.
|
---Deprecated: returning nil is the same as returning true.
|
||||||
---
|
---
|
||||||
---default: core.node_dig
|
---default: core.node_dig
|
||||||
---@type (fun(pos:Position, node:NodeTable, digger:Player): boolean)?
|
---@type (fun(pos:MapVector, node:NodeTable, digger:Player): boolean)?
|
||||||
Callbacks.on_dig = minetest.node_dig
|
Callbacks.on_dig = minetest.node_dig
|
||||||
|
|
||||||
---called by NodeTimers, see core.get_node_timer and NodeTimerRef.
|
---called by NodeTimers, see core.get_node_timer and NodeTimerRef.
|
||||||
@@ -134,7 +134,7 @@ Callbacks.on_dig = minetest.node_dig
|
|||||||
---return true to run the timer for another cycle with the same timeout value.
|
---return true to run the timer for another cycle with the same timeout value.
|
||||||
---
|
---
|
||||||
---default: nil
|
---default: nil
|
||||||
---@type (fun(pos:Position, elapsed:number): boolean)?
|
---@type (fun(pos:MapVector, elapsed:number, node:NodeTable, timeout:number):boolean?)?
|
||||||
Callbacks.on_timer = nil
|
Callbacks.on_timer = nil
|
||||||
|
|
||||||
---fields = {name1 = value1, name2 = value2, ...}
|
---fields = {name1 = value1, name2 = value2, ...}
|
||||||
@@ -144,7 +144,7 @@ Callbacks.on_timer = nil
|
|||||||
---See `core.register_on_player_receive_fields` for more info.
|
---See `core.register_on_player_receive_fields` for more info.
|
||||||
---
|
---
|
||||||
---default: nil
|
---default: nil
|
||||||
---@type fun(pos:Position, formname:string, fields:table, sender:Player)?
|
---@type fun(pos:MapVector, formname:string, fields:table, sender:Player)?
|
||||||
Callbacks.on_receive_fields = nil
|
Callbacks.on_receive_fields = nil
|
||||||
|
|
||||||
---Called when a player wants to put something into the inventory.
|
---Called when a player wants to put something into the inventory.
|
||||||
@@ -152,7 +152,7 @@ Callbacks.on_receive_fields = nil
|
|||||||
---Return value: number of items allowed to put.
|
---Return value: number of items allowed to put.
|
||||||
---
|
---
|
||||||
---Return value -1: Allow and don't modify item count in inventory.
|
---Return value -1: Allow and don't modify item count in inventory.
|
||||||
---@type (fun(pos:Position, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): number)?
|
---@type (fun(pos:MapVector, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): number)?
|
||||||
Callbacks.allow_metadata_inventory_move = nil
|
Callbacks.allow_metadata_inventory_move = nil
|
||||||
|
|
||||||
---Called when a player wants to take something out of the inventory.
|
---Called when a player wants to take something out of the inventory.
|
||||||
@@ -160,31 +160,31 @@ Callbacks.allow_metadata_inventory_move = nil
|
|||||||
---Return value: number of items allowed to take.
|
---Return value: number of items allowed to take.
|
||||||
---
|
---
|
||||||
---Return value -1: Allow and don't modify item count in inventory.
|
---Return value -1: Allow and don't modify item count in inventory.
|
||||||
---@type (fun(pos:Position, listname:string, index:number, stack:ItemStack, player:Player): number)?
|
---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): number)?
|
||||||
Callbacks.allow_metadata_inventory_take = nil
|
Callbacks.allow_metadata_inventory_take = nil
|
||||||
|
|
||||||
---Called after the actual action has happened, according to what was allowed.
|
---Called after the actual action has happened, according to what was allowed.
|
||||||
---
|
---
|
||||||
---No return value.
|
---No return value.
|
||||||
---@type (fun(pos:Position, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): void)?
|
---@type (fun(pos:MapVector, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): any)?
|
||||||
Callbacks.on_metadata_inventory_move = nil
|
Callbacks.on_metadata_inventory_move = nil
|
||||||
|
|
||||||
---Called after the actual action has happened, according to what was allowed.
|
---Called after the actual action has happened, according to what was allowed.
|
||||||
---
|
---
|
||||||
---No return value.
|
---No return value.
|
||||||
---@type (fun(pos:Position, listname:string, index:number, stack:ItemStack, player:Player): void)?
|
---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): any)?
|
||||||
Callbacks.on_metadata_inventory_put = nil
|
Callbacks.on_metadata_inventory_put = nil
|
||||||
|
|
||||||
---Called after the actual action has happened, according to what was allowed.
|
---Called after the actual action has happened, according to what was allowed.
|
||||||
---
|
---
|
||||||
---No return value.
|
---No return value.
|
||||||
---@type (fun(pos:Position, listname:string, index:number, stack:ItemStack, player:Player): void)?
|
---@type (fun(pos:MapVector, listname:string, index:number, stack:ItemStack, player:Player): any)?
|
||||||
Callbacks.on_metadata_inventory_take = nil
|
Callbacks.on_metadata_inventory_take = nil
|
||||||
|
|
||||||
---If defined, called when an explosion touches the node, instead of
|
---If defined, called when an explosion touches the node, instead of
|
||||||
---removing the node.
|
---removing the node.
|
||||||
---* `intensity`: 1.0 = mid range of regular TNT.
|
---* `intensity`: 1.0 = mid range of regular TNT.
|
||||||
---@type (fun(pos:Position, intensity:number): void)?
|
---@type (fun(pos:MapVector, intensity:number): any)?
|
||||||
Callbacks.on_blast = nil
|
Callbacks.on_blast = nil
|
||||||
|
|
||||||
return Callbacks
|
return Callbacks
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ local Plant = Node:getExtended({
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "meshoptions",
|
paramtype2 = "meshoptions",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
waving = 1,
|
||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
groups = {dig_immediate = 3},
|
groups = {dig_immediate = 3},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local modInfo = Mod.getInfo('smc__core__player')
|
local modInfo = Mod.getInfo('smc__core__player')
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
|
|
||||||
return require('Player')
|
return require('Player')
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user