mirror of
				https://github.com/minetest-mods/craftguide.git
				synced 2025-11-04 06:55:30 +01:00 
			
		
		
		
	Compare commits
	
		
			35 Commits
		
	
	
		
			1.14
			...
			9412ac740a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					9412ac740a | ||
| 
						 | 
					f2a5c4255e | ||
| 
						 | 
					d903aaca89 | ||
| 
						 | 
					c30db91662 | ||
| 
						 | 
					1fb7790c4e | ||
| 
						 | 
					74785bca5e | ||
| 
						 | 
					7ea6899b06 | ||
| 
						 | 
					9a0e36d884 | ||
| 
						 | 
					9890d8a669 | ||
| 
						 | 
					98f8499103 | ||
| 
						 | 
					d57cb7865b | ||
| 
						 | 
					0b37b2bb2f | ||
| 
						 | 
					701c7ae690 | ||
| 
						 | 
					14c1372550 | ||
| 
						 | 
					4a85acec9a | ||
| 
						 | 
					fa1e330856 | ||
| 
						 | 
					89979a8610 | ||
| 
						 | 
					2771ec12f5 | ||
| 
						 | 
					bba7dd81b9 | ||
| 
						 | 
					1ebc1eab68 | ||
| 
						 | 
					84a7377ed0 | ||
| 
						 | 
					c008f5097d | ||
| 
						 | 
					bfa7f4d631 | ||
| 
						 | 
					3a0a2c032d | ||
| 
						 | 
					bfdb67783b | ||
| 
						 | 
					00dcea5c50 | ||
| 
						 | 
					361c64e51c | ||
| 
						 | 
					c0823faad3 | ||
| 
						 | 
					e6d1857799 | ||
| 
						 | 
					95e1aea493 | ||
| 
						 | 
					1980fefa50 | ||
| 
						 | 
					835ab3ba36 | ||
| 
						 | 
					b596a0d10c | ||
| 
						 | 
					a51fe10c92 | ||
| 
						 | 
					24115a0d84 | 
							
								
								
									
										234
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										234
									
								
								init.lua
									
									
									
									
									
								
							@@ -7,6 +7,7 @@ local searches      = {}
 | 
			
		||||
local recipes_cache = {}
 | 
			
		||||
local usages_cache  = {}
 | 
			
		||||
local fuel_cache    = {}
 | 
			
		||||
local replacements  = {fuel = {}}
 | 
			
		||||
local toolrepair
 | 
			
		||||
 | 
			
		||||
local progressive_mode = core.settings:get_bool "craftguide_progressive_mode"
 | 
			
		||||
@@ -30,6 +31,7 @@ local globalstep = core.register_globalstep
 | 
			
		||||
local on_shutdown = core.register_on_shutdown
 | 
			
		||||
local get_players = core.get_connected_players
 | 
			
		||||
local get_craft_result = core.get_craft_result
 | 
			
		||||
local translate = minetest.get_translated_string
 | 
			
		||||
local on_joinplayer = core.register_on_joinplayer
 | 
			
		||||
local get_all_recipes = core.get_all_craft_recipes
 | 
			
		||||
local register_command = core.register_chatcommand
 | 
			
		||||
@@ -38,7 +40,6 @@ local slz, dslz = core.serialize, core.deserialize
 | 
			
		||||
local on_mods_loaded = core.register_on_mods_loaded
 | 
			
		||||
local on_leaveplayer = core.register_on_leaveplayer
 | 
			
		||||
local get_player_info = core.get_player_information
 | 
			
		||||
local get_translation = minetest.get_translated_string
 | 
			
		||||
local on_receive_fields = core.register_on_player_receive_fields
 | 
			
		||||
 | 
			
		||||
local ESC = core.formspec_escape
 | 
			
		||||
