Skip to content

Commit e97cbcf

Browse files
authoredSep 8, 2019
Lua API documentation: Various fixes (#8914)
Remove unusable 'minetest.setting_*' from client_lua_api.txt lua_api.txt: - Define the 'mod.conf' format - More precise 'settingtypes.txt' format reference - Document special sound files 'player_*damage' - Group, sort and add 'not_in_creative_inventory' special group - Define the 'Settings' format - Warning about incorrect byte saving in 'StorageRef' - Note about non-persistent player definitions fields - Better 'leveldiff' and 'level' group description
1 parent 52e3b4b commit e97cbcf

File tree

2 files changed

+75
-25
lines changed

2 files changed

+75
-25
lines changed
 

‎doc/client_lua_api.txt

-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ The main Lua script. Running this script should register everything it
111111
wants to register. Subsequent execution depends on minetest calling the
112112
registered callbacks.
113113

114-
`minetest.setting_get(name)` and `minetest.setting_getbool(name)` can be used
115-
to read custom or existing settings at load time, if necessary.
116-
117114
### `sounds`
118115
Media files (sounds) that will be transferred to the
119116
client and will be available for use by the mod.

‎doc/lua_api.txt

+75-22
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ The location of this directory can be fetched by using
154154

155155
### mod.conf
156156

157-
A key-value store of mod details.
157+
A `Settings` file that provides meta information about the mod.
158158

159159
* `name`: The mod name. Allows Minetest to determine the mod name even if the
160160
folder is wrongly named.
@@ -196,8 +196,9 @@ A file containing a description to be shown in the Mods tab of the main menu.
196196

197197
### `settingtypes.txt`
198198

199-
A file in the same format as the one in builtin. It will be parsed by the
200-
settings menu and the settings will be displayed in the "Mods" category.
199+
The format is documented in `builtin/settingtypes.txt`.
200+
It is parsed by the main menu settings dialogue to list mod-specific
201+
settings in the "Mods" category.
201202

202203
### `init.lua`
203204

@@ -856,6 +857,15 @@ A positional sound will only be heard by players that are within
856857
* e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}`
857858

858859

860+
Special sound files
861+
-------------------
862+
863+
These sound files are played back by the engine if provided.
864+
865+
* `main_menu`: Looped sound in the main menu (gain = 1.0)
866+
* `player_damage`: Played when the local player takes damage (gain = 0.5)
867+
* `player_falling_damage`: Played when the local player takes
868+
damage by falling (gain = 0.5)
859869

860870

861871
Registered definitions
@@ -1537,36 +1547,59 @@ Another example: Make red wool from white wool and red dye:
15371547
Special groups
15381548
--------------
15391549

1540-
* `immortal`: Skips all damage and breath handling for an object. This group
1541-
will also hide the integrated HUD status bars for players, and is
1542-
automatically set to all players when damage is disabled on the server.
1543-
* `punch_operable`: For entities; disables the regular damage mechanism for
1544-
players punching it by hand or a non-tool item, so that it can do something
1545-
else than take damage.
1546-
* `level`: Can be used to give an additional sense of progression in the game.
1547-
* A larger level will cause e.g. a weapon of a lower level make much less
1548-
damage, and get worn out much faster, or not be able to get drops
1549-
from destroyed nodes.
1550-
* `0` is something that is directly accessible at the start of gameplay
1551-
* There is no upper limit
1550+
The asterisk `(*)` after a group name describes that there is no engine
1551+
functionality bound to it, and implementation is left up as a suggestion
1552+
to games.
1553+
1554+
### Node, item and tool groups
1555+
1556+
* `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
1557+
that the item should be hidden in item lists.
1558+
1559+
1560+
### Node-only groups
1561+
1562+
* `attached_node`: if the node under it is not a walkable block the node will be
1563+
dropped as an item. If the node is wallmounted the wallmounted direction is
1564+
checked.
1565+
* `bouncy`: value is bounce speed in percent
1566+
* `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1567+
connect to each other
15521568
* `dig_immediate`: Player can always pick up node without reducing tool wear
15531569
* `2`: the node always gets the digging time 0.5 seconds (rail, sign)
15541570
* `3`: the node always gets the digging time 0 seconds (torch)
15551571
* `disable_jump`: Player (and possibly other things) cannot jump from node
15561572
* `fall_damage_add_percent`: damage speed = `speed * (1 + value/100)`
1557-
* `bouncy`: value is bounce speed in percent
15581573
* `falling_node`: if there is no walkable block under the node it will fall
15591574
* `float`: the node will not fall through liquids
1560-
* `attached_node`: if the node under it is not a walkable block the node will be
1561-
dropped as an item. If the node is wallmounted the wallmounted direction is
1562-
checked.
1563-
* `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1564-
connect to each other
1575+
* `level`: Can be used to give an additional sense of progression in the game.
1576+
* A larger level will cause e.g. a weapon of a lower level make much less
1577+
damage, and get worn out much faster, or not be able to get drops
1578+
from destroyed nodes.
1579+
* `0` is something that is directly accessible at the start of gameplay
1580+
* There is no upper limit
1581+
* See also: `leveldiff` in [Tools]
15651582
* `slippery`: Players and items will slide on the node.
15661583
Slipperiness rises steadily with `slippery` value, starting at 1.
1584+
1585+
1586+
### Tool-only groups
1587+
15671588
* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
15681589
`"toolrepair"` crafting recipe
15691590

