From 84756af3a11a8e9e8635b5ab0300443a095852dd Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Thu, 21 Mar 2019 17:30:46 +0100 Subject: [PATCH] Opens the stereotypes to the API --- API.md | 9 +++++++++ init.lua | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index e03a0e2..d9cf161 100644 --- a/API.md +++ b/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" +``` diff --git a/init.lua b/init.lua index cd85f77..7236fe9 100644 --- a/init.lua +++ b/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