mirror of
https://github.com/rollerozxa/voxelmanip-wiki
synced 2024-05-05 08:01:02 -07:00
Some fixes to pages
This commit is contained in:
parent
0aba624293
commit
4158204f2e
@ -1,6 +1,6 @@
|
||||
This page contains (at times very opinionated) notes about taking a Minetest game and distribute it outside of Minetest. It assumes that you know how to compile Minetest from source.
|
||||
This page contains (at times very opinionated) notes about taking a Minetest game and distributing it outside of Minetest. It assumes that you know how to compile Minetest from source.
|
||||
|
||||
Minetest as an engine itself doesn't have any official means to export a game into a self-contained package with the engine. However as Minetest is free software you can fork the engine to rebrand it and bundle it with the game of your choosing.
|
||||
Minetest as an engine itself doesn't have any official means to export a game into a self-contained package with the engine, instead games are published on [ContentDB](https://content.minetest.net/packages/?type=game) which allows your game to be installed from the main menu content browser. However as Minetest is free software you can fork the engine to rebrand it and bundle it with your game for distribution outside of the Minetest ecosystem.
|
||||
|
||||
[toc]
|
||||
|
||||
@ -8,18 +8,18 @@ Minetest as an engine itself doesn't have any official means to export a game in
|
||||
Generally you're able to customise the main menu (at `builtin/mainmenu/`), which is written in Lua and formspec, however you'd like to suit your game.
|
||||
|
||||
### Locking down the singleplayer tab to one game
|
||||
Go into `src/defaultsettings.cpp` and change `default_game` to the gameid of your choice. It will now start up on your given game.
|
||||
As of 5.8.0-dev, the engine will automatically detect what games are installed and pick the first one installed. If you ship the engine with just your game, then it will select that game on the main menu.
|
||||
|
||||
To remove the gamebar, it's enough to just remove this code in `builtin/mainmenu/tab_local.lua` and set the sizes of the buttonbar to 0:
|
||||
|
||||
```lua
|
||||
@@ -78,32 +78,8 @@ function singleplayer_refresh_gamebar()
|
||||
|
||||
|
||||
local btnbar = buttonbar_create("game_button_bar",
|
||||
game_buttonbar_button_handler,
|
||||
- {x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15})
|
||||
+ {x=-0.3,y=5.9}, "horizontal", {x=0,y=0})
|
||||
|
||||
|
||||
- for _, game in ipairs(pkgmgr.games) do
|
||||
- local btn_name = "game_btnbar_" .. game.id
|
||||
-
|
||||
@ -75,7 +75,7 @@ You can filter the serverlist to only show servers running the specified game. A
|
||||
```lua
|
||||
@@ -181,7 +181,18 @@ function serverlistmgr.sync()
|
||||
end
|
||||
|
||||
|
||||
local retval = core.parse_json(response.data)
|
||||
- return retval and retval.list or {}
|
||||
+
|
||||
@ -118,7 +118,7 @@ You can change the default settings in `src/defaultsettings.cpp` to better suit
|
||||
### Rebranding
|
||||
To fully change the name of the engine you can change the name of the "project" in `CMakeLists.txt`. This will change the name of the executable and the name used on the titlebar, among other places. Keep in mind this will also mean you need to rename files in `misc/` and the translation files.
|
||||
|
||||
To change the icon that's used for Minetest builds on Windows you'll have to replace `misc/minetest-icon.ico` with your game's icon in the Windows ICO file format.
|
||||
To change the icon that's used for Minetest builds on Windows you'll have to replace `misc/minetest-icon.ico` with your game's icon in the Windows ICO file format.
|
||||
|
||||
To make it install your given game instead of Minetest Game, go into `CMakeLists.txt` and change the line that installs `mods/minetest_game` to install your game instead. You may also remove things such as the documentation (e.g. lua_api.txt) and devtest. The lines that install this is right around where the game gets installed, just remove those.
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
ItemStackMetaData is a subclass of [[MetaData]] obtained via `stack:get_meta()` allowing for persistent storage of key-value pairs tied to ItemStacks.
|
||||
|
||||
WARNING: ItemStack metadata is serialized with ItemStacks, increasing the ItemString length.
|
||||
Inventories have to store multiple ItemStrings, all of which an attacker will try to get to maximum length.
|
||||
Always limit the size of your ItemStackMetaData to keep inventories sendable.
|
||||
WARNING: ItemStack metadata is serialized with ItemStacks, increasing the ItemString length. Inventories have to store multiple ItemStrings, all of which an attacker will try to get to maximum length. Always limit the size of your ItemStackMetaData to keep inventories sendable.
|
||||
|
||||
[toc]
|
||||
|
||||
@ -17,9 +15,7 @@ Always limit the size of your ItemStackMetaData to keep inventories sendable.
|
||||
* `palette_index`: Palette index to use for hardware colorization of the stack (if the stack has a palette).
|
||||
|
||||
### Count
|
||||
Requires Minetest 5.6 clients for the count override
|
||||
(older clients will simply show the item count according to the item definition);
|
||||
works on all 5.x servers since it only uses ItemStackMetaData serverside.
|
||||
Requires Minetest 5.6 clients for the count override (older clients will simply show the item count according to the item definition); works on all 5.x servers since it only uses ItemStackMetaData serverside.
|
||||
|
||||
#### `count_meta`
|
||||
String to show in inventory lists instead of the item count.
|
||||
@ -27,15 +23,14 @@ String to show in inventory lists instead of the item count.
|
||||
#### `count_alignment`
|
||||
Integer (use with `:get_int` and `:set_int`).
|
||||
|
||||
Alignment of the displayed item count value is encoded as `x_align + 4 * y_align`
|
||||
where `x_align` and `y_align` are one of:
|
||||
Alignment of the displayed item count value is encoded as `x_align + 4 * y_align` where `x_align` and `y_align` are one of:
|
||||
|
||||
| Value | X-alignment (horizontally) | Y-alignment (vertically) |
|
||||
|---|----|----|
|
||||
| `0` | Default (same as `3`) | Default (same as `3`) |
|
||||
| `1` | Left | Top/Up |
|
||||
| `2` | Centered/Middle | Centered/Middle |
|
||||
| `3` | Right | Bottom/Down |
|
||||
| ----- | -------------------------- | ------------------------ |
|
||||
| `0` | Default (same as `3`) | Default (same as `3`) |
|
||||
| `1` | Left | Top/Up |
|
||||
| `2` | Centered/Middle | Centered/Middle |
|
||||
| `3` | Right | Bottom/Down |
|
||||
|
||||
TIP: Magic numbers make code unreadable. Add an explanatory comment when setting alignment:
|
||||
|
||||
|
@ -8,7 +8,6 @@ Minetest uses Lua 5.1. The environment in which Minetest executes mods depends o
|
||||
[toc]
|
||||
|
||||
## Platform Independence / Portability
|
||||
|
||||
See the [Lua 5.1 Reference Manual](https://www.lua.org/manual/5.1/manual.html) for platform- and OS-environment-dependant Lua features. These include:
|
||||
|
||||
* Locale, affecting pattern matching (character classes) and character codes used by `string.char` and `string.byte`
|
||||
@ -17,7 +16,6 @@ See the [Lua 5.1 Reference Manual](https://www.lua.org/manual/5.1/manual.html) f
|
||||
* `require` and `package.loadlib` (only available in an insecure environment anyways)
|
||||
|
||||
## Global Strictness
|
||||
|
||||
Variables in Lua are global by default (both assignment and access). This often leads to mistaken use of global variables, with the two perhaps most common issues being:
|
||||
|
||||
1. Missspelling a local variable and accessing a global variable instead (which will usually be `nil`)
|
||||
@ -52,27 +50,22 @@ For mod compatibility, the existence of global variables must be checked. A simp
|
||||
As Minetest implements global strictness over a metatable, `rawget(_G, name)` can be used in place of just `name` to access possibly `nil` globals without triggering a warning. Similarly, `rawset(_G, name, value)` may be used to set globals at run time.
|
||||
|
||||
#### `minetest.global_exists(name)`
|
||||
|
||||
Returns `true` if a global variable with the given `name` exists (is not `nil`), `false` otherwise. An error is thrown if `name` is not a string.
|
||||
|
||||
NOTE: This wraps `rawget(_G, name)` in the end but might be considered more readable as it makes the intention clear.
|
||||
|
||||
## Standard Library Extensions
|
||||
|
||||
NOTE: It is considered bad practice to extend the standard library yourself, as this may collide with other mods doing the same as well as future engine changes including Lua version upgrades. Put your extensions into distinct API tables instead of modifying Lua's builtin libraries.
|
||||
|
||||
### `math`
|
||||
|
||||
#### `math.hypot(x, y)`
|
||||
|
||||
Finds the length of the hypotenuse `z` according to the Pythagorean Theorem: stem:[z^2 = x^2 + y^2]. Shorthand for `math.sqrt(x*x + y*y)`.
|
||||
|
||||
#### `math.sign(x, [tolerance])`
|
||||
|
||||
`tolerance` defaults to `0` if falsy. Returns `-1` if the value is smaller than the `tolerance`, `1` if it is larger. Returns `0` if `x` is within the closed tolerance interval `[-tolerance, tolerance]`. Also returns `0` if `x` is `nan`.
|
||||
|
||||
#### `math.factorial(x)`
|
||||
|
||||
`x` must be a non-negative integer; otherwise, the function will error with `"factorial expects a non-negative integer"`. If `x` is at least `171`, `+inf` is returned.
|
||||
|
||||
As Python has built-in big integer support (and uses 64-bit `float`), it can be used to easily determine for which `x` this implementation becomes imprecise due to float precision limitations:
|
||||
@ -89,7 +82,6 @@ for x in range(1, 171):
|
||||
This will print `23`. This means that only for `x` values ranging from `1` to `22`, both inclusive, `factorial(x)` will be fully accurate.
|
||||
|
||||
#### `math.round(x)`
|
||||
|
||||
Rounds `x` towards the nearest integer value. Edge cases:
|
||||
|
||||
* Ties: If `x` is exactly the same distance from two integer values (`x = k + 0.5`) with `k` being an integer, it is rounded "away from zero", to the value with the higher absolute value:
|
||||
@ -99,13 +91,11 @@ Rounds `x` towards the nearest integer value. Edge cases:
|
||||
* Special float values: `nan` and `inf` are preserved, as well as their sign.
|
||||
|
||||
### `string`
|
||||
|
||||
These functions can be used over the string metatable as well, using `self:func(...)` if `self` is a string.
|
||||
|
||||
Note. `"...":func(...)` is a syntax error in Lua. Wrap strings in brackets `(...)` if you want to index them: `("..."):func(...)`.
|
||||
|
||||
#### `string.trim(self)`
|
||||
|
||||
Will return a string with consecutive spacing characters (`%s` pattern character class) at the start and the end of the string removed. Usually the following characters are considered spacing:
|
||||
|
||||
* Horizontal tab: `'\t'` or `'\9'`
|
||||
@ -128,7 +118,6 @@ end
|
||||
WARNING: Platform-independence is not guaranteed: "The definitions of letter, space, and other character groups depend on the current locale." - [Lua 5.1 Reference Manual, section 5.4.1](https://www.lua.org/manual/5.1/manual.html#5.4.1)
|
||||
|
||||
#### `string.split(str, [delim], [include_empty], [max_splits], [sep_is_pattern])`
|
||||
|
||||
* `str`: The string to split.
|
||||
* `delim`: Delimiter/separator. Defaults to `","` if falsy.
|
||||
* `include_empty`: If truthy, empty strings (`""`) are included in the returned list.
|
||||
@ -140,11 +129,9 @@ Returns a list containing the delimited parts without the delimiters.
|
||||
### `table`
|
||||
|
||||
#### `table.indexof(list, val)`
|
||||
|
||||
Linear search for `val` in the `list`. Returns the first index where the value equals `val`. Returns `-1` if the value is not found.
|
||||
|
||||
#### `table.copy(t, [seen])`
|
||||
|
||||
Deepcopies the table `t` and all it's subtables - both keys and values. Non-table types are not copied, even if they are reference types (userdata, functions and threads). The reference structure will be fully preserved: A single table, even if referenced multiple times, will only be copied a single time; subsequent references in the copy will just reference the same copied table.
|
||||
|
||||
The `seen` table is a lookup for already copied tables, which are used as keys. The value is the copy. By providing `[table] = table` entries for certain tables, you can prevent them from being copied.
|
||||
@ -158,15 +145,12 @@ a = {}; b = {a, a}; c = table.copy(b); assert(c[1] ## c[2])
|
||||
A different deep cloning implementation might clone `a` twice, leading to `c[1] ~= c[2]`.
|
||||
|
||||
#### `table.insert_all(t, other)`
|
||||
|
||||
Adds all the list entries of `other` to `t` (list part concatenation).
|
||||
|
||||
#### `table.key_value_swap(t)`
|
||||
|
||||
Returns a new table with the keys of `t` as values and the corresponding values as keys. If a value occurs multiple times in `t`, any of the keys might be the value in the resulting table.
|
||||
|
||||
#### `table.shuffle(t, [from], [to], [random])`
|
||||
|
||||
Performs a Fisher-Yates shuffling on the specified range of the list part of `t`.
|
||||
|
||||
* `from`: Inclusive starting index of the range to be shuffled. Defaults to the first item of the list part if falsy.
|
||||
@ -176,15 +160,12 @@ Performs a Fisher-Yates shuffling on the specified range of the list part of `t`
|
||||
Returns nothing.
|
||||
|
||||
## LuaJIT extensions
|
||||
|
||||
Minetest builds compiled with LuaJIT (`ENABLE_LUAJIT=1`) provide the [LuaJIT extensions](https://luajit.org/extensions.html). These include syntactical Lua 5.2 language features like `goto`, which will lead to a syntax error on PUC Lua 5.1. Hex escapes will be converted into the raw characters by PUC Lua 5.1 (Example: `"\xFF"` which is the same as `"\255"` on LuaJIT will be `"xFF"` on PUC Lua 5.1).
|
||||
|
||||
## Common extensions
|
||||
|
||||
[LuaJIT's `bit` library](https://bitop.luajit.org/) is made available for both PUC Lua and LuaJIT builds. It must not be required, as this will lead to a crash in a secure environment as documented below; in an insecure environment, it is simply unneeded.
|
||||
[LuaJIT's `bit` library](https://bitop.luajit.org/) is made available for both PUC Lua and LuaJIT builds. It must not be required, as this will lead to a crash in a secure environment as documented below; in an insecure environment, it is simply unneeded.
|
||||
|
||||
## Secure environment whitelists
|
||||
|
||||
In the secure environment, the following builtin Lua(JIT) libraries and library functions are whitelisted:
|
||||
|
||||
* `_VERSION`
|
||||
|
@ -83,7 +83,7 @@ for z = minp.z, maxp.z do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = area:index(minp.x, y, z)
|
||||
for x = minp.x, maxp.x do
|
||||
--[[ code here ]]
|
||||
-- code here
|
||||
|
||||
vi = vi + 1
|
||||
end
|
||||
|
@ -13,14 +13,11 @@ Subclasses tie the key-value store to various objects recognized by Minetest:
|
||||
## Methods
|
||||
|
||||
### Getters
|
||||
NOTE: No type information is stored for values; values will be coerced to and from string as needed.
|
||||
Mods need to know which type they expect in order to call the appropriate getters & setters.
|
||||
Do not rely on coercion to work one way or another; never mix different types.
|
||||
NOTE: No type information is stored for values; values will be coerced to and from string as needed. Mods need to know which type they expect in order to call the appropriate getters & setters. Do not rely on coercion to work one way or another; never mix different types.
|
||||
|
||||
WARNING: [Getters currently resolve the value `${key}` to the value associated with `key`](https://github.com/minetest/minetest/issues/12577).
|
||||
|
||||
TIP: Due to the limitations of the provided setters & getters, you might favor using your own
|
||||
(de)serialization for coercion of Lua types to strings which can be stored in the string k-v store.
|
||||
TIP: Due to the limitations of the provided setters & getters, you might favor using your own (de)serialization for coercion of Lua types to strings which can be stored in the string k-v store.
|
||||
|
||||
* `minetest.write_json` & `minetest.parse_json` for Lua tables which are representable as JSON;
|
||||
* `minetest.serialize` & `minetest.deserialize` for arbitrary Lua tables (consisting of tables & primitive types);
|
||||
@ -39,13 +36,11 @@ local got_lua = minetest.deserialize(meta:get_string"lua")
|
||||
assert(got_lua[42] ## true and got_lua[true] ## false)
|
||||
```
|
||||
|
||||
Applying serialization to numbers provides you with safe number storage;
|
||||
you don't have to worry about C(++) type bounds.
|
||||
Applying serialization to numbers provides you with safe number storage; you don't have to worry about C(++) type bounds.
|
||||
|
||||
**Arguments:**
|
||||
|
||||
All getters take only a single argument: The key/name.
|
||||
|
||||
- `key` - `{type-string}`: the key/name
|
||||
|
||||
#### `:contains(key)`
|
||||
@ -82,7 +77,6 @@ Retrieves the value associated with a key & coerces it to an integer.
|
||||
- `{type-number}`: The associated value, coerced to an integer
|
||||
|
||||
#### `:get_float(key)`
|
||||
|
||||
Retrieves the value associated with a key & coerces it to a floating-point number.
|
||||
|
||||
**Returns:**
|
||||
@ -91,7 +85,6 @@ Retrieves the value associated with a key & coerces it to a floating-point numbe
|
||||
- `{type-number}`: The associated value, coerced to a floating point number
|
||||
|
||||
### Setters
|
||||
|
||||
**Arguments & Returns:**
|
||||
|
||||
Setters have no return values; they all take exactly two arguments: Key & value.
|
||||
@ -109,18 +102,13 @@ Setters have no return values; they all take exactly two arguments: Key & value.
|
||||
**Arguments:**
|
||||
- `value` - `{type-number}`: The integer value to coerce to a string & associate with `key`
|
||||
|
||||
WARNING: Integer refers to a C(++) `int` as internally used by the implementation - usually 32 bits wide -
|
||||
meaning it is unable to represent as large integer numbers as the Lua number type.
|
||||
Be careful when storing integers with large absolute values; they may overflow.
|
||||
Keep `value` between `-2^31` and `2^31 - 1`, both inclusive.
|
||||
WARNING: Integer refers to a C(++) `int` as internally used by the implementation - usually 32 bits wide - meaning it is unable to represent as large integer numbers as the Lua number type. Be careful when storing integers with large absolute values; they may overflow. Keep `value` between `-2^31` and `2^31 - 1`, both inclusive.
|
||||
|
||||
#### `:set_float(key, value)`
|
||||
**Arguments:**
|
||||
- `value` - `{type-number}`: The floating-point value to coerce to a string & associate with `key`
|
||||
|
||||
WARNING: The implementation internally uses the C(++) `float` type - usually 32 bits wide -
|
||||
whereas Lua guarantees 64-bit "double-precision" floating point numbers.
|
||||
This may lead to a precision loss. Large numbers in particular may be hardly representable.
|
||||
WARNING: The implementation internally uses the C(++) `float` type - usually 32 bits wide - whereas Lua guarantees 64-bit "double-precision" floating point numbers. This may lead to a precision loss. Large numbers in particular may be hardly representable.
|
||||
|
||||
#### `:equals(other)`
|
||||
**Arguments:**
|
||||
|
@ -12,7 +12,7 @@ NMPR has been made available at [<https://github.com/celeron55/minetest_nmpr>](h
|
||||
|
||||
[toc]
|
||||
|
||||
## Map (the voxels) {#map_the_voxels}
|
||||
## Map (the voxels)
|
||||

|
||||
|
||||
- The main content of the Map is a `map<v2s16, MapSector*>` container.
|
||||
@ -70,7 +70,6 @@ The NMPR server logic is 287 lines of code that runs in two threads:
|
||||
- Send player positions
|
||||
|
||||
#### Packet handler
|
||||
|
||||
The packet handler handles the TOSERVER\_\* commands coming from clients.
|
||||
|
||||
| Name | Description |
|
||||
|
@ -7,13 +7,11 @@ Allows server side mods (SSMs) communication to client side mods (CSMs) and vice
|
||||
### Functions
|
||||
|
||||
#### `minetest.mod_channel_join(channel_name)`
|
||||
|
||||
* `channel_name`: string, modchannel name
|
||||
|
||||
Returns an object for use with [Methods](#Methods). Creates the channel if it does not exist and joins the channel.
|
||||
Returns an object for use with [Methods](#methods). Creates the channel if it does not exist and joins the channel.
|
||||
|
||||
#### `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
|
||||
|
||||
* `channel_name`: string, modchannel name (already joined)
|
||||
* `sender`: string, empty if from a SSM, player name if from a client
|
||||
* `message`: string, message
|
||||
@ -21,21 +19,17 @@ Returns an object for use with [Methods](#Methods). Creates the channel if it do
|
||||
Used for handling messages received from the client.
|
||||
|
||||
### Methods
|
||||
|
||||
NOTE: `channel` here means the object returned by `minetest.mod_channel_join`.
|
||||
|
||||
#### `channel:leave()`
|
||||
|
||||
The server will leave the channel, meaning no more messages from this channel on `minetest.register_on_modchannel_message`
|
||||
|
||||
TIP: Set the channel to `nil` afterwords to free resources
|
||||
|
||||
#### `channel:is_writeable()`
|
||||
|
||||
* Returns `bool`: `true` true if the channel is writeable, `false` if it's not.
|
||||
|
||||
#### `channel:send_all(message)`
|
||||
|
||||
* `message`: string, limited to 65535 bytes
|
||||
|
||||
Sends to all SSMs and CSMs on the channel.
|
||||
@ -47,14 +41,12 @@ CAUTION: The message will not if channel is not writable or invalid.
|
||||
### Functions
|
||||
|
||||
#### `minetest.mod_channel_join(channel_name)`
|
||||
|
||||
* `channel_name`: string, modchannel name
|
||||
|
||||
Returns an object for use with [Methods](#Methods). Creates the channel if it does not exist and joins the channel. Is equivalent to the the server side function.
|
||||
Returns an object for use with [Methods](#methods-1). Creates the channel if it does not exist and joins the channel. Is equivalent to the the server side function.
|
||||
|
||||
#### `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
|
||||
|
||||
* `channel_name`: string, modchannel name (already joined and recieved acknowledgement)
|
||||
* `channel_name`: string, modchannel name (already joined and received acknowledgement)
|
||||
* `sender`: string, empty if from a SSM, player name if from a client
|
||||
* `message`: string, message
|
||||
|
||||
@ -64,31 +56,27 @@ Used for handling messages received from the client. Is equivalent to the the se
|
||||
* `channel_name`: string, channel name that the signal has come in on
|
||||
* `signal`: integer, 0 - 5
|
||||
|
||||
0. join_ok
|
||||
1. join_failed
|
||||
2. leave_ok
|
||||
3. leave_failed
|
||||
4. event_on_not_joined_channel
|
||||
5. state_changed
|
||||
0. `join_ok`
|
||||
1. `join_failed`
|
||||
2. `leave_ok`
|
||||
3. `leave_failed`
|
||||
4. `event_on_not_joined_channel`
|
||||
5. `state_changed`
|
||||
|
||||
Used to handle signals generated by the mod channel system.
|
||||
|
||||
### Methods
|
||||
|
||||
NOTE: `channel` here means the object returned by `minetest.mod_channel_join`.
|
||||
|
||||
#### `channel:leave()`
|
||||
|
||||
The client will leave the channel, meaning no more messages from this channel on `minetest.register_on_modchannel_message`
|
||||
|
||||
TIP: Set the channel to `nil` afterwords to free resources
|
||||
|
||||
#### `channel:is_writeable()`
|
||||
|
||||
* Returns `bool`: `true` true if the channel is writeable, `false` if it's not.
|
||||
|
||||
#### `channel:send_all(message)`
|
||||
|
||||
* `message`: string, limited to 65535 bytes
|
||||
|
||||
Sends to all SSMs and CSMs on the channel.
|
||||
|
@ -165,7 +165,6 @@ A nested hierarchical key-value store is possible through directory structures,
|
||||
If you want to mitigate the risk of data loss, you can use `minetest.safe_file_write` when (re)writing files.
|
||||
|
||||
#### Configuration files
|
||||
|
||||
The `Settings` object allows you to operate on configuration files, getting & setting key-value entries and saving the file.
|
||||
The main `Settings` object `minetest.settings` can be used to persist a few settings "globally" - bleeding everywhere.
|
||||
This is horribly abused by the mainmenu to store stuff like the last selected game. Don't be like the mainmenu;
|
||||
@ -177,7 +176,6 @@ but this is usually not a requirement for game data which is "edited" by in-game
|
||||
indeed, you might not want to tempt players to cheat in singleplayer by editing their "saves".
|
||||
|
||||
#### MetaData
|
||||
|
||||
Minetest provides metadata objects which all provide a simple string key-value store, tied to four different game "objects":
|
||||
|
||||
1. ItemStacks: `ItemStackMetaData`: Fully sent to clients; serialized within inventories, which may be serialized within mapblocks
|
||||
|
@ -5,7 +5,6 @@ With some limitations, they work almost exactly like the player pointing at thin
|
||||
[toc]
|
||||
|
||||
## Pointed Thing
|
||||
|
||||
Pointed things in-game as passed to various callbacks are either
|
||||
|
||||
* Nothing (`{type = "nothing"}`), or
|
||||
@ -15,18 +14,15 @@ Pointed things in-game as passed to various callbacks are either
|
||||
Pointed thing tables are thus a "tagged union" type, taking the following forms for objects & nodes:
|
||||
|
||||
### Objects
|
||||
|
||||
- `type` - `{type-string}`: `"object"`
|
||||
- `ref` - ObjectRef: The pointed ObjectRef
|
||||
|
||||
### Nodes
|
||||
|
||||
- `type` - `{type-string}`: `"node"`
|
||||
- `under` - `{type-vector}`: The position of the pointed node (the node which would be dug if using an appropriate tool)
|
||||
- `above` - `{type-vector}`: The position of the pointed node plus the pointed face normal (the position of the node which would be placed if you were building)
|
||||
|
||||
### Additional Raycast Fields
|
||||
|
||||
These fields are only available in pointed things returned by raycasts.
|
||||
|
||||
- `box_id` - `{type-number}`: Only relevant for nodes: 1-indexed ID of the pointed selection box of the node
|
||||
@ -36,23 +32,19 @@ These fields are only available in pointed things returned by raycasts.
|
||||
Raycasts do not emit "nothing" pointed things.
|
||||
|
||||
## `minetest.line_of_sight(pos1, pos2)`
|
||||
|
||||
Checks whether any non-air node is blocking the line of sight between two positions.
|
||||
|
||||
You may use this to determine e.g. whether a target would be visible to a mob.
|
||||
Raycasts will often be preferable since they provide more fine-grained control
|
||||
(objects, liquids, looping over possibly blocking things in the line of sight).
|
||||
You may use this to determine e.g. whether a target would be visible to a mob. Raycasts will often be preferable since they provide more fine-grained control (objects, liquids, looping over possibly blocking things in the line of sight).
|
||||
|
||||
### Arguments
|
||||
**Arguments:**
|
||||
- `pos1` - `{type-vector}`: Starting position of the line ("segment") of sight
|
||||
- `pos2` - `{type-vector}`: Ending position of the line ("segment") of sight
|
||||
|
||||
### Returns
|
||||
**Returns:**
|
||||
- `free_sight` - `{type-bool}`: Whether any node is blocking the sight
|
||||
- `pos` - `{type-vector}`: Position of the "first" node (the node closest to `pos1`) blocking the sight (only returned if `free_sight` is `false`)
|
||||
|
||||
## `Raycast(from_pos, to_pos, include_objects, include_liquid_nodes)`
|
||||
|
||||
Creates a raycast object; OOP-constructor-style alias for `minetest.raycast`.
|
||||
|
||||
IMPORTANT: [Raycasts work on selection-, not collision boxes, making them coherent with player pointing but not physics (collisions) unless selection- and collision boxes are identical.](https://github.com/minetest/minetest/issues/12673)
|
||||
@ -61,13 +53,13 @@ TIP: Have selection boxes, collision boxes (and ideally even visuals) match for
|
||||
|
||||
IMPORTANT: [Serverside raycasts do not support attachments properly; the server is unaware of model specificities, doesn't keep track of automatic rotation etc.](https://github.com/minetest/minetest/issues/10304)
|
||||
|
||||
### Arguments
|
||||
**Arguments:**
|
||||
- `from_pos` - `{type-vector}`: Starting position of the raycast (usually eye position)
|
||||
- `to_pos` - `{type-vector}`: Ending position of the raycast (usually eye position + look direction times range)
|
||||
- `include_objects` - `{type-bool}`: Whether objects are included (considered pointable). Optional, defaults to `true`.
|
||||
- `include_liquids` - `{type-bool}`: Whether liquids are included (considered pointable). Optional, defaults to `true`.
|
||||
|
||||
### Returns
|
||||
**Returns:**
|
||||
- `ray` - Raycast iterator object: Non-restartable, stateful iterator of pointed things
|
||||
|
||||
The Raycast iterator object is callable. Calling `ray()` is syntactic sugar for `ray:next()`.
|
||||
@ -107,8 +99,7 @@ while pointed_thing ~= nil do
|
||||
end
|
||||
```
|
||||
|
||||
There is absolutely no need to manually step through raycasts
|
||||
using the latter two more verbose loops.
|
||||
There is absolutely no need to manually step through raycasts using the latter two more verbose loops.
|
||||
|
||||
IMPORTANT: Restartability is the ability of an iterator to start again. For example, `ipairs` is resumable:
|
||||
|
||||
@ -123,8 +114,7 @@ end
|
||||
|
||||
will work just expected, printing the contents of `t` three times.
|
||||
|
||||
*Raycasts are not restartable.* Iterating them _"consumes"_ the pointed things;
|
||||
they can't be iterated again. The following will not work as expected:
|
||||
*Raycasts are not restartable.* Iterating them _"consumes"_ the pointed things; they can't be iterated again. The following will not work as expected:
|
||||
|
||||
```lua
|
||||
local ray = Raycast(...)
|
||||
@ -135,9 +125,7 @@ for _ = 1, 3 do
|
||||
end
|
||||
```
|
||||
|
||||
this will print the pointed things (table addresses) exactly once:
|
||||
after the first run of the inner `for` loop, all pointed things have been consumed;
|
||||
subsequent runs exit immediately, not entering the `for` loop at all.
|
||||
this will print the pointed things (table addresses) exactly once: after the first run of the inner `for` loop, all pointed things have been consumed; subsequent runs exit immediately, not entering the `for` loop at all.
|
||||
|
||||
One advantage of this is that Raycasts remember their looping state. The following is thus possible:
|
||||
|
||||
@ -155,9 +143,7 @@ end
|
||||
|
||||
### Redo tool raycasts
|
||||
|
||||
Useful to obtain the additional raycast pointed thing fields,
|
||||
to dynamically decide what is pointable and what is not,
|
||||
to determine the pointed thing periodically ("what am I looking at?") etc.
|
||||
Useful to obtain the additional raycast pointed thing fields, to dynamically decide what is pointable and what is not, to determine the pointed thing periodically ("what am I looking at?") etc.
|
||||
|
||||
```lua
|
||||
-- Calculate eye position including eye offset
|
||||
|
@ -7,7 +7,7 @@ If a media file required on the server doesn't exist on the remote server or the
|
||||
## Technical info
|
||||
At first, the client will POST request `[remote_media]index.mth`, which contains the list of (SHA1) hashes that are available on the server. The client will then check what hashes it wants, but does not currently have cached, and requests `[remote_media][SHA1 hash]` for each one if it exists in the hash index. If it doesn't exist, it will fall back to traditional transfer.
|
||||
|
||||
Preferrably the server should support HTTP/2, though unfortunately the official Android and Windows builds do not come with a cURL linked against libnghttp2 currently. Linux however will usually be linked against a cURL system library that is linked against libnghttp2.
|
||||
Preferably the server should support HTTP/2, though unfortunately the official Android and Windows builds do not come with a cURL linked against libnghttp2 currently. Linux however will usually be linked against a cURL system library that is linked against libnghttp2.
|
||||
|
||||
## Setting a remote media server
|
||||
Set the `remote_media` setting to the URL of the media server. Restart.
|
||||
|
@ -9,7 +9,7 @@ ContentDB has a page where you can check whether a modname exists, both on Conte
|
||||
https://content.minetest.net/modnames/<modname>/
|
||||
```
|
||||
|
||||
If you have uploaded your package, an alert will pop up on the package page if it contains technical names that already exist on ContentDB.
|
||||
If you have uploaded your package, an alert will pop up on the package page if it contains technical names that already exist on ContentDB.
|
||||
|
||||

|
||||
|
||||
|
@ -46,13 +46,13 @@ Lua provides three string notations: Quoted (single or double) and long. The typ
|
||||
|
||||
Long strings enclose their content with two pairs of square brackets (`[]`) with a matching number of equals signs (`=`) between the two brackets of each pair:
|
||||
|
||||
`[[...]]` and `[===[...]===]` are examples of valid long strings.
|
||||
\[\[...\]\] and `[===[...]===]` are examples of valid long strings.
|
||||
|
||||
Within them, no escaping applies, which means that texture modifiers can be written down literally;
|
||||
a leading square bracket such as that of a generating texture modifier is not a problem.
|
||||
Example: `+[[[combine:1x1:0,0=a.png]]+`.
|
||||
Example: +\[\[\[`combine:1x1:0,0=a.png`\]\]+.
|
||||
|
||||
Using equals signs is never necessary since texture modifiers won't contain `[[` or `]]`.
|
||||
Using equals signs is never necessary since texture modifiers won't contain \[\[ or \]\].
|
||||
|
||||
TIP: You can use metamethods in order to implement a neat, possibly OOP-ish Lua DSL that does the escaping and formatting for you.
|
||||
|
||||
|
@ -61,7 +61,7 @@ CAUTION: The returned `time` is not portable and not relative to any specific po
|
||||
|
||||
TIP: You can use the difference between ``minetest.get_us_time`` and the returned times to check whether a real-world timespan has passed, which is useful for rate limiting. For in-game timers, you might prefer adding up `dtime` or (if second precision is enough) using gametime.
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
|
||||
It is possible to use a simple while-loop to wait for a timespan smaller than the server step. This is called a "busywait".
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user