Skip to content

Commit ce32a32

Browse files
p-ouellettenerzhul
authored andcommitted
lua_api.txt: Various fixes and improvements (#7945)
* Add missing tables of registered things * Eliminate some duplication Registration functions in 'Registered definitions' section merged into 'Registration functions' section. * Misc. fixes * Add privilege definition table * Remove not-special soil group from special groups * Merge two registration functions sections * Move 'added to' information to tables section Also fix some capitalization and missing periods * Minor fixes * Split Registration functions into two subsections And update Registered definition tables to match order * Fixes
1 parent a857529 commit ce32a32

File tree

1 file changed

+131
-119
lines changed

1 file changed

+131
-119
lines changed

doc/lua_api.txt

+131-119
Original file line numberDiff line numberDiff line change
@@ -859,74 +859,19 @@ one player using `to_player = name,`
859859
Registered definitions
860860
======================
861861

862-
Anything added using certain `minetest.register_*` functions gets added to
863-
the global `minetest.registered_*` tables.
864-
865-
* `minetest.register_entity(name, entity definition)`
866-
* added to `minetest.registered_entities[name]`
867-
868-
* `minetest.register_node(name, node definition)`
869-
* added to `minetest.registered_items[name]`
870-
* added to `minetest.registered_nodes[name]`
871-
872-
* `minetest.register_tool(name, item definition)`
873-
* added to `minetest.registered_items[name]`
874-
875-
* `minetest.register_craftitem(name, item definition)`
876-
* added to `minetest.registered_items[name]`
877-
878-
* `minetest.unregister_item(name)`
879-
* Unregisters the item name from engine, and deletes the entry with key
880-
`name` from `minetest.registered_items` and from the associated item
881-
table according to its nature: `minetest.registered_nodes[]` etc
882-
883-
* `minetest.register_biome(biome definition)`
884-
* returns an integer uniquely identifying the registered biome
885-
* added to `minetest.registered_biome` with the key of `biome.name`
886-
* if `biome.name` is nil, the key is the returned ID
887-
888-
* `minetest.unregister_biome(name)`
889-
* Unregisters the biome name from engine, and deletes the entry with key
890-
`name` from `minetest.registered_biome`
891-
892-
* `minetest.register_ore(ore definition)`
893-
* returns an integer uniquely identifying the registered ore
894-
* added to `minetest.registered_ores` with the key of `ore.name`
895-
* if `ore.name` is nil, the key is the returned ID
896-
897-
* `minetest.register_decoration(decoration definition)`
898-
* returns an integer uniquely identifying the registered decoration
899-
* added to `minetest.registered_decorations` with the key of
900-
`decoration.name`.
901-
* if `decoration.name` is nil, the key is the returned ID
902-
903-
* `minetest.register_schematic(schematic definition)`
904-
* returns an integer uniquely identifying the registered schematic
905-
* added to `minetest.registered_schematic` with the key of `schematic.name`
906-
* if `schematic.name` is nil, the key is the returned ID
907-
* if the schematic is loaded from a file, schematic.name is set to the
908-
filename.
909-
* if the function is called when loading the mod, and schematic.name is a
910-
relative path, then the current mod path will be prepended to the
911-
schematic filename.
912-
913-
* `minetest.clear_registered_biomes()`
914-
* clears all biomes currently registered
915-
916-
* `minetest.clear_registered_ores()`
917-
* clears all ores currently registered
918-
919-
* `minetest.clear_registered_decorations()`
920-
* clears all decorations currently registered
921-
922-
* `minetest.clear_registered_schematics()`
923-
* clears all schematics currently registered
862+
Anything added using certain [Registration functions] gets added to one or more
863+
of the global [Registered definition tables].
924864

925865
Note that in some cases you will stumble upon things that are not contained
926866
in these tables (e.g. when a mod has been removed). Always check for
927867
existence before trying to access the fields.
928868

929-
Example: If you want to check the drawtype of a node, you could do:
869+
Example:
870+
871+
All nodes register with `minetest.register_node` get added to the table
872+
`minetest.registered_nodes`.
873+
874+
If you want to check the drawtype of a node, you could do:
930875

931876
local function get_nodedef_field(nodename, fieldname)
932877
if not minetest.registered_nodes[nodename] then
@@ -1248,6 +1193,7 @@ Below are the specific uses for fields in each type; fields not listed for that
12481193
type are ignored.
12491194

12501195
### `image`
1196+
12511197
Displays an image on the HUD.
12521198

12531199
* `scale`: The scale of the image, with 1 being the original texture size.
@@ -1321,6 +1267,7 @@ For helper functions see [Spatial Vectors].
13211267
* `{type="object", ref=ObjectRef}`
13221268

13231269
Exact pointing location (currently only `Raycast` supports these fields):
1270+
13241271
* `pointed_thing.intersection_point`: The absolute world coordinates of the
13251272
point on the selection box which is pointed at. May be in the selection box
13261273
if the pointer is in the box too.
@@ -1546,15 +1493,13 @@ Special groups
15461493
* `attached_node`: if the node under it is not a walkable block the node will be
15471494
dropped as an item. If the node is wallmounted the wallmounted direction is
15481495
checked.
1549-
* `soil`: saplings will grow on nodes in this group
15501496
* `connect_to_raillike`: makes nodes of raillike drawtype with same group value
15511497
connect to each other
15521498
* `slippery`: Players and items will slide on the node.
15531499
Slipperiness rises steadily with `slippery` value, starting at 1.
15541500
* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
15551501
`"toolrepair"` crafting recipe
15561502

1557-
15581503
Known damage and digging time defining groups
15591504
---------------------------------------------
15601505

@@ -1985,6 +1930,7 @@ Elements
19851930
* `<fontcolor>` tooltip font color as `ColorString` (optional)
19861931

19871932
### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
1933+
19881934
* Adds tooltip for an area. Other tooltips will take priority when present.
19891935
* `<bgcolor>` tooltip background color as `ColorString` (optional)
19901936
* `<fontcolor>` tooltip font color as `ColorString` (optional)
@@ -2097,9 +2043,9 @@ Elements
20972043

20982044
### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
20992045

2100-
* `item name` is the registered name of an item/node,
2101-
tooltip will be made out of its description
2102-
to override it use tooltip element
2046+
* `item name` is the registered name of an item/node
2047+
* The item description will be used as the tooltip. This can be overridden with
2048+
a tooltip element.
21032049

21042050
### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
21052051

@@ -3020,7 +2966,6 @@ to be a table retrieved from `get_data()`.
30202966
Once the internal VoxelManip state has been modified to your liking, the
30212967
changes can be committed back to the map by calling `VoxelManip:write_to_map()`
30222968

3023-
30242969
### Flat array format
30252970

30262971
Let
@@ -3536,17 +3481,56 @@ Registration functions
35363481

35373482
Call these functions only at load time!
35383483

3539-
* `minetest.register_entity(name, entity definition)`
3540-
* `minetest.register_abm(abm definition)`
3541-
* `minetest.register_lbm(lbm definition)`
3484+
### Environment
3485+
35423486
* `minetest.register_node(name, node definition)`
3543-
* `minetest.register_tool(name, item definition)`
35443487
* `minetest.register_craftitem(name, item definition)`
3488+
* `minetest.register_tool(name, item definition)`
3489+
* `minetest.override_item(name, redefinition)`
3490+
* Overrides fields of an item registered with register_node/tool/craftitem.
3491+
* Note: Item must already be defined, (opt)depend on the mod defining it.
3492+
* Example: `minetest.override_item("default:mese",
3493+
{light_source=minetest.LIGHT_MAX})`
35453494
* `minetest.unregister_item(name)`
3495+
* Unregisters the item from the engine, and deletes the entry with key
3496+
`name` from `minetest.registered_items` and from the associated item table
3497+
according to its nature: `minetest.registered_nodes`, etc.
3498+
* `minetest.register_entity(name, entity definition)`
3499+
* `minetest.register_abm(abm definition)`
3500+
* `minetest.register_lbm(lbm definition)`
35463501
* `minetest.register_alias(name, convert_to)`
35473502
* Also use this to set the 'mapgen aliases' needed in a game for the core
3548-
* mapgens. See [Mapgen aliases] section above.
3503+
mapgens. See [Mapgen aliases] section above.
35493504
* `minetest.register_alias_force(name, convert_to)`
3505+
* `minetest.register_ore(ore definition)`
3506+
* Returns an integer uniquely identifying the registered ore on success.
3507+
* `minetest.register_biome(biome definition)`
3508+
* Returns an integer uniquely identifying the registered biome on success.
3509+
* `minetest.unregister_biome(name)`
3510+
* Unregisters the biome from the engine, and deletes the entry with key
3511+
`name` from `minetest.registered_biomes`.
3512+
* `minetest.register_decoration(decoration definition)`
3513+
* Returns an integer uniquely identifying the registered decoration on
3514+
success.
3515+
* `minetest.register_schematic(schematic definition)`
3516+
* Returns an integer uniquely identifying the registered schematic on
3517+
success.
3518+
* If the schematic is loaded from a file, the `name` field is set to the
3519+
filename.
3520+
* If the function is called when loading the mod, and `name` is a relative
3521+
path, then the current mod path will be prepended to the schematic
3522+
filename.
3523+
* `minetest.clear_registered_ores()`
3524+
* Clears all ores currently registered.
3525+
* `minetest.clear_registered_biomes()`
3526+
* Clears all biomes currently registered.
3527+
* `minetest.clear_registered_decorations()`
3528+
* Clears all decorations currently registered.
3529+
* `minetest.clear_registered_schematics()`
3530+
* Clears all schematics currently registered.
3531+
3532+
### Gameplay
3533+
35503534
* `minetest.register_craft(recipe)`
35513535
* Check recipe table syntax for different types below.
35523536
* `minetest.clear_craft(recipe)`
@@ -3559,16 +3543,21 @@ Call these functions only at load time!
35593543
* **Warning**! The type field ("shaped", "cooking" or any other) will be
35603544
ignored if the recipe contains output. Erasing is then done independently
35613545
from the crafting method.
3562-
* `minetest.register_ore(ore definition)`
3563-
* `minetest.register_biome(biome definition)`
3564-
* `minetest.register_decoration(decoration definition)`
3565-
* `minetest.override_item(name, redefinition)`
3566-
* Overrides fields of an item registered with register_node/tool/craftitem.
3567-
* Note: Item must already be defined, (opt)depend on the mod defining it.
3568-
* Example: `minetest.override_item("default:mese", {light_source=LIGHT_MAX})`
3569-
* `minetest.clear_registered_ores()`
3570-
* `minetest.clear_registered_biomes()`
3571-
* `minetest.clear_registered_decorations()`
3546+
* `minetest.register_chatcommand(cmd, chatcommand definition)`
3547+
* `minetest.override_chatcommand(name, redefinition)`
3548+
* Overrides fields of a chatcommand registered with `register_chatcommand`.
3549+
* `minetest.unregister_chatcommand(name)`
3550+
* Unregisters a chatcommands registered with `register_chatcommand`.
3551+
* `minetest.register_privilege(name, definition)`
3552+
* `definition` can be a description or a definition table (see [Privilege
3553+
definition]).
3554+
* If it is a description, the priv will be granted to singleplayer and admin
3555+
by default.
3556+
* To allow players with `basic_privs` to grant, see the `basic_privs`
3557+
minetest.conf setting.
3558+
* `minetest.register_authentication_handler(authentication handler definition)`
3559+
* Registers an auth handler that overrides the builtin one.
3560+
* This function can be called by a single mod once only.
35723561

35733562
Global callback registration functions
35743563
--------------------------------------
@@ -3729,36 +3718,6 @@ Call these functions only at load time!
37293718
* You should have joined some channels to receive events.
37303719
* If message comes from a server mod, `sender` field is an empty string.
37313720

3732-
Other registration functions
3733-
----------------------------
3734-
3735-
* `minetest.register_chatcommand(cmd, chatcommand definition)`
3736-
* Adds definition to `minetest.registered_chatcommands`
3737-
* `minetest.override_chatcommand(name, redefinition)`
3738-
* Overrides fields of a chatcommand registered with `register_chatcommand`.
3739-
* `minetest.unregister_chatcommand(name)`
3740-
* Unregisters a chatcommands registered with `register_chatcommand`.
3741-
* `minetest.register_privilege(name, definition)`
3742-
* `definition`: `"description text"`
3743-
* `definition`:
3744-
`{description = "description text", give_to_singleplayer = boolean}`
3745-
the default of `give_to_singleplayer` is true.
3746-
* To allow players with `basic_privs` to grant, see `basic_privs`
3747-
minetest.conf setting.
3748-
* `on_grant(name, granter_name)`: Called when given to player `name` by
3749-
`granter_name`.
3750-
`granter_name` will be nil if the priv was granted by a mod.
3751-
* `on_revoke(name, revoker_name)`: Called when taken from player `name` by
3752-
`revoker_name`.
3753-
`revoker_name` will be nil if the priv was revoked by a mod
3754-
* Note that the above two callbacks will be called twice if a player is
3755-
responsible, once with the player name, and then with a nil player name.
3756-
* Return true in the above callbacks to stop register_on_priv_grant or
3757-
revoke being called.
3758-
* `minetest.register_authentication_handler(authentication handler definition)`
3759-
* Registers an auth handler that overrides the builtin one
3760-
* This function can be called by a single mod once only.
3761-
37623721
Setting-related
37633722
---------------
37643723

@@ -4713,6 +4672,8 @@ Global objects
47134672
Global tables
47144673
-------------
47154674

4675+
### Registered definition tables
4676+
47164677
* `minetest.registered_items`
47174678
* Map of registered items, indexed by name
47184679
* `minetest.registered_nodes`
@@ -4727,14 +4688,35 @@ Global tables
47274688
* Map of object references, indexed by active object id
47284689
* `minetest.luaentities`
47294690
* Map of Lua entities, indexed by active object id
4730-
* `minetest.registered_chatcommands`
4731-
* Map of registered chat command definitions, indexed by name
4691+
* `minetest.registered_abms`
4692+
* List of ABM definitions
4693+
* `minetest.registered_lbms`
4694+
* List of LBM definitions
4695+
* `minetest.registered_aliases`
4696+
* Map of registered aliases, indexed by name
47324697
* `minetest.registered_ores`
4733-
* List of registered ore definitions.
4698+
* Map of registered ore definitions, indexed by the `name` field.
4699+
* If `name` is nil, the key is the ID returned by `minetest.register_ore`.
47344700
* `minetest.registered_biomes`
4735-
* List of registered biome definitions.
4701+
* Map of registered biome definitions, indexed by the `name` field.
4702+
* If `name` is nil, the key is the ID returned by `minetest.register_biome`.
47364703
* `minetest.registered_decorations`
4737-
* List of registered decoration definitions.
4704+
* Map of registered decoration definitions, indexed by the `name` field.
4705+
* If `name` is nil, the key is the ID returned by
4706+
`minetest.register_decoration`.
4707+
* `minetest.registered_schematics`
4708+
* Map of registered schematic definitions, indexed by the `name` field.
4709+
* If `name` is nil, the key is the ID returned by
4710+
`minetest.register_schematic`.
4711+
* `minetest.registered_chatcommands`
4712+
* Map of registered chat command definitions, indexed by name
4713+
* `minetest.registered_privileges`
4714+
* Map of registered privilege definitions, indexed by name
4715+
4716+
### Registered callback tables
4717+
4718+
All callbacks registered with [Global callback registration functions] are added
4719+
to corresponding `minetest.registered_*` tables.
47384720

47394721

47404722

@@ -6557,6 +6539,36 @@ Note that in params, use of symbols is as follows:
65576539
* `()` signifies grouping. For example, when param1 and param2 are both
65586540
required, or only param3 is required: `(<param1> <param2>) | <param3>`
65596541

6542+
Privilege definition
6543+
--------------------
6544+
6545+
Used by `minetest.register_privilege`.
6546+
6547+
{
6548+
description = "Can teleport", -- Privilege description
6549+
6550+
give_to_singleplayer = false,
6551+
-- Whether to grant the privilege to singleplayer (default true).
6552+
6553+
give_to_admin = true,
6554+
-- Whether to grant the privilege to the server admin.
6555+
-- Uses value of 'give_to_singleplayer' by default.
6556+
6557+
on_grant = function(name, granter_name),
6558+
-- Called when given to player 'name' by 'granter_name'.
6559+
-- 'granter_name' will be nil if the priv was granted by a mod.
6560+
6561+
on_revoke = function(name, revoker_name),
6562+
-- Called when taken from player 'name' by 'revoker_name'.
6563+
-- 'revoker_name' will be nil if the priv was revoked by a mod.
6564+
6565+
-- Note that the above two callbacks will be called twice if a player is
6566+
-- responsible, once with the player name, and then with a nil player
6567+
-- name.
6568+
-- Return true in the above callbacks to stop register_on_priv_grant or
6569+
-- revoke being called.
6570+
}
6571+
65606572
Detached inventory callbacks
65616573
----------------------------
65626574

0 commit comments

Comments
 (0)