lua_api: Clarify some environment API functions

This commit is contained in:
sfan5 2024-04-13 13:50:05 +02:00
parent 9f263319ca
commit ecfe9c5c2f
1 changed files with 25 additions and 21 deletions

View File

@ -6003,8 +6003,9 @@ handler.
Chat Chat
---- ----
* `minetest.chat_send_all(text)` * `minetest.chat_send_all(text)`: send chat message to all players
* `minetest.chat_send_player(name, text)` * `minetest.chat_send_player(name, text)`: send chat message to specific player
* `name`: Name of the player
* `minetest.format_chat_message(name, message)` * `minetest.format_chat_message(name, message)`
* Used by the server to format a chat message, based on the setting `chat_message_format`. * Used by the server to format a chat message, based on the setting `chat_message_format`.
Refer to the documentation of the setting for a list of valid placeholders. Refer to the documentation of the setting for a list of valid placeholders.
@ -6016,13 +6017,14 @@ Environment access
------------------ ------------------
* `minetest.set_node(pos, node)` * `minetest.set_node(pos, node)`
* `minetest.add_node(pos, node)`: alias to `minetest.set_node` * Set node at position `pos`.
* Set node at position `pos` * Any existing metadata is deleted.
* `node`: table `{name=string, param1=number, param2=number}` * `node`: table `{name=string, param1=number, param2=number}`
* If param1 or param2 is omitted, it's set to `0`. If param1 or param2 is omitted, it's set to `0`.
* e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})` * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
* `minetest.add_node(pos, node)`: alias to `minetest.set_node`
* `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)` * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
* Set node on all positions set in the first argument. * Set the same node at all positions in the first argument.
* e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})` * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
* For node specification or position syntax see `minetest.set_node` call * For node specification or position syntax see `minetest.set_node` call
* Faster than set_node due to single call, but still considerably slower * Faster than set_node due to single call, but still considerably slower
@ -6032,16 +6034,17 @@ Environment access
For setting a cube, this is 1.3x faster than set_node whereas LVM is 20 For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
times faster. times faster.
* `minetest.swap_node(pos, node)` * `minetest.swap_node(pos, node)`
* Set node at position, but don't remove metadata * Swap node at position with another.
* `minetest.remove_node(pos)` * This keeps the metadata intact and will not run con-/destructor callbacks.
* By default it does the same as `minetest.set_node(pos, {name="air"})` * `minetest.remove_node(pos)`: Remove a node
* Equivalent to `minetest.set_node(pos, {name="air"})`, but a bit faster.
* `minetest.get_node(pos)` * `minetest.get_node(pos)`
* Returns the node at the given position as table in the format * Returns the node at the given position as table in the same format as `set_node`.
`{name="node_name", param1=0, param2=0}`, * This function never returns `nil` and instead returns
returns `{name="ignore", param1=0, param2=0}` for unloaded areas. `{name="ignore", param1=0, param2=0}` for unloaded areas.
* `minetest.get_node_or_nil(pos)` * `minetest.get_node_or_nil(pos)`
* Same as `get_node` but returns `nil` for unloaded areas. * Same as `get_node` but returns `nil` for unloaded areas.
* Note that areas may still contain "ignore" despite being loaded. * Note that even loaded areas can contain "ignore" nodes.
* `minetest.get_node_light(pos[, timeofday])` * `minetest.get_node_light(pos[, timeofday])`
* Gets the light value at the given position. Note that the light value * Gets the light value at the given position. Note that the light value
"inside" the node at the given position is returned, so you usually want "inside" the node at the given position is returned, so you usually want
@ -6096,20 +6099,21 @@ Environment access
* Returns `ObjectRef`, or `nil` if failed * Returns `ObjectRef`, or `nil` if failed
* Items can be added also to unloaded and non-generated blocks. * Items can be added also to unloaded and non-generated blocks.
* `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
* `minetest.get_objects_inside_radius(pos, radius)`: returns a list of * Returns nothing in case of error (player offline, doesn't exist, ...).
ObjectRefs. * `minetest.get_objects_inside_radius(pos, radius)`
* returns a list of ObjectRefs.
* `radius`: using a Euclidean metric * `radius`: using a Euclidean metric
* `minetest.get_objects_in_area(pos1, pos2)`: returns a list of * `minetest.get_objects_in_area(pos1, pos2)`
ObjectRefs. * returns a list of ObjectRefs.
* `pos1` and `pos2` are the min and max positions of the area to search. * `pos1` and `pos2` are the min and max positions of the area to search.
* `minetest.set_timeofday(val)` * `minetest.set_timeofday(val)`: set time of day
* `val` is between `0` and `1`; `0` for midnight, `0.5` for midday * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
* `minetest.get_timeofday()` * `minetest.get_timeofday()`: get time of day
* `minetest.get_gametime()`: returns the time, in seconds, since the world was * `minetest.get_gametime()`: returns the time, in seconds, since the world was
created. The time is not available (`nil`) before the first server step. created. The time is not available (`nil`) before the first server step.
* `minetest.get_day_count()`: returns number days elapsed since world was * `minetest.get_day_count()`: returns number days elapsed since world was
created. created.
* accounts for time changes. * Time changes are accounted for.
* `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
pos or `nil`. pos or `nil`.
* `radius`: using a maximum metric * `radius`: using a maximum metric