mirror of
				https://github.com/minetest-mods/craftguide.git
				synced 2025-11-04 06:55:30 +01:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			1.14.2
			...
			584c215aee
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					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.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										139
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										139
									
								
								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 = {
 | 
			
		||||
@@ -147,6 +147,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 +160,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 +593,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 +632,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 +1139,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,
 | 
			
		||||
@@ -1257,13 +1245,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)
 | 
			
		||||
@@ -1358,7 +1345,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=
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user