Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
4cc44d004e | |||
584c215aee | |||
5b91f9f171 | |||
54e6406e53 | |||
917dd8714f | |||
6ef7dda7de | |||
a3c41cbd8d | |||
3866c41ab9 | |||
e2c13c4d27 | |||
a7d5653d8f |
@ -1,5 +1,7 @@
|
||||
#  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.
|
||||
#### Consult the [Minetest Wiki](http://wiki.minetest.net/Crafting_guide) for more details.
|
||||
|
||||
|
190
init.lua
@ -77,25 +77,25 @@ local POLL_FREQ = 0.25
|
||||
local HUD_TIMER_MAX = 1.5
|
||||
|
||||
local PNG = {
|
||||
bg = "craftguide_bg.png",
|
||||
bg_full = "craftguide_bg_full.png",
|
||||
search = "craftguide_search_icon.png",
|
||||
clear = "craftguide_clear_icon.png",
|
||||
prev = "craftguide_next_icon.png^\\[transformFX",
|
||||
next = "craftguide_next_icon.png",
|
||||
arrow = "craftguide_arrow.png",
|
||||
fire = "craftguide_fire.png",
|
||||
bg = "craftguide_bg.png",
|
||||
bg_full = "craftguide_bg_full.png",
|
||||
search = "craftguide_search_icon.png",
|
||||
clear = "craftguide_clear_icon.png",
|
||||
prev = "craftguide_next_icon.png^\\[transformFX",
|
||||
next = "craftguide_next_icon.png",
|
||||
arrow = "craftguide_arrow.png",
|
||||
fire = "craftguide_fire.png",
|
||||
fire_anim = "craftguide_fire_anim.png",
|
||||
book = "craftguide_book.png",
|
||||
sign = "craftguide_sign.png",
|
||||
nothing = "craftguide_no.png",
|
||||
selected = "craftguide_selected.png",
|
||||
book = "craftguide_book.png",
|
||||
sign = "craftguide_sign.png",
|
||||
nothing = "craftguide_no.png",
|
||||
selected = "craftguide_selected.png",
|
||||
furnace_anim = "craftguide_furnace_anim.png",
|
||||
|
||||
search_hover = "craftguide_search_icon_hover.png",
|
||||
clear_hover = "craftguide_clear_icon_hover.png",
|
||||
prev_hover = "craftguide_next_icon_hover.png^\\[transformFX",
|
||||
next_hover = "craftguide_next_icon_hover.png",
|
||||
clear_hover = "craftguide_clear_icon_hover.png",
|
||||
prev_hover = "craftguide_next_icon_hover.png^\\[transformFX",
|
||||
next_hover = "craftguide_next_icon_hover.png",
|
||||
}
|
||||
|
||||
local FMT = {
|
||||
@ -112,6 +112,31 @@ local FMT = {
|
||||
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 info = get_player_info(name)
|
||||
return info and info.lang_code
|
||||
@ -147,6 +172,11 @@ craftguide.group_stereotypes = {
|
||||
wool = "wool:white",
|
||||
wood = "default:wood",
|
||||
tree = "default:tree",
|
||||
sand = "default:sand",
|
||||
glass = "default:glass",
|
||||
stick = "default:stick",
|
||||
stone = "default:stone",
|
||||
leaves = "default:leaves",
|
||||
coal = "default:coal_lump",
|
||||
vessel = "vessels:glass_bottle",
|
||||
flower = "flowers:dandelion_yellow",
|
||||
@ -155,20 +185,20 @@ craftguide.group_stereotypes = {
|
||||
}
|
||||
|
||||
local group_names = {
|
||||
carpet = S"Any carpet",
|
||||
coal = S"Any coal",
|
||||
dye = S"Any dye",
|
||||
flower = S"Any flower",
|
||||
glass = S"Any glass",
|
||||
leaves = S"Any leaves",
|
||||
mushroom = S"Any mushroom",
|
||||
coal = S"Any coal",
|
||||
sand = S"Any sand",
|
||||
stick = S"Any stick",
|
||||
stone = S"Any kind of stone block",
|
||||
tree = S"Any tree",
|
||||
vessel = S"Any vessel",
|
||||
tree = S"Any tree",
|
||||
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",
|
||||
mushroom = S"Any mushroom",
|
||||
|
||||
["color_red,flower"] = S"Any red flower",
|
||||
["color_blue,flower"] = S"Any blue flower",
|
||||
@ -588,6 +618,7 @@ end
|
||||
|
||||
local function get_usages(recipe)
|
||||
local added = {}
|
||||
|
||||
for _, item in pairs(recipe.items) do
|
||||
item = reg_aliases[item] or item
|
||||
if not added[item] then
|
||||
@ -626,68 +657,50 @@ local function cache_usages(item)
|
||||
end
|
||||
|
||||
local function drop_table(name, drop)
|
||||
local drop_sure, drop_maybe = {}, {}
|
||||
local count_sure = 0
|
||||
local drop_items = drop.items or {}
|
||||
local max_items = drop.max_items
|
||||
|
||||
for i = 1, #drop_items do
|
||||
local di = drop_items[i]
|
||||
local valid_rarity = di.rarity and di.rarity > 1
|
||||
|
||||
for j = 1, #di.items do
|
||||
local dstack = ItemStack(di.items[j])
|
||||
local dname = dstack:get_name()
|
||||
local dcount = dstack:get_count()
|
||||
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
|
||||
local dstack = ItemStack(di.items[j])
|
||||
local dname = dstack:get_name()
|
||||
local dcount = dstack:get_count()
|
||||
local empty = dstack:is_empty()
|
||||
|
||||
if not dstack:is_empty() and (dname ~= name or
|
||||
(dname == name and dcount > 1)) then
|
||||
if not di.rarity or di.rarity <= 1 then
|
||||
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
|
||||
if not empty and (dname ~= name or
|
||||
(dname == name and dcount > 1)) then
|
||||
local rarity = valid_rarity and di.rarity
|
||||
|
||||
drop_sure[dname] = {
|
||||
output = dcount,
|
||||
tools = di.tools,
|
||||
}
|
||||
else
|
||||
drop_maybe[#drop_maybe + 1] = {
|
||||
item = dname,
|
||||
output = dcount,
|
||||
rarity = di.rarity,
|
||||
craftguide.register_craft{
|
||||
type = rarity and "digging_chance" or "digging",
|
||||
items = {name},
|
||||
output = fmt("%s %u", dname, dcount),
|
||||
rarity = rarity,
|
||||
tools = di.tools,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for item, data in pairs(drop_sure) do
|
||||
craftguide.register_craft{
|
||||
type = "digging",
|
||||
items = {name},
|
||||
output = fmt("%s %u", item, data.output),
|
||||
tools = data.tools,
|
||||
}
|
||||
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,
|
||||
}
|
||||
if not di.rarity then
|
||||
count_sure = count_sure + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function cache_drops(name, drop)
|
||||
if true_str(drop) then
|
||||
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{
|
||||
type = "digging",
|
||||
items = {name},
|
||||
@ -1151,7 +1164,7 @@ local function get_rcp_lbl(lang_code, show_usages, unum, rnum, fs, panel, spacin
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
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 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),
|
||||
x_arrow - shift, y_arrow, PNG.prev, prev_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)
|
||||
|
||||
if recipe_or_usage and not rn then
|
||||
local X = XOFFSET - 0.7
|
||||
local Y = YOFFSET - 0.4 + spacing
|
||||
local lbl = is_recipe and ES"No recipes" or ES"No usages"
|
||||
|
||||
fs[#fs + 1] = fmt(FMT.image, X, Y, 2, 2, PNG.nothing)
|
||||
|
||||
fs[#fs + 1] = fmt(FMT.tooltip,
|
||||
X, Y, 2, 2, is_recipe and ES"No recipes" or ES"No usages")
|
||||
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||
8.29, YOFFSET + spacing + 0.3, 6.8, 1,
|
||||
fmt("<center><style size=20><b>%s</b></style></center>",
|
||||
translate(lang_code, lbl)))
|
||||
|
||||
elseif panel.name == "title" then
|
||||
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)
|
||||
end
|
||||
|
||||
fs[#fs + 1] = styles
|
||||
|
||||
fs[#fs + 1] = fmt([[
|
||||
style[filter;border=false]
|
||||
field[0.4,0.2;2.6,1;filter;;%s]
|
||||
field_close_on_enter[filter;false]
|
||||
box[0,0;2.5,0.6;#bababa25]
|
||||
]],
|
||||
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),
|
||||
2.6, -0.06, 0.85, 0.85, "", "search", "",
|
||||
3.3, -0.06, 0.85, 0.85, "", "clear", "")
|
||||
@ -1358,7 +1348,7 @@ local function make_fs(data)
|
||||
|
||||
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||
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)))
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ Any dark grey dye=
|
||||
Any green dye=
|
||||
Any green flower=
|
||||
Any grey dye=
|
||||
Any kind of stone block=
|
||||
Any stone=
|
||||
Any magenta dye=
|
||||
Any orange dye=
|
||||
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 |