Skip to content

Commit 986cd32

Browse files
authored
Minor lua_api.md improvements (#16169)
1 parent 94a9b94 commit 986cd32

File tree

2 files changed

+96
-83
lines changed

2 files changed

+96
-83
lines changed

doc/client_lua_api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ Luanti Lua Client Modding API Reference 5.13.0
55
it's now called `core` due to the renaming of Luanti (formerly Minetest).
66
`minetest` will keep existing as an alias, so that old code won't break.
77

8+
Note that `core` has already existed since version 0.4.10, so you can use it
9+
safely without breaking backwards compatibility.
10+
811
* More information at <http://www.luanti.org/>
9-
* Developer Wiki: <https://dev.luanti.org/>
12+
* Additional documentation: <https://docs.luanti.org/>
1013

1114
Introduction
1215
------------

doc/lua_api.md

Lines changed: 92 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ Luanti Lua Modding API Reference
55
it's now called `core` due to the renaming of Luanti (formerly Minetest).
66
`minetest` will keep existing as an alias, so that old code won't break.
77

8+
Note that `core` has already existed since version 0.4.10, so you can use it
9+
safely without breaking backwards compatibility.
10+
811
* More information at <http://www.luanti.org/>
9-
* Developer Wiki: <https://dev.luanti.org/>
12+
* Additional documentation: <https://docs.luanti.org/>
1013
* (Unofficial) Minetest Modding Book by rubenwardy: <https://rubenwardy.com/minetest_modding_book/>
1114
* Modding tools: <https://github.com/luanti-org/modtools>
1215

@@ -4581,11 +4584,13 @@ and offset the noise variation.
45814584

45824585
The final fractal value noise variation is created as follows:
45834586

4587+
```
45844588
noise = offset + scale * (octave1 +
45854589
octave2 * persistence +
45864590
octave3 * persistence ^ 2 +
45874591
octave4 * persistence ^ 3 +
45884592
...)
4593+
```
45894594

45904595
Noise Parameters
45914596
----------------
@@ -4699,11 +4704,13 @@ with restraint.
46994704
The absolute value of each octave's noise variation is used when combining the
47004705
octaves. The final value noise variation is created as follows:
47014706

4707+
```
47024708
noise = offset + scale * (abs(octave1) +
47034709
abs(octave2) * persistence +
47044710
abs(octave3) * persistence ^ 2 +
47054711
abs(octave4) * persistence ^ 3 +
47064712
...)
4713+
```
47074714

47084715
### Format example
47094716

@@ -6562,13 +6569,10 @@ Environment access
65626569
* The actual seed used is the noiseparams seed plus the world seed.
65636570
* `core.get_value_noise(seeddiff, octaves, persistence, spread)`
65646571
* Deprecated: use `core.get_value_noise(noiseparams)` instead.
6565-
* Return world-specific value noise
65666572
* `core.get_perlin(noiseparams)`
6567-
* Deprecated: use `core.get_value_noise(noiseparams)` instead.
6568-
* Return world-specific value noise (was not Perlin noise)
6573+
* Deprecated: renamed to `core.get_value_noise` in version 5.12.0.
65696574
* `core.get_perlin(seeddiff, octaves, persistence, spread)`
6570-
* Deprecated: use `core.get_value_noise(noiseparams)` instead.
6571-
* Return world-specific value noise (was not Perlin noise)
6575+
* Deprecated: renamed to `core.get_value_noise` in version 5.12.0.
65726576
* `core.get_voxel_manip([pos1, pos2])`
65736577
* Return voxel manipulator object.
65746578
* Loads the manipulator from the map if positions are passed.
@@ -9061,78 +9065,6 @@ offering very strong randomness.
90619065
* `get_state()`: return generator state encoded in string
90629066
* `set_state(state_string)`: restore generator state from encoded string
90639067

9064-
`ValueNoise`
9065-
-------------
9066-
9067-
A value noise generator.
9068-
It can be created via `ValueNoise()` or `core.get_value_noise()`.
9069-
For legacy reasons, it can also be created via `PerlinNoise()` or `core.get_perlin()`,
9070-
but the implemented noise is not Perlin noise.
9071-
For `core.get_value_noise()`, the actual seed used is the noiseparams seed
9072-
plus the world seed, to create world-specific noise.
9073-
9074-
* `ValueNoise(noiseparams)
9075-
* `ValueNoise(seed, octaves, persistence, spread)` (Deprecated)
9076-
* `PerlinNoise(noiseparams)` (Deprecated)
9077-
* `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated)
9078-
9079-
* `core.get_value_noise(noiseparams)`
9080-
* `core.get_value_noise(seeddiff, octaves, persistence, spread)` (Deprecated)
9081-
* `core.get_perlin(noiseparams)` (Deprecated)
9082-
* `core.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated)
9083-
9084-
### Methods
9085-
9086-
* `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
9087-
* `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
9088-
9089-
`ValueNoiseMap`
9090-
----------------
9091-
9092-
A fast, bulk noise generator.
9093-
9094-
It can be created via `ValueNoiseMap(noiseparams, size)` or
9095-
`core.get_value_noise_map(noiseparams, size)`.
9096-
For legacy reasons, it can also be created via `PerlinNoiseMap(noiseparams, size)`
9097-
or `core.get_perlin_map(noiseparams, size)`, but it is not Perlin noise.
9098-
For `core.get_value_noise_map()`, the actual seed used is the noiseparams seed
9099-
plus the world seed, to create world-specific noise.
9100-
9101-
Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
9102-
for 2D noise, and it must be larger than 1 for 3D noise (otherwise
9103-
`nil` is returned).
9104-
9105-
For each of the functions with an optional `buffer` parameter: If `buffer` is
9106-
not nil, this table will be used to store the result instead of creating a new
9107-
table.
9108-
9109-
### Methods
9110-
9111-
* `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
9112-
with values starting at `pos={x=,y=}`
9113-
* `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
9114-
3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
9115-
* `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
9116-
array of 2D noise with values starting at `pos={x=,y=}`
9117-
* `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
9118-
* `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
9119-
is stored internally.
9120-
* `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
9121-
is stored internally.
9122-
* `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
9123-
returns a slice of the most recently computed noise results. The result slice
9124-
begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
9125-
E.g., to grab a 2-slice high horizontal 2d plane of noise starting at buffer
9126-
offset y = 20:
9127-
`noisevals = noise:get_map_slice({y=20}, {y=2})`
9128-
It is important to note that `slice_offset` offset coordinates begin at 1,
9129-
and are relative to the starting position of the most recently calculated
9130-
noise.
9131-
To grab a single vertical column of noise starting at map coordinates
9132-
x = 1023, y=1000, z = 1000:
9133-
`noise:calc_3d_map({x=1000, y=1000, z=1000})`
9134-
`noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
9135-
91369068
`PlayerMetaRef`
91379069
---------------
91389070

@@ -9184,14 +9116,17 @@ end
91849116
The map is loaded as the ray advances. If the map is modified after the
91859117
`Raycast` is created, the changes may or may not have an effect on the object.
91869118

9187-
It can be created via `Raycast(pos1, pos2, objects, liquids)` or
9188-
`core.raycast(pos1, pos2, objects, liquids)` where:
9119+
It can be created via `Raycast(pos1, pos2, objects, liquids, pointabilities)`
9120+
or `core.raycast(pos1, pos2, objects, liquids, pointabilities)` where:
91899121

91909122
* `pos1`: start of the ray
91919123
* `pos2`: end of the ray
9192-
* `objects`: if false, only nodes will be returned. Default is true.
9124+
* `objects`: if false, only nodes will be returned. Default is `true`.
91939125
* `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
9194-
returned. Default is false.
9126+
returned. Default is `false`.
9127+
* `pointabilities`: Allows overriding the `pointable` property of
9128+
nodes and objects. Uses the same format as the `pointabilities` property
9129+
of item definitions. Default is `nil`.
91959130

