Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
4cc44d004e | |||
584c215aee | |||
5b91f9f171 | |||
54e6406e53 | |||
917dd8714f | |||
6ef7dda7de | |||
a3c41cbd8d | |||
3866c41ab9 | |||
e2c13c4d27 | |||
a7d5653d8f |
@ -1,5 +1,7 @@
|
|||||||
#  Crafting Guide
|
#  Crafting Guide
|
||||||
|
|
||||||
|
[](https://content.minetest.net/packages/jp/craftguide/) [](https://content.minetest.net/packages/jp/craftguide/)
|
||||||
|
|
||||||
#### `craftguide` is the most comprehensive crafting guide on Minetest.
|
#### `craftguide` is the most comprehensive crafting guide on Minetest.
|
||||||
#### Consult the [Minetest Wiki](http://wiki.minetest.net/Crafting_guide) for more details.
|
#### Consult the [Minetest Wiki](http://wiki.minetest.net/Crafting_guide) for more details.
|
||||||
|
|
||||||
|
146
init.lua
@ -112,6 +112,31 @@ local FMT = {
|
|||||||
arrow = "image_button[%f,%f;0.8,0.8;%s;%s;;;false;%s]",
|
arrow = "image_button[%f,%f;0.8,0.8;%s;%s;;;false;%s]",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local styles = fmt([[
|
||||||
|
style[filter;border=false]
|
||||||
|
style_type[label,field;font_size=16]
|
||||||
|
style_type[image_button;border=false]
|
||||||
|
style_type[button;border=false;font=bold;font_size=18]
|
||||||
|
style_type[item_image_button;border=false;bgimg_hovered=%s;bgimg_pressed=%s]
|
||||||
|
style[search;fgimg=%s;fgimg_hovered=%s]
|
||||||
|
style[clear;fgimg=%s;fgimg_hovered=%s]
|
||||||
|
style[prev_page;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
||||||
|
style[next_page;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
||||||
|
style[prev_recipe;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
||||||
|
style[next_recipe;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
||||||
|
style[prev_usage;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
||||||
|
style[next_usage;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
||||||
|
]],
|
||||||
|
PNG.selected, PNG.selected,
|
||||||
|
PNG.search, PNG.search_hover,
|
||||||
|
PNG.clear, PNG.clear_hover,
|
||||||
|
PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
||||||
|
PNG.next, PNG.next_hover, PNG.next_hover,
|
||||||
|
PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
||||||
|
PNG.next, PNG.next_hover, PNG.next_hover,
|
||||||
|
PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
||||||
|
PNG.next, PNG.next_hover, PNG.next_hover)
|
||||||
|
|
||||||
local function get_lang_code(name)
|
local function get_lang_code(name)
|
||||||
local info = get_player_info(name)
|
local info = get_player_info(name)
|
||||||
return info and info.lang_code
|
return info and info.lang_code
|
||||||
@ -147,6 +172,11 @@ craftguide.group_stereotypes = {
|
|||||||
wool = "wool:white",
|
wool = "wool:white",
|
||||||
wood = "default:wood",
|
wood = "default:wood",
|
||||||
tree = "default:tree",
|
tree = "default:tree",
|
||||||
|
sand = "default:sand",
|
||||||
|
glass = "default:glass",
|
||||||
|
stick = "default:stick",
|
||||||
|
stone = "default:stone",
|
||||||
|
leaves = "default:leaves",
|
||||||
coal = "default:coal_lump",
|
coal = "default:coal_lump",
|
||||||
vessel = "vessels:glass_bottle",
|
vessel = "vessels:glass_bottle",
|
||||||
flower = "flowers:dandelion_yellow",
|
flower = "flowers:dandelion_yellow",
|
||||||
@ -155,20 +185,20 @@ craftguide.group_stereotypes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local group_names = {
|
local group_names = {
|
||||||
carpet = S"Any carpet",
|
|
||||||
coal = S"Any coal",
|
|
||||||
dye = S"Any dye",
|
dye = S"Any dye",
|
||||||
flower = S"Any flower",
|
coal = S"Any coal",
|
||||||
glass = S"Any glass",
|
|
||||||
leaves = S"Any leaves",
|
|
||||||
mushroom = S"Any mushroom",
|
|
||||||
sand = S"Any sand",
|
sand = S"Any sand",
|
||||||
stick = S"Any stick",
|
|
||||||
stone = S"Any kind of stone block",
|
|
||||||
tree = S"Any tree",
|
tree = S"Any tree",
|
||||||
vessel = S"Any vessel",
|
|
||||||
wool = S"Any wool",
|
wool = S"Any wool",
|
||||||
|
glass = S"Any glass",
|
||||||
|
stick = S"Any stick",
|
||||||
|
stone = S"Any stone",
|
||||||
|
carpet = S"Any carpet",
|
||||||
|
flower = S"Any flower",
|
||||||
|
leaves = S"Any leaves",
|
||||||
|
vessel = S"Any vessel",
|
||||||
wood = S"Any wood planks",
|
wood = S"Any wood planks",
|
||||||
|
mushroom = S"Any mushroom",
|
||||||
|
|
||||||
["color_red,flower"] = S"Any red flower",
|
["color_red,flower"] = S"Any red flower",
|
||||||
["color_blue,flower"] = S"Any blue flower",
|
["color_blue,flower"] = S"Any blue flower",
|
||||||
@ -588,6 +618,7 @@ end
|
|||||||
|
|
||||||
local function get_usages(recipe)
|
local function get_usages(recipe)
|
||||||
local added = {}
|
local added = {}
|
||||||
|
|
||||||
for _, item in pairs(recipe.items) do
|
for _, item in pairs(recipe.items) do
|
||||||
item = reg_aliases[item] or item
|
item = reg_aliases[item] or item
|
||||||
if not added[item] then
|
if not added[item] then
|
||||||
@ -626,68 +657,50 @@ local function cache_usages(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function drop_table(name, drop)
|
local function drop_table(name, drop)
|
||||||
local drop_sure, drop_maybe = {}, {}
|
local count_sure = 0
|
||||||
local drop_items = drop.items or {}
|
local drop_items = drop.items or {}
|
||||||
|
local max_items = drop.max_items
|
||||||
|
|
||||||
for i = 1, #drop_items do
|
for i = 1, #drop_items do
|
||||||
local di = drop_items[i]
|
local di = drop_items[i]
|
||||||
|
local valid_rarity = di.rarity and di.rarity > 1
|
||||||
|
|
||||||
|
if di.rarity or not max_items or
|
||||||
|
(max_items and not di.rarity and count_sure < max_items) then
|
||||||
for j = 1, #di.items do
|
for j = 1, #di.items do
|
||||||
local dstack = ItemStack(di.items[j])
|
local dstack = ItemStack(di.items[j])
|
||||||
local dname = dstack:get_name()
|
local dname = dstack:get_name()
|
||||||
local dcount = dstack:get_count()
|
local dcount = dstack:get_count()
|
||||||
|
local empty = dstack:is_empty()
|
||||||
|
|
||||||
if not dstack:is_empty() and (dname ~= name or
|
if not empty and (dname ~= name or
|
||||||
(dname == name and dcount > 1)) then
|
(dname == name and dcount > 1)) then
|
||||||
if not di.rarity or di.rarity <= 1 then
|
local rarity = valid_rarity and di.rarity
|
||||||
if drop_sure[dname] then
|
|
||||||
if dcount > drop_sure[dname].output then
|
|
||||||
dcount = dcount + drop_sure[dname].output
|
|
||||||
else
|
|
||||||
dcount = drop_sure[dname].output
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
drop_sure[dname] = {
|
craftguide.register_craft{
|
||||||
output = dcount,
|
type = rarity and "digging_chance" or "digging",
|
||||||
tools = di.tools,
|
items = {name},
|
||||||
}
|
output = fmt("%s %u", dname, dcount),
|
||||||
else
|
rarity = rarity,
|
||||||
drop_maybe[#drop_maybe + 1] = {
|
|
||||||
item = dname,
|
|
||||||
output = dcount,
|
|
||||||
rarity = di.rarity,
|
|
||||||
tools = di.tools,
|
tools = di.tools,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
for item, data in pairs(drop_sure) do
|
if not di.rarity then
|
||||||
craftguide.register_craft{
|
count_sure = count_sure + 1
|
||||||
type = "digging",
|
|
||||||
items = {name},
|
|
||||||
output = fmt("%s %u", item, data.output),
|
|
||||||
tools = data.tools,
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, data in ipairs(drop_maybe) do
|
|
||||||
craftguide.register_craft{
|
|
||||||
type = "digging_chance",
|
|
||||||
items = {name},
|
|
||||||
output = fmt("%s %u", data.item, data.output),
|
|
||||||
rarity = data.rarity,
|
|
||||||
tools = data.tools,
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cache_drops(name, drop)
|
local function cache_drops(name, drop)
|
||||||
if true_str(drop) then
|
if true_str(drop) then
|
||||||
local dstack = ItemStack(drop)
|
local dstack = ItemStack(drop)
|
||||||
if not dstack:is_empty() and dstack:get_name() ~= name then
|
local dname = dstack:get_name()
|
||||||
|
local empty = dstack:is_empty()
|
||||||
|
|
||||||
|
if not empty and dname ~= name then
|
||||||
craftguide.register_craft{
|
craftguide.register_craft{
|
||||||
type = "digging",
|
type = "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
@ -1151,7 +1164,7 @@ local function get_rcp_lbl(lang_code, show_usages, unum, rnum, fs, panel, spacin
|
|||||||
end
|
end
|
||||||
|
|
||||||
lbl = translate(lang_code, lbl)
|
lbl = translate(lang_code, lbl)
|
||||||
local lbl_len = #(lbl):gsub("[\128-\191]", "") -- Count chars, not bytes in UTF-8 strings
|
local lbl_len = #lbl:gsub("[\128-\191]", "") -- Count chars, not bytes in UTF-8 strings
|
||||||
local shift = min(0.9, abs(13 - max(13, lbl_len)) * 0.1)
|
local shift = min(0.9, abs(13 - max(13, lbl_len)) * 0.1)
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.label,
|
fs[#fs + 1] = fmt(FMT.label,
|
||||||
@ -1165,13 +1178,6 @@ local function get_rcp_lbl(lang_code, show_usages, unum, rnum, fs, panel, spacin
|
|||||||
local x_arrow = XOFFSET + (sfinv_only and 1.7 or 1)
|
local x_arrow = XOFFSET + (sfinv_only and 1.7 or 1)
|
||||||
local y_arrow = YOFFSET + (sfinv_only and 3.3 or 1.4 + spacing)
|
local y_arrow = YOFFSET + (sfinv_only and 3.3 or 1.4 + spacing)
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
|
||||||
style[%s;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
|
||||||
style[%s;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
|
||||||
]],
|
|
||||||
prev_name, PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
|
||||||
next_name, PNG.next, PNG.next_hover, PNG.next_hover)
|
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
||||||
x_arrow - shift, y_arrow, PNG.prev, prev_name, "",
|
x_arrow - shift, y_arrow, PNG.prev, prev_name, "",
|
||||||
x_arrow + 1.8, y_arrow, PNG.next, next_name, "")
|
x_arrow + 1.8, y_arrow, PNG.next, next_name, "")
|
||||||
@ -1257,13 +1263,12 @@ local function get_panels(lang_code, query_item, recipes, usages, show_usages,
|
|||||||
-0.2 + spacing, panel.height, PNG.bg_full, 10)
|
-0.2 + spacing, panel.height, PNG.bg_full, 10)
|
||||||
|
|
||||||
if recipe_or_usage and not rn then
|
if recipe_or_usage and not rn then
|
||||||
local X = XOFFSET - 0.7
|
local lbl = is_recipe and ES"No recipes" or ES"No usages"
|
||||||
local Y = YOFFSET - 0.4 + spacing
|
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.image, X, Y, 2, 2, PNG.nothing)
|
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||||
|
8.29, YOFFSET + spacing + 0.3, 6.8, 1,
|
||||||
fs[#fs + 1] = fmt(FMT.tooltip,
|
fmt("<center><style size=20><b>%s</b></style></center>",
|
||||||
X, Y, 2, 2, is_recipe and ES"No recipes" or ES"No usages")
|
translate(lang_code, lbl)))
|
||||||
|
|
||||||
elseif panel.name == "title" then
|
elseif panel.name == "title" then
|
||||||
get_title_fs(query_item, lang_code, favs, fs, spacing)
|
get_title_fs(query_item, lang_code, favs, fs, spacing)
|
||||||
@ -1303,30 +1308,15 @@ local function make_fs(data)
|
|||||||
9 - 0.9, LINES + 0.4, PNG.bg_full, 10)
|
9 - 0.9, LINES + 0.4, PNG.bg_full, 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fs[#fs + 1] = styles
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = fmt([[
|
||||||
style[filter;border=false]
|
|
||||||
field[0.4,0.2;2.6,1;filter;;%s]
|
field[0.4,0.2;2.6,1;filter;;%s]
|
||||||
field_close_on_enter[filter;false]
|
field_close_on_enter[filter;false]
|
||||||
box[0,0;2.5,0.6;#bababa25]
|
box[0,0;2.5,0.6;#bababa25]
|
||||||
]],
|
]],
|
||||||
ESC(data.filter))
|
ESC(data.filter))
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
|
||||||
style_type[label,field;font_size=16]
|
|
||||||
style_type[image_button;border=false]
|
|
||||||
style_type[button;border=false;font=bold;font_size=18]
|
|
||||||
style_type[item_image_button;border=false;bgimg_hovered=%s;bgimg_pressed=%s]
|
|
||||||
style[search;fgimg=%s;fgimg_hovered=%s]
|
|
||||||
style[clear;fgimg=%s;fgimg_hovered=%s]
|
|
||||||
style[prev_page;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
|
||||||
style[next_page;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
|
||||||
]],
|
|
||||||
PNG.selected, PNG.selected,
|
|
||||||
PNG.search, PNG.search_hover,
|
|
||||||
PNG.clear, PNG.clear_hover,
|
|
||||||
PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
|
||||||
PNG.next, PNG.next_hover, PNG.next_hover)
|
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 2),
|
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 2),
|
||||||
2.6, -0.06, 0.85, 0.85, "", "search", "",
|
2.6, -0.06, 0.85, 0.85, "", "search", "",
|
||||||
3.3, -0.06, 0.85, 0.85, "", "clear", "")
|
3.3, -0.06, 0.85, 0.85, "", "clear", "")
|
||||||
@ -1358,7 +1348,7 @@ local function make_fs(data)
|
|||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.hypertext,
|
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||||
0.05, 3, 8.29, 1,
|
0.05, 3, 8.29, 1,
|
||||||
fmt("<center><style size=20><b>%s</b></style></center>]",
|
fmt("<center><style size=20><b>%s</b></style></center>",
|
||||||
translate(data.lang_code, lbl)))
|
translate(data.lang_code, lbl)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ Any dark grey dye=
|
|||||||
Any green dye=
|
Any green dye=
|
||||||
Any green flower=
|
Any green flower=
|
||||||
Any grey dye=
|
Any grey dye=
|
||||||
Any kind of stone block=
|
Any stone=
|
||||||
Any magenta dye=
|
Any magenta dye=
|
||||||
Any orange dye=
|
Any orange dye=
|
||||||
Any orange flower=
|
Any orange flower=
|
||||||
|
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 727 B After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.3 KiB |