@@ -859,74 +859,19 @@ one player using `to_player = name,`
859
859
Registered definitions
860
860
======================
861
861
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].
924
864
925
865
Note that in some cases you will stumble upon things that are not contained
926
866
in these tables (e.g. when a mod has been removed). Always check for
927
867
existence before trying to access the fields.
928
868
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:
930
875
931
876
local function get_nodedef_field(nodename, fieldname)
932
877
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
1248
1193
type are ignored.
1249
1194
1250
1195
### `image`
1196
+
1251
1197
Displays an image on the HUD.
1252
1198
1253
1199
* `scale`: The scale of the image, with 1 being the original texture size.
@@ -1321,6 +1267,7 @@ For helper functions see [Spatial Vectors].
1321
1267
* `{type="object", ref=ObjectRef}`
1322
1268
1323
1269
Exact pointing location (currently only `Raycast` supports these fields):
1270
+
1324
1271
* `pointed_thing.intersection_point`: The absolute world coordinates of the
1325
1272
point on the selection box which is pointed at. May be in the selection box
1326
1273
if the pointer is in the box too.
@@ -1546,15 +1493,13 @@ Special groups
1546
1493
* `attached_node`: if the node under it is not a walkable block the node will be
1547
1494
dropped as an item. If the node is wallmounted the wallmounted direction is
1548
1495
checked.
1549
- * `soil`: saplings will grow on nodes in this group
1550
1496
* `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1551
1497
connect to each other
1552
1498
* `slippery`: Players and items will slide on the node.
1553
1499
Slipperiness rises steadily with `slippery` value, starting at 1.
1554
1500
* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1555
1501
`"toolrepair"` crafting recipe
1556
1502
1557
-
1558
1503
Known damage and digging time defining groups
1559
1504
---------------------------------------------
1560
1505
@@ -1985,6 +1930,7 @@ Elements
1985
1930
* `<fontcolor>` tooltip font color as `ColorString` (optional)
1986
1931
1987
1932
### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
1933
+
1988
1934
* Adds tooltip for an area. Other tooltips will take priority when present.
1989
1935
* `<bgcolor>` tooltip background color as `ColorString` (optional)
1990
1936
* `<fontcolor>` tooltip font color as `ColorString` (optional)
@@ -2097,9 +2043,9 @@ Elements
2097
2043
2098
2044
### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
2099
2045
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.
2103
2049
2104
2050
### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
2105
2051
@@ -3020,7 +2966,6 @@ to be a table retrieved from `get_data()`.
3020
2966
Once the internal VoxelManip state has been modified to your liking, the
3021
2967
changes can be committed back to the map by calling `VoxelManip:write_to_map()`
3022
2968
3023
-
3024
2969
### Flat array format
3025
2970
3026
2971
Let
@@ -3536,17 +3481,56 @@ Registration functions
3536
3481
3537
3482
Call these functions only at load time!
3538
3483
3539
- * `minetest.register_entity(name, entity definition)`
3540
- * `minetest.register_abm(abm definition)`
3541
- * `minetest.register_lbm(lbm definition)`
3484
+ ### Environment
3485
+
3542
3486
* `minetest.register_node(name, node definition)`
3543
- * `minetest.register_tool(name, item definition)`
3544
3487
* `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})`
3545
3494
* `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)`
3546
3501
* `minetest.register_alias(name, convert_to)`
3547
3502
* 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.
3549
3504
* `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
+
3550
3534
* `minetest.register_craft(recipe)`
3551
3535
* Check recipe table syntax for different types below.
3552
3536
* `minetest.clear_craft(recipe)`
@@ -3559,16 +3543,21 @@ Call these functions only at load time!
3559
3543
* **Warning**! The type field ("shaped", "cooking" or any other) will be
3560
3544
ignored if the recipe contains output. Erasing is then done independently
3561
3545
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.
3572
3561
3573
3562
Global callback registration functions
3574
3563
--------------------------------------
@@ -3729,36 +3718,6 @@ Call these functions only at load time!
3729
3718
* You should have joined some channels to receive events.
3730
3719
* If message comes from a server mod, `sender` field is an empty string.
3731
3720
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
-
3762
3721
Setting-related
3763
3722
---------------
3764
3723
@@ -4713,6 +4672,8 @@ Global objects
4713
4672
Global tables
4714
4673
-------------
4715
4674
4675
+ ### Registered definition tables
4676
+
4716
4677
* `minetest.registered_items`
4717
4678
* Map of registered items, indexed by name
4718
4679
* `minetest.registered_nodes`
@@ -4727,14 +4688,35 @@ Global tables
4727
4688
* Map of object references, indexed by active object id
4728
4689
* `minetest.luaentities`
4729
4690
* 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
4732
4697
* `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`.
4734
4700
* `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`.
4736
4703
* `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.
4738
4720
4739
4721
4740
4722
@@ -6557,6 +6539,36 @@ Note that in params, use of symbols is as follows:
6557
6539
* `()` signifies grouping. For example, when param1 and param2 are both
6558
6540
required, or only param3 is required: `(<param1> <param2>) | <param3>`
6559
6541
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
+
6560
6572
Detached inventory callbacks
6561
6573
----------------------------
6562
6574
0 commit comments