91969131
### Limitations
91979132

@@ -9307,6 +9242,81 @@ to restrictions of JSON.
93079242

93089243
* All methods in MetaDataRef
93099244

9245+
`ValueNoise`
9246+
-------------
9247+
9248+
A value noise generator.
9249+
It can be created via `ValueNoise()` or `core.get_value_noise()`.
9250+
For `core.get_value_noise()`, the actual seed used is the noiseparams seed
9251+
plus the world seed, to create world-specific noise.
9252+
9253+
* `ValueNoise(noiseparams)`
9254+
* `ValueNoise(seed, octaves, persistence, spread)` (deprecated)
9255+
* `core.get_value_noise(noiseparams)`
9256+
* `core.get_value_noise(seeddiff, octaves, persistence, spread)` (deprecated)
9257+
9258+
These were previously called `PerlinNoise()` and `core.get_perlin()`, but the
9259+
implemented noise was not Perlin noise. They were renamed in 5.12.0. The old
9260+
names still exist as aliases.
9261+
9262+
### Methods
9263+
9264+
* `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
9265+
* `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
9266+
9267+
`ValueNoiseMap`
9268+
----------------
9269+
9270+
A fast, bulk noise generator.
9271+
9272+
It can be created via `ValueNoiseMap(noiseparams, size)` or
9273+
`core.get_value_noise_map(noiseparams, size)`.
9274+
For `core.get_value_noise_map()`, the actual seed used is the noiseparams seed
9275+
plus the world seed, to create world-specific noise.
9276+
9277+
These were previously called `PerlinNoiseMap()` and `core.get_perlin_map()`,
9278+
but the implemented noise was not Perlin noise. They were renamed in 5.12.0.
9279+
The old names still exist as aliases.
9280+
9281+
Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
9282+
for 2D noise, and it must be larger than 1 for 3D noise (otherwise
9283+
`nil` is returned).
9284+
9285+
For each of the functions with an optional `buffer` parameter: If `buffer` is
9286+
not nil, this table will be used to store the result instead of creating a new
9287+
table.
9288+
9289+
### Methods
9290+
9291+
* `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
9292+
with values starting at `pos={x=,y=}`
9293+
* `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
9294+
3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
9295+
* `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
9296+
array of 2D noise with values starting at `pos={x=,y=}`
9297+
* `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
9298+
* `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
9299+
is stored internally.
9300+
* `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
9301+
is stored internally.
9302+
* `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
9303+
returns a slice of the most recently computed noise results. The result slice
9304+
begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
9305+
E.g., to grab a 2-slice high horizontal 2d plane of noise starting at buffer
9306+
offset `y = 20`:
9307+
```lua
9308+
noisevals = noise:get_map_slice({y=20}, {y=2})
9309+
```
9310+
It is important to note that `slice_offset` offset coordinates begin at 1,
9311+
and are relative to the starting position of the most recently calculated
9312+
noise.
9313+
To grab a single vertical column of noise starting at map coordinates
9314+
`x = 1023, y=1000, z = 1000`:
9315+
```lua
9316+
noise:calc_3d_map({x=1000, y=1000, z=1000})
9317+
noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})
9318+
```
9319+
93109320

93119321

93129322

0 commit comments

Comments
 (0)