Skip to content

Commit be3fe16

Browse files
authoredNov 10, 2020
Do not set a default for description in itemdef table (#10559)
* Do not set a default for description in itemdef table * improve documentation
1 parent fca4db4 commit be3fe16

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed
 

Diff for: ‎builtin/game/register.lua

+1-3
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@ function core.register_item(name, itemdef)
118118
end
119119
itemdef.name = name
120120

121-
-- default description to item name
122-
itemdef.description = itemdef.description or name
123121
-- default short_description to first line of description
124122
itemdef.short_description = itemdef.short_description or
125-
itemdef.description:gsub("\n.*","")
123+
(itemdef.description or ""):gsub("\n.*","")
126124

127125
-- Apply defaults and add to registered_* table
128126
if itemdef.type == "node" then

Diff for: ‎doc/lua_api.txt

+16-5
Original file line numberDiff line numberDiff line change
@@ -2023,10 +2023,10 @@ Item metadata only contains a key-value store.
20232023

20242024
Some of the values in the key-value store are handled specially:
20252025

2026-
* `description`: Set the item stack's description. Defaults to
2027-
`idef.description`.
2028-
* `short_description`: Set the item stack's short description. Defaults
2029-
to `idef.short_description`.
2026+
* `description`: Set the item stack's description.
2027+
See also: `get_description` in [`ItemStack`]
2028+
* `short_description`: Set the item stack's short description.
2029+
See also: `get_short_description` in [`ItemStack`]
20302030
* `color`: A `ColorString`, which sets the stack's color.
20312031
* `palette_index`: If the item has a palette, this is used to get the
20322032
current color from the palette.
@@ -5983,8 +5983,18 @@ an itemstring, a table or `nil`.
59835983
stack).
59845984
* `set_metadata(metadata)`: (DEPRECATED) Returns true.
59855985
* `get_description()`: returns the description shown in inventory list tooltips.
5986+
* The engine uses the same as this function for item descriptions.
5987+
* Fields for finding the description, in order:
5988+
* `description` in item metadata (See [Item Metadata].)
5989+
* `description` in item definition
5990+
* item name
59865991
* `get_short_description()`: returns the short description.
59875992
* Unlike the description, this does not include new lines.
5993+
* The engine uses the same as this function for short item descriptions.
5994+
* Fields for finding the short description, in order:
5995+
* `short_description` in item metadata (See [Item Metadata].)
5996+
* `short_description` in item definition
5997+
* first line of the description (See `get_description()`.)
59885998
* `clear()`: removes all items from the stack, making it empty.
59895999
* `replace(item)`: replace the contents of this stack.
59906000
* `item` can also be an itemstring or table.
@@ -7085,11 +7095,12 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
70857095
{
70867096
description = "Steel Axe",
70877097
-- Can contain new lines. "\n" has to be used as new line character.
7088-
-- Defaults to the item's name.
7098+
-- See also: `get_description` in [`ItemStack`]
70897099

70907100
short_description = "Steel Axe",
70917101
-- Must not contain new lines.
70927102
-- Defaults to the first line of description.
7103+
-- See also: `get_short_description` in [`ItemStack`]
70937104

70947105
groups = {},
70957106
-- key = name, value = rating; rating = 1..3.

0 commit comments

Comments
 (0)