1591+
1592+
### `ObjectRef` groups
1593+
1594+
* `immortal`: Skips all damage and breath handling for an object. This group
1595+
will also hide the integrated HUD status bars for players, and is
1596+
automatically set to all players when damage is disabled on the server.
1597+
* `punch_operable`: For entities; disables the regular damage mechanism for
1598+
players punching it by hand or a non-tool item, so that it can do something
1599+
else than take damage.
1600+
1601+
1602+
15701603
Known damage and digging time defining groups
15711604
---------------------------------------------
15721605

@@ -1656,6 +1689,8 @@ to implement this.
16561689
Determines how many uses the tool has when it is used for digging a node,
16571690
of this group, of the maximum level. For lower leveled nodes, the use count
16581691
is multiplied by `3^leveldiff`.
1692+
`leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
1693+
node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
16591694

16601695
* `uses=10, leveldiff=0`: actual uses: 10
16611696
* `uses=10, leveldiff=1`: actual uses: 30
@@ -5303,7 +5338,8 @@ Can be obtained via `item:get_meta()`.
53035338
`MetaDataRef`
53045339
-------------
53055340

5306-
See [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`], and [`PlayerMetaRef`].
5341+
Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
5342+
and [`PlayerMetaRef`].
53075343

53085344
### Methods
53095345

@@ -5828,12 +5864,26 @@ It can be created via `Settings(filename)`.
58285864
* Writes changes to file.
58295865
* `to_table()`: returns `{[key1]=value1,...}`
58305866

5867+
### Format
5868+
5869+
The settings have the format `key = value`. Example:
5870+
5871+
foo = example text
5872+
bar = """
5873+
Multiline
5874+
value
5875+
"""
5876+
5877+
58315878
`StorageRef`
58325879
------------
58335880

58345881
Mod metadata: per mod metadata, saved automatically.
58355882
Can be obtained via `minetest.get_mod_storage()` during load time.
58365883

5884+
WARNING: This storage backend is incaptable to save raw binary data due
5885+
to restrictions of JSON.
5886+
58375887
### Methods
58385888

58395889
* All methods in MetaDataRef
@@ -5848,6 +5898,9 @@ Object properties
58485898
-----------------
58495899

58505900
Used by `ObjectRef` methods. Part of an Entity definition.
5901+
These properties are not persistent, but are applied automatically to the
5902+
corresponding Lua entity using the given registration fields.
5903+
Player properties need to be saved manually.
58515904

58525905
{
58535906
hp_max = 1,

0 commit comments

Comments
 (0)
Please sign in to comment.