diff options
-rw-r--r-- | API.md | 17 | ||||
-rw-r--r-- | init.lua | 8 |
2 files changed, 14 insertions, 11 deletions
@@ -270,6 +270,14 @@ Minetest as it does not support “friendly” group names, which means exposing groups to an interface is not pretty. Therefore, this function may be deprecated when Minetest supports such a thing. +### `doc.sub.items.get_group_name(internal_group_name)` +Returns the group name of the specified group as displayed by this mod. +If the setting `doc_items_friendly_group_names` is `true`, this might +return a “friendly” group name (see above). If no friendly group name +exists, `internal_group_name` is returned. +If `doc_items_friendly_group_names` is `false`, the argument is always +returned. + ### `doc.sub.items.add_notable_groups(groupnames)` Add a list of groups you think are notable enough to be mentioned in the “This item belongs to the following groups: (…)” factoid. @@ -300,13 +308,6 @@ The intention of this function is to give a short rundown of the groups which are notable as they are important to gameplay in some way yet don't deserve a full-blown factoid. -### `doc.sub.items.add_notable_groups(groupnames)` -Declare a number of groups as mining groups, that is, groups which are -primarily used for determining mining times. They will appear in the -“Mining capabilities” factoid. - -`groupnames` is a table of group names. - ### `doc.sub.items.add_forced_item_entries(itemstrings)` Adds items which will be forced to be added to the entry list, even if the item is not in creative inventory. @@ -358,3 +359,5 @@ It is possible to override **these** names, just use the function normally. ["farming:wheat_8"] = "Wheat Plant", -- Item description was empty ["example:node"] = "My Custom Name", }) + + @@ -109,7 +109,7 @@ local description_for_formspec = function(itemstring) end end -local group_to_string = function(groupname) +doc.sub.items.get_group_name = function(groupname) if groupdefs[groupname] ~= nil and doc.sub.items.settings.friendly_group_names == true then return groupdefs[groupname] else @@ -166,7 +166,7 @@ local toolcaps_to_text = function(tool_capabilities) else levelstring = S("any level") end - formstring = formstring .. string.format(S("• %s: %s, %s"), group_to_string(k), ratingstring, levelstring) + formstring = formstring .. string.format(S("• %s: %s, %s"), doc.sub.items.get_group_name(k), ratingstring, levelstring) formstring = formstring .. "\n" end end @@ -176,7 +176,7 @@ local toolcaps_to_text = function(tool_capabilities) if damage_groups ~= nil then formstring = formstring .. S("This is a melee weapon which deals damage by punching.\nMaximum damage per hit:\n") for k,v in pairs(damage_groups) do - formstring = formstring .. string.format(S("• %s: %d HP"), group_to_string(k), v) + formstring = formstring .. string.format(S("• %s: %d HP"), doc.sub.items.get_group_name(k), v) formstring = formstring .. "\n" end end @@ -527,7 +527,7 @@ doc.new_category("nodes", { for group,_ in pairs(mininggroups) do local rating = data.def.groups[group] if rating ~= nil then - mstring = mstring .. string.format(S("• %s: %d"), group_to_string(group), rating).."\n" + mstring = mstring .. string.format(S("• %s: %d"), doc.sub.items.get_group_name(group), rating).."\n" minegroupcount = minegroupcount + 1 end end |