forked from minetest-mods/craftguide
Opens the stereotypes to the API
This commit is contained in:
parent
9dc656d5a2
commit
84756af3a1
9
API.md
9
API.md
|
@ -171,3 +171,12 @@ Opens the Crafting Guide with the current filter applied.
|
|||
* `player_name`: string param.
|
||||
* `item`: optional, string param. If set, this item is pre-selected. If the item does not exist or has no recipe, use the player's previous selection. By default, player's previous selection is used
|
||||
* `show_usages`: optional, boolean param. If true, show item usages.
|
||||
|
||||
#### `craftguide.group_stereotypes`
|
||||
|
||||
This is the table indexing the item groups by stereotypes.
|
||||
You can add a stereotype like so:
|
||||
|
||||
```Lua
|
||||
craftguide.group_stereotypes.radioactive = "mod:item"
|
||||
```
|
||||
|
|
8
init.lua
8
init.lua
|
@ -54,7 +54,7 @@ local FMT = {
|
|||
item_image_button = "item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||
}
|
||||
|
||||
local group_stereotypes = {
|
||||
craftguide.group_stereotypes = {
|
||||
wool = "wool:white",
|
||||
dye = "dye:white",
|
||||
water_bucket = "bucket:bucket_water",
|
||||
|
@ -373,9 +373,11 @@ local function groups_to_item(groups)
|
|||
if #groups == 1 then
|
||||
local group = groups[1]
|
||||
local def_gr = "default:" .. group
|
||||
local stereotypes = craftguide.group_stereotypes
|
||||
local stereotype = stereotypes and stereotypes[group]
|
||||
|
||||
if group_stereotypes[group] then
|
||||
return group_stereotypes[group]
|
||||
if stereotype then
|
||||
return stereotype
|
||||
elseif reg_items[def_gr] then
|
||||
return def_gr
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user