@@ -156,6 +157,8 @@ local group_names = {
 | 
			
		||||
	coal = S"Any coal",
 | 
			
		||||
	dye = S"Any dye",
 | 
			
		||||
	flower = S"Any flower",
 | 
			
		||||
	glass = S"Any glass",
 | 
			
		||||
	leaves = S"Any leaves",
 | 
			
		||||
	mushroom = S"Any mushroom",
 | 
			
		||||
	sand = S"Any sand",
 | 
			
		||||
	stick = S"Any stick",
 | 
			
		||||
@@ -566,7 +569,12 @@ end
 | 
			
		||||
local function cache_fuel(item)
 | 
			
		||||
	local burntime = get_burntime(item)
 | 
			
		||||
	if burntime > 0 then
 | 
			
		||||
		fuel_cache[item] = burntime
 | 
			
		||||
		fuel_cache[item] = {
 | 
			
		||||
			type = "fuel",
 | 
			
		||||
			items = {item},
 | 
			
		||||
			burntime = burntime,
 | 
			
		||||
			replacements = replacements.fuel[item],
 | 
			
		||||
		}
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -578,7 +586,6 @@ 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
 | 
			
		||||
@@ -612,13 +619,7 @@ local function cache_usages(item)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if fuel_cache[item] then
 | 
			
		||||
		local fuel = {
 | 
			
		||||
			type = "fuel",
 | 
			
		||||
			items = {item},
 | 
			
		||||
			replacements = fuel_cache.replacements[item],
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		usages_cache[item] = table_merge(usages_cache[item] or {}, {fuel})
 | 
			
		||||
		usages_cache[item] = table_merge(usages_cache[item] or {}, {fuel_cache[item]})
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -636,7 +637,7 @@ local function drop_table(name, drop)
 | 
			
		||||
 | 
			
		||||
			if not dstack:is_empty() and (dname ~= name or
 | 
			
		||||
					(dname == name and dcount > 1)) then
 | 
			
		||||
				if #di.items == 1 and (not di.rarity or di.rarity <= 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
 | 
			
		||||
@@ -697,14 +698,23 @@ local function cache_drops(name, drop)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function cache_recipes(item)
 | 
			
		||||
	item = reg_aliases[item] or item
 | 
			
		||||
	local def = reg_items[item]
 | 
			
		||||
	if not def then return end
 | 
			
		||||
	local recipes = get_all_recipes(item) or {}
 | 
			
		||||
	local recipes = get_all_recipes(item)
 | 
			
		||||
 | 
			
		||||
	for i = 1, #recipes do
 | 
			
		||||
		recipes_cache[item] = table_merge(recipes_cache[item] or {}, recipes[i])
 | 
			
		||||
	if replacements[item] then
 | 
			
		||||
		local _recipes = {}
 | 
			
		||||
 | 
			
		||||
		for k, v in ipairs(recipes or {}) do
 | 
			
		||||
			_recipes[#recipes + 1 - k] = v
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		for k, v in pairs(replacements[item]) do
 | 
			
		||||
			_recipes[k].replacements = v
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		recipes = _recipes
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	recipes_cache[item] = recipes
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function get_recipes(item, data, player)
 | 
			
		||||
@@ -741,21 +751,17 @@ end
 | 
			
		||||
local function groups_to_items(groups, get_all)
 | 
			
		||||
	if not get_all and #groups == 1 then
 | 
			
		||||
		local group = groups[1]
 | 
			
		||||
		local def_gr = "default:" .. group
 | 
			
		||||
		local stereotypes = craftguide.group_stereotypes
 | 
			
		||||
		local stereotype = stereotypes and stereotypes[group]
 | 
			
		||||
		stereotype = reg_items[stereotype] and stereotype
 | 
			
		||||
		local stereotype = craftguide.group_stereotypes[group]
 | 
			
		||||
		local def = reg_items[stereotype]
 | 
			
		||||
 | 
			
		||||
		if stereotype then
 | 
			
		||||
		if def and show_item(def) then
 | 
			
		||||
			return stereotype
 | 
			
		||||
		elseif reg_items[def_gr] then
 | 
			
		||||
			return def_gr
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local names = {}
 | 
			
		||||
	for name, def in pairs(reg_items) do
 | 
			
		||||
		if item_has_groups(def.groups, groups) then
 | 
			
		||||
		if show_item(def) and item_has_groups(def.groups, groups) then
 | 
			
		||||
			if get_all then
 | 
			
		||||
				names[#names + 1] = name
 | 
			
		||||
			else
 | 
			
		||||
@@ -785,8 +791,16 @@ local function is_fav(favs, query_item)
 | 
			
		||||
	return fav, i
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function str_newline(str)
 | 
			
		||||
	return find(str, "\n")
 | 
			
		||||
local function weird_desc(str)
 | 
			
		||||
	return not true_str(str) or find(str, "\n") or not find(str, "%u")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function toupper(str)
 | 
			
		||||
	return str:gsub("%f[%w]%l", upper):gsub("_", " ")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function strip_newline(str)
 | 
			
		||||
	return match(str, "[^\n]*")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function get_desc(item, lang_code)
 | 
			
		||||
@@ -797,10 +811,15 @@ local function get_desc(item, lang_code)
 | 
			
		||||
	local def = reg_items[item]
 | 
			
		||||
 | 
			
		||||
	if def then
 | 
			
		||||
		if true_str(def.description) then
 | 
			
		||||
			return match(get_translation(lang_code, def.description), "[^\n]*")
 | 
			
		||||
		local desc = def.description
 | 
			
		||||
		if true_str(desc) then
 | 
			
		||||
			if not find(desc, "%u") then
 | 
			
		||||
				return strip_newline(toupper(desc))
 | 
			
		||||
			end
 | 
			
		||||
			return strip_newline(translate(lang_code, desc))
 | 
			
		||||
 | 
			
		||||
		elseif true_str(item) then
 | 
			
		||||
			return match(item, ":.*"):gsub("%W%l", upper):sub(2):gsub("_", " ")
 | 
			
		||||
			return toupper(match(item, ":(.*)"))
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
@@ -842,7 +861,7 @@ local function get_tooltip(item, info, lang_code)
 | 
			
		||||
 | 
			
		||||
	if info.replace then
 | 
			
		||||
		for i = 1, #info.replace do
 | 
			
		||||
			local rpl = info.replace[i]
 | 
			
		||||
			local rpl = match(info.replace[i], "%S+")
 | 
			
		||||
			local desc = clr("#ff0", get_desc(rpl, lang_code))
 | 
			
		||||
 | 
			
		||||
			if info.cooktime then
 | 
			
		||||
@@ -913,36 +932,37 @@ local function get_output_fs(lang_code, fs, rcp, shapeless, right, btn_size, _bt
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local arrow_X = right + (_btn_size or ITEM_BTN_SIZE)
 | 
			
		||||
	local output_X = arrow_X + 0.9
 | 
			
		||||
	local X = arrow_X + 0.9
 | 
			
		||||
	local Y = YOFFSET + (sfinv_only and 2 or 0) + spacing
 | 
			
		||||
 | 
			
		||||
	fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
 | 
			
		||||
 | 
			
		||||
	if rcp.type == "fuel" then
 | 
			
		||||
		fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y,
 | 
			
		||||
		fs[#fs + 1] = fmt(FMT.animated_image, X, Y,
 | 
			
		||||
			ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.fire_anim, 8, 180)
 | 
			
		||||
	else
 | 
			
		||||
		local item = rcp.output
 | 
			
		||||
		item = clean_name(item)
 | 
			
		||||
		local name = match(item, "%S*")
 | 
			
		||||
 | 
			
		||||
		fs[#fs + 1] = fmt(FMT.image, output_X, Y,
 | 
			
		||||
		fs[#fs + 1] = fmt(FMT.image, X, Y,
 | 
			
		||||
			ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.selected)
 | 
			
		||||
 | 
			
		||||
		local _name = sfinv_only and name or fmt("_%s", name)
 | 
			
		||||
 | 
			
		||||
		fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
 | 
			
		||||
			output_X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, _name, "")
 | 
			
		||||
			X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, _name, "")
 | 
			
		||||
 | 
			
		||||
		local def = reg_items[name]
 | 
			
		||||
		local unknown = not def or nil
 | 
			
		||||
		local weird_desc = name ~= "" and def and
 | 
			
		||||
			(not true_str(def.description) or str_newline(def.description)) or nil
 | 
			
		||||
		local desc = def and def.description
 | 
			
		||||
		local weird = name ~= "" and desc and weird_desc(desc) or nil
 | 
			
		||||
		local burntime = fuel_cache[name] and fuel_cache[name].burntime
 | 
			
		||||
 | 
			
		||||
		local infos = {
 | 
			
		||||
			unknown  = unknown,
 | 
			
		||||
			weird_desc = weird_desc,
 | 
			
		||||
			burntime   = fuel_cache[name],
 | 
			
		||||
			weird    = weird,
 | 
			
		||||
			burntime = burntime,
 | 
			
		||||
			repair   = repairable(name),
 | 
			
		||||
			rarity   = rcp.rarity,
 | 
			
		||||
			tools    = rcp.tools,
 | 
			
		||||
@@ -954,11 +974,11 @@ local function get_output_fs(lang_code, fs, rcp, shapeless, right, btn_size, _bt
 | 
			
		||||
 | 
			
		||||
		if infos.burntime then
 | 
			
		||||
			fs[#fs + 1] = fmt(FMT.image,
 | 
			
		||||
				output_X + 1, YOFFSET + (sfinv_only and 2 or 0.1) + spacing,
 | 
			
		||||
				X + 1, YOFFSET + (sfinv_only and 2 or 0.1) + spacing,
 | 
			
		||||
				0.6, 0.4, PNG.arrow)
 | 
			
		||||
 | 
			
		||||
			fs[#fs + 1] = fmt(FMT.animated_image,
 | 
			
		||||
				output_X + 1.6, YOFFSET + (sfinv_only and 1.85 or 0) + spacing,
 | 
			
		||||
				X + 1.6, YOFFSET + (sfinv_only and 1.85 or 0) + spacing,
 | 
			
		||||
				0.6, 0.6, PNG.fire_anim, 8, 180)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
@@ -1026,13 +1046,22 @@ local function get_grid_fs(lang_code, fs, rcp, spacing)
 | 
			
		||||
		local label = groups and "\nG" or ""
 | 
			
		||||
		local replace
 | 
			
		||||
 | 
			
		||||
		if rcp.replacements then
 | 
			
		||||
			replace = {}
 | 
			
		||||
			label = fmt("%s%s\nR", label ~= "" and "\n" or "", label)
 | 
			
		||||
 | 
			
		||||
			for j = 1, #rcp.replacements do
 | 
			
		||||
		for j = 1, #(rcp.replacements or {}) do
 | 
			
		||||
			local replacement = rcp.replacements[j]
 | 
			
		||||
			if replacement[1] == name then
 | 
			
		||||
				replace = replace or {}
 | 
			
		||||
 | 
			
		||||
				local added
 | 
			
		||||
 | 
			
		||||
				for _, v in ipairs(replace) do
 | 
			
		||||
					if replacement[2] == v then
 | 
			
		||||
						added = true
 | 
			
		||||
						break
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
 | 
			
		||||
				if not added then
 | 
			
		||||
					label = fmt("%s%s\nR", label ~= "" and "\n" or "", label)
 | 
			
		||||
					replace[#replace + 1] = replacement[2]
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
@@ -1044,26 +1073,35 @@ local function get_grid_fs(lang_code, fs, rcp, spacing)
 | 
			
		||||
			fs[#fs + 1] = fmt(FMT.image, X, Y, btn_size, btn_size, PNG.selected)
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		local btn_name = ""
 | 
			
		||||
 | 
			
		||||
		if groups then
 | 
			
		||||
			btn_name = fmt("group|%s|%s", groups[1], item)
 | 
			
		||||
		elseif item ~= "" then
 | 
			
		||||
			btn_name = item
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		fs[#fs + 1] = fmt(FMT.item_image_button,
 | 
			
		||||
			X, Y, btn_size, btn_size, item, item, label)
 | 
			
		||||
			X, Y, btn_size, btn_size, item, btn_name, label)
 | 
			
		||||
 | 
			
		||||
		local def = reg_items[name]
 | 
			
		||||
		local unknown = not def or nil
 | 
			
		||||
		unknown = not groups and unknown or nil
 | 
			
		||||
		local weird_desc = name ~= "" and def and
 | 
			
		||||
			(not true_str(def.description) or str_newline(def.description)) or nil
 | 
			
		||||
		local desc = def and def.description
 | 
			
		||||
		local weird = name ~= "" and desc and weird_desc(desc) or nil
 | 
			
		||||
		local burntime = fuel_cache[name] and fuel_cache[name].burntime
 | 
			
		||||
 | 
			
		||||
		local infos = {
 | 
			
		||||
			unknown  = unknown,
 | 
			
		||||
			weird_desc = weird_desc,
 | 
			
		||||
			weird    = weird,
 | 
			
		||||
			groups   = groups,
 | 
			
		||||
			burntime   = fuel_cache[name],
 | 
			
		||||
			burntime = burntime,
 | 
			
		||||
			cooktime = cooktime,
 | 
			
		||||
			replace  = replace,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if next(infos) then
 | 
			
		||||
			fs[#fs + 1] = get_tooltip(item, infos, lang_code)
 | 
			
		||||
			fs[#fs + 1] = get_tooltip(btn_name, infos, lang_code)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
@@ -1088,8 +1126,9 @@ local function get_rcp_lbl(lang_code, show_usages, unum, rnum, fs, panel, spacin
 | 
			
		||||
			ES("Recipe @1 of @2", rnum, rn)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	lbl = get_translation(lang_code, lbl)
 | 
			
		||||
	local shift = min(0.9, abs(13 - max(13, #lbl)) * 0.1)
 | 
			
		||||
	lbl = translate(lang_code, lbl)
 | 
			
		||||
	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,
 | 
			
		||||
		XOFFSET + (sfinv_only and 2.3 or 1.6) - shift,
 | 
			
		||||
@@ -1124,7 +1163,7 @@ local function get_title_fs(query_item, lang_code, favs, fs, spacing)
 | 
			
		||||
	local t_desc = query_item
 | 
			
		||||
	t_desc = #t_desc > 40 and fmt("%s...", sub(t_desc, 1, 37)) or t_desc
 | 
			
		||||
 | 
			
		||||
	fs[#fs + 1] = fmt("hypertext[9.05,%f;5.85,1.2;item_title;%s]",
 | 
			
		||||
	fs[#fs + 1] = fmt("hypertext[9.05,%f;5.85,1.2;;%s]",
 | 
			
		||||
		spacing - 0.1,
 | 
			
		||||
		fmt("<item name=%s float=right width=64 height=64 rotate=yes>" ..
 | 
			
		||||
		    "<big><b>%s</b></big>\n<style color=#7bf font=mono>%s</style>",
 | 
			
		||||
@@ -1249,13 +1288,14 @@ local function make_fs(data)
 | 
			
		||||
	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]
 | 
			
		||||
		style[pagenum;border=false]
 | 
			
		||||
	]],
 | 
			
		||||
	PNG.selected, PNG.selected,
 | 
			
		||||
	PNG.search, PNG.search_hover,
 | 
			
		||||
@@ -1286,15 +1326,16 @@ local function make_fs(data)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if #data.items == 0 then
 | 
			
		||||
		local no_item = ES"No item to show"
 | 
			
		||||
		local pos = 3
 | 
			
		||||
		local lbl = ES"No item to show"
 | 
			
		||||
 | 
			
		||||
		if next(recipe_filters) and #init_items > 0 and data.filter == "" then
 | 
			
		||||
			no_item = ES"Collect items to reveal more recipes"
 | 
			
		||||
			pos = pos - 1
 | 
			
		||||
			lbl = ES"Collect items to reveal more recipes"
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		fs[#fs + 1] = fmt(FMT.label, pos, 2, no_item)
 | 
			
		||||
		fs[#fs + 1] = fmt("hypertext[%f,%f;%f,%f;;%s]",
 | 
			
		||||
			0.05, 3, 8.29, 1,
 | 
			
		||||
			fmt("<center><style size=20><b>%s</b></style></center>]",
 | 
			
		||||
				translate(data.lang_code, lbl)))
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local first_item = (data.pagenum - 1) * IPP
 | 
			
		||||
@@ -1306,7 +1347,7 @@ local function make_fs(data)
 | 
			
		||||
		local X = i % ROWS
 | 
			
		||||
		local Y = (i % IPP - X) / ROWS + 1
 | 
			
		||||
		X = X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05
 | 
			
		||||
		Y = Y - (Y * 0.1) - 0.1
 | 
			
		||||
		Y = Y - (Y * 0.08) - 0.15
 | 
			
		||||
 | 
			
		||||
		if data.query_item == item then
 | 
			
		||||
			fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
 | 
			
		||||
@@ -1369,7 +1410,7 @@ local function search(data)
 | 
			
		||||
	for i = 1, #data.items_raw do
 | 
			
		||||
		local item = data.items_raw[i]
 | 
			
		||||
		local def = reg_items[item]
 | 
			
		||||
		local desc = (def and def.description) and lower(def.description) or ""
 | 
			
		||||
		local desc = lower(translate(data.lang_code, def and def.description)) or ""
 | 
			
		||||
		local search_in = fmt("%s %s", item, desc)
 | 
			
		||||
		local to_add
 | 
			
		||||
 | 
			
		||||
@@ -1419,13 +1460,12 @@ craftguide.add_search_filter("groups", function(item, groups)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
--[[	As `core.get_craft_recipe` and `core.get_all_craft_recipes` do not
 | 
			
		||||
	return the replacements and toolrepair, we have to override
 | 
			
		||||
	`core.register_craft` and do some reverse engineering.
 | 
			
		||||
	See engine's issues #4901 and #8920.	]]
 | 
			
		||||
 | 
			
		||||
fuel_cache.replacements = {}
 | 
			
		||||
	return the fuel, replacements and toolrepair recipes, we have to
 | 
			
		||||
	override `core.register_craft` and do some reverse engineering.
 | 
			
		||||
	See engine's issues #4901, #5745 and #8920.	]]
 | 
			
		||||
 | 
			
		||||
local old_register_craft = core.register_craft
 | 
			
		||||
local rcp_num = {}
 | 
			
		||||
 | 
			
		||||
core.register_craft = function(def)
 | 
			
		||||
	old_register_craft(def)
 | 
			
		||||
@@ -1447,50 +1487,18 @@ core.register_craft = function(def)
 | 
			
		||||
 | 
			
		||||
	for i = 1, #output do
 | 
			
		||||
		local name = output[i]
 | 
			
		||||
		rcp_num[name] = (rcp_num[name] or 0) + 1
 | 
			
		||||
 | 
			
		||||
		if def.type ~= "fuel" then
 | 
			
		||||
			def.items = {}
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		if def.replacements then
 | 
			
		||||
			if def.type == "fuel" then
 | 
			
		||||
			fuel_cache[name] = def.burntime
 | 
			
		||||
			fuel_cache.replacements[name] = def.replacements
 | 
			
		||||
 | 
			
		||||
		elseif def.type == "cooking" then
 | 
			
		||||
			def.width = def.cooktime
 | 
			
		||||
			def.cooktime = nil
 | 
			
		||||
			def.items[1] = def.recipe
 | 
			
		||||
 | 
			
		||||
		elseif def.type == "shapeless" then
 | 
			
		||||
			def.width = 0
 | 
			
		||||
			for j = 1, #def.recipe do
 | 
			
		||||
				def.items[#def.items + 1] = def.recipe[j]
 | 
			
		||||
			end
 | 
			
		||||
				replacements.fuel[name] = def.replacements
 | 
			
		||||
			else
 | 
			
		||||
			def.width = #def.recipe[1]
 | 
			
		||||
			local c = 0
 | 
			
		||||
 | 
			
		||||
			for j = 1, #def.recipe do
 | 
			
		||||
				if def.recipe[j] then
 | 
			
		||||
					for h = 1, def.width do
 | 
			
		||||
						c = c + 1
 | 
			
		||||
						local it = def.recipe[j][h]
 | 
			
		||||
 | 
			
		||||
						if it and it ~= "" then
 | 
			
		||||
							def.items[c] = it
 | 
			
		||||
				replacements[name] = replacements[name] or {}
 | 
			
		||||
				replacements[name][rcp_num[name]] = def.replacements
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		if def.type ~= "fuel" then
 | 
			
		||||
			def.recipe = nil
 | 
			
		||||
			recipes_cache[name] = recipes_cache[name] or {}
 | 
			
		||||
			insert(recipes_cache[name], 1, def)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local old_clear_craft = core.clear_craft
 | 
			
		||||
 | 
			
		||||
@@ -1498,10 +1506,7 @@ core.clear_craft = function(def)
 | 
			
		||||
	old_clear_craft(def)
 | 
			
		||||
 | 
			
		||||
	if true_str(def) then
 | 
			
		||||
		def = match(def, "%S*")
 | 
			
		||||
		recipes_cache[def] = nil
 | 
			
		||||
		fuel_cache[def] = nil
 | 
			
		||||
 | 
			
		||||
		return -- TODO
 | 
			
		||||
	elseif is_table(def) then
 | 
			
		||||
		return -- TODO
 | 
			
		||||
	end
 | 
			
		||||
@@ -1550,9 +1555,15 @@ local function get_init_items()
 | 
			
		||||
 | 
			
		||||
	for name, def in pairs(reg_items) do
 | 
			
		||||
		if name ~= "" and show_item(def) then
 | 
			
		||||
			cache_recipes(name)
 | 
			
		||||
			cache_drops(name, def.drop)
 | 
			
		||||
 | 
			
		||||
			if not fuel_cache[name] then
 | 
			
		||||
				cache_fuel(name)
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			if not recipes_cache[name] then
 | 
			
		||||
				cache_recipes(name)
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			_preselect[name] = true
 | 
			
		||||
		end
 | 
			
		||||
@@ -1576,7 +1587,6 @@ local function get_init_items()
 | 
			
		||||
		local post_data = {
 | 
			
		||||
			recipes = recipes_cache,
 | 
			
		||||
			usages  = usages_cache,
 | 
			
		||||
			fuel    = fuel_cache,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		http.fetch_async{
 | 
			
		||||
@@ -1682,6 +1692,8 @@ local function fields(player, _f)
 | 
			
		||||
			item = sub(item, 1, -5)
 | 
			
		||||
		elseif sub(item, 1, 1) == "_" then
 | 
			
		||||
			item = sub(item, 2)
 | 
			
		||||
		elseif sub(item, 1, 6) == "group|" then
 | 
			
		||||
			item = match(item, "([%w:_]+)$")
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		item = reg_aliases[item] or item
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@ Craft Guide=Guide de recettes
 | 
			
		||||
Crafting Guide=Guide de recettes
 | 
			
		||||
Crafting Guide Sign=Guide de recettes
 | 
			
		||||
Bookmarks=Favoris
 | 
			
		||||
Usage @1 of @2=Usage @1 de @2
 | 
			
		||||
Recipe @1 of @2=Recette @1 de @2
 | 
			
		||||
Usage @1 of @2=Usage @1 sur @2
 | 
			
		||||
Recipe @1 of @2=Recette @1 sur @2
 | 
			
		||||
No recipes=Pas de recettes
 | 
			
		||||
No usages=Pas d'usages
 | 
			
		||||
Burning time: @1=Temps de combustion : @1
 | 
			
		||||
@@ -53,7 +53,7 @@ No item to show=Aucun item à afficher
 | 
			
		||||
Collect items to reveal more recipes=Collecte des items pour révéler plus de recettes
 | 
			
		||||
Show recipe(s) of the pointed node=Affiche les recettes du bloc visé
 | 
			
		||||
No node pointed=Aucun bloc visé
 | 
			
		||||
You don't know a recipe or usage for this item=Tu ne connais aucune recette pour ce bloc
 | 
			
		||||
You don't know a recipe or usage for this item=Vous ne connaissez aucune recette pour ce bloc
 | 
			
		||||
No recipe or usage for this item=Aucune recette pour ce bloc
 | 
			
		||||
Digging=Destruction
 | 
			
		||||
Digging (by chance)=Destruction (par chance)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user