mirror of
				https://github.com/minetest-mods/craftguide.git
				synced 2025-11-04 06:55:30 +01:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			1.11b
			...
			aa47a70e12
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| aa47a70e12 | |||
| 0463712cbb | |||
| 1745cc0ba3 | |||
| 66fc47a1c3 | |||
| 
						 | 
					d6542a2697 | 
							
								
								
									
										189
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										189
									
								
								init.lua
									
									
									
									
									
								
							@@ -79,7 +79,7 @@ local IPP   = ROWS * LINES
 | 
				
			|||||||
local WH_LIMIT = 8
 | 
					local WH_LIMIT = 8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local XOFFSET = sfinv_only and 3.83 or 11.2
 | 
					local XOFFSET = sfinv_only and 3.83 or 11.2
 | 
				
			||||||
local YOFFSET = sfinv_only and 6 or 1
 | 
					local YOFFSET = sfinv_only and 4.9 or 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local PNG = {
 | 
					local PNG = {
 | 
				
			||||||
	bg       = "craftguide_bg.png",
 | 
						bg       = "craftguide_bg.png",
 | 
				
			||||||
@@ -556,7 +556,7 @@ local function get_usages(item)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_burntime(item)
 | 
					local function get_burntime(item)
 | 
				
			||||||
	return get_craft_result{method = "fuel", items = {item}}.time
 | 
						return get_craft_result({method = "fuel", items = {item}}).time
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function cache_fuel(item)
 | 
					local function cache_fuel(item)
 | 
				
			||||||
@@ -639,19 +639,6 @@ local function repairable(tool)
 | 
				
			|||||||
	return toolrepair and def and def.groups and def.groups.disable_repair ~= 1
 | 
						return toolrepair and def and def.groups and def.groups.disable_repair ~= 1
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function is_fav(data)
 | 
					 | 
				
			||||||
	local fav, i
 | 
					 | 
				
			||||||
	for j = 1, #data.favs do
 | 
					 | 
				
			||||||
		if data.favs[j] == data.query_item then
 | 
					 | 
				
			||||||
			fav = true
 | 
					 | 
				
			||||||
			i = j
 | 
					 | 
				
			||||||
			break
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return fav, i
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function get_desc(name)
 | 
					local function get_desc(name)
 | 
				
			||||||
	local def = reg_items[name]
 | 
						local def = reg_items[name]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -867,7 +854,8 @@ local function get_grid_fs(fs, rcp, spacing)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if CORE_VERSION >= 510 and not large_recipe then
 | 
							if CORE_VERSION >= 510 and not large_recipe then
 | 
				
			||||||
			fs[#fs + 1] = fmt(FMT.image,
 | 
								fs[#fs + 1] = fmt(FMT.image,
 | 
				
			||||||
				X, Y + (sfinv_only and 0.7 or 0), btn_size, btn_size, PNG.selected)
 | 
									X, Y + (sfinv_only and 0.7 or 0),
 | 
				
			||||||
 | 
									btn_size, btn_size, PNG.selected)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fs[#fs + 1] = fmt(FMT.item_image_button,
 | 
							fs[#fs + 1] = fmt(FMT.item_image_button,
 | 
				
			||||||
@@ -903,58 +891,33 @@ local function get_grid_fs(fs, rcp, spacing)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_panels(data, fs)
 | 
					local function get_panels(data, fs)
 | 
				
			||||||
	local start_y = CORE_VERSION >= 520 and 0 or 0.33
 | 
						local panels = {recipes = data.recipes or {}, usages = data.usages or {}}
 | 
				
			||||||
	local panels = {
 | 
						local x = 0.33
 | 
				
			||||||
		{dat = data.usages or {}, height = 3.5},
 | 
					 | 
				
			||||||
		{dat = data.recipes or {}, height = 3.5},
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if CORE_VERSION >= 520 and not sfinv_only then
 | 
						if sfinv_only then
 | 
				
			||||||
		panels.favs = {dat = {}, height = 2.19}
 | 
							panels = data.show_usages and {usages = data.usages} or {recipes = data.recipes}
 | 
				
			||||||
	elseif sfinv_only then
 | 
					 | 
				
			||||||
		panels = data.show_usages and
 | 
					 | 
				
			||||||
			{{dat = data.usages}} or {{dat = data.recipes}}
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for k, v in pairs(panels) do
 | 
						for k, v in pairs(panels) do
 | 
				
			||||||
		start_y = start_y + 1
 | 
							x = x + 1
 | 
				
			||||||
		local spacing = (start_y - 1) * 3.6
 | 
							local spacing = (x - 1) * 3.6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if not sfinv_only then
 | 
							if not sfinv_only then
 | 
				
			||||||
			fs[#fs + 1] = CORE_VERSION >= 510 and
 | 
								fs[#fs + 1] = CORE_VERSION >= 510 and
 | 
				
			||||||
				fmt("background9[8.1,%f;6.6,%f;%s;false;%d]",
 | 
									fmt("background9[8.1,%f;6.6,3.5;%s;false;%d]",
 | 
				
			||||||
					-0.2 + spacing, v.height, PNG.bg_full, 10) or
 | 
										-0.2 + spacing, PNG.bg_full, 10) or
 | 
				
			||||||
				fmt("background[8.1,%f;6.6,%f;%s;false]",
 | 
									fmt("background[8.1,%f;6.6,3.5;%s;false]",
 | 
				
			||||||
					-0.2 + spacing, v.height, PNG.bg_full)
 | 
										-0.2 + spacing, PNG.bg_full)
 | 
				
			||||||
 | 
					 | 
				
			||||||
			if k ~= "favs" then
 | 
					 | 
				
			||||||
				local fav = is_fav(data)
 | 
					 | 
				
			||||||
				local nfavs = #data.favs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				fs[#fs + 1] = fmt(
 | 
					 | 
				
			||||||
					"style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
 | 
					 | 
				
			||||||
					fmt("craftguide_fav%s.png", fav and "" or "_off"),
 | 
					 | 
				
			||||||
					fmt("craftguide_fav%s.png", fav and "_off" or ""),
 | 
					 | 
				
			||||||
					fmt("craftguide_fav%s.png", fav and "_off" or ""))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if nfavs < 6 or (nfavs >= 6 and fav) then
 | 
					 | 
				
			||||||
					fs[#fs + 1] = fmt(FMT.image_button,
 | 
					 | 
				
			||||||
						14, spacing, 0.5, 0.45, "", "fav", "")
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				fs[#fs + 1] = fmt("tooltip[fav;%s]",
 | 
					 | 
				
			||||||
					fav and ES"Unmark this item" or ES"Mark this item")
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		local rn = #v.dat
 | 
							local rn = #v
 | 
				
			||||||
		local _rn = tostring(rn)
 | 
							local _rn = tostring(rn)
 | 
				
			||||||
		local xu = tostring(data.unum) .. _rn
 | 
							local xu = tostring(data.unum) .. _rn
 | 
				
			||||||
		local xr = tostring(data.rnum) .. _rn
 | 
							local xr = tostring(data.rnum) .. _rn
 | 
				
			||||||
		xu = max(-0.3, -((#xu - 3) * 0.05))
 | 
							xu = max(-0.3, -((#xu - 3) * 0.15))
 | 
				
			||||||
		xr = max(-0.3, -((#xr - 3) * 0.05))
 | 
							xr = max(-0.3, -((#xr - 3) * 0.15))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		local is_recipe = k == 2
 | 
							local is_recipe = k == "recipes"
 | 
				
			||||||
		local lbl
 | 
							local lbl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if not sfinv_only and rn == 0 then
 | 
							if not sfinv_only and rn == 0 then
 | 
				
			||||||
@@ -975,14 +938,14 @@ local function get_panels(data, fs)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		fs[#fs + 1] = fmt(FMT.label,
 | 
							fs[#fs + 1] = fmt(FMT.label,
 | 
				
			||||||
			XOFFSET + (sfinv_only and 2.3 or 1.6) + (is_recipe and xr or xu),
 | 
								XOFFSET + (sfinv_only and 2.3 or 1.6) + (is_recipe and xr or xu),
 | 
				
			||||||
			YOFFSET + (sfinv_only and 2.3 or 1.5 + spacing), lbl)
 | 
								YOFFSET + (sfinv_only and 3.35 or 1.5 + spacing), lbl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if rn > 1 then
 | 
							if rn > 1 then
 | 
				
			||||||
			local btn_suffix = is_recipe and "recipe" or "usage"
 | 
								local btn_suffix = is_recipe and "recipe" or "usage"
 | 
				
			||||||
			local prev_name = fmt("prev_%s", btn_suffix)
 | 
								local prev_name = fmt("prev_%s", btn_suffix)
 | 
				
			||||||
			local next_name = fmt("next_%s", btn_suffix)
 | 
								local next_name = fmt("next_%s", btn_suffix)
 | 
				
			||||||
			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 2.2 or 1.4 + spacing)
 | 
								local y_arrow = YOFFSET + (sfinv_only and 3.25 or 1.4 + spacing)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if CORE_VERSION >= 520 then
 | 
								if CORE_VERSION >= 520 then
 | 
				
			||||||
				fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
 | 
									fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
 | 
				
			||||||
@@ -997,28 +960,10 @@ local function get_panels(data, fs)
 | 
				
			|||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		local rcp = is_recipe and v.dat[data.rnum] or v.dat[data.unum]
 | 
							local rcp = is_recipe and v[data.rnum] or v[data.unum]
 | 
				
			||||||
		if rcp then
 | 
							if rcp then
 | 
				
			||||||
			get_grid_fs(fs, rcp, spacing)
 | 
								get_grid_fs(fs, rcp, spacing)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if k == "favs" and CORE_VERSION >= 520 and not sfinv_only then
 | 
					 | 
				
			||||||
			fs[#fs + 1] = fmt(FMT.label, 8.3, spacing - 0.1, ES"Bookmarks")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			for i = 1, #data.favs do
 | 
					 | 
				
			||||||
				local item = data.favs[i]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if data.query_item == item then
 | 
					 | 
				
			||||||
					fs[#fs + 1] = fmt(FMT.image,
 | 
					 | 
				
			||||||
						7.85 + (i - 0.5), spacing + 0.45,
 | 
					 | 
				
			||||||
						1.1, 1.1, PNG.selected)
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				fs[#fs + 1] = fmt(FMT.item_image_button,
 | 
					 | 
				
			||||||
					7.85 + (i - 0.5), spacing + 0.45,
 | 
					 | 
				
			||||||
					1.1, 1.1, item, item, "")
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1026,14 +971,16 @@ local function make_formspec(name)
 | 
				
			|||||||
	local data = pdata[name]
 | 
						local data = pdata[name]
 | 
				
			||||||
	local fs = {}
 | 
						local fs = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fs[#fs + 1] = fmt([[
 | 
					 | 
				
			||||||
		size[%f,%f]
 | 
					 | 
				
			||||||
		no_prepend[]
 | 
					 | 
				
			||||||
		bgcolor[#0000]
 | 
					 | 
				
			||||||
	]],
 | 
					 | 
				
			||||||
	ROWS + (data.query_item and 6.7 or 0) - 1.2, LINES - 0.3)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if not sfinv_only then
 | 
						if not sfinv_only then
 | 
				
			||||||
 | 
							fs[#fs + 1] = fmt([[
 | 
				
			||||||
 | 
								size[%f,%f]
 | 
				
			||||||
 | 
								no_prepend[]
 | 
				
			||||||
 | 
								bgcolor[#0000]
 | 
				
			||||||
 | 
								style_type[image_button;border=false]
 | 
				
			||||||
 | 
								style_type[item_image_button;border=false;bgimg_hovered=%s]
 | 
				
			||||||
 | 
							]],
 | 
				
			||||||
 | 
							ROWS + (data.query_item and 6.7 or 0) - 1.2, LINES - 0.3, PNG.selected)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fs[#fs + 1] = CORE_VERSION >= 510 and
 | 
							fs[#fs + 1] = CORE_VERSION >= 510 and
 | 
				
			||||||
			fmt("background9[-0.15,-0.2;%f,%f;%s;false;%d]",
 | 
								fmt("background9[-0.15,-0.2;%f,%f;%s;false;%d]",
 | 
				
			||||||
				ROWS - 0.9, LINES + 0.4, PNG.bg_full, 10) or
 | 
									ROWS - 0.9, LINES + 0.4, PNG.bg_full, 10) or
 | 
				
			||||||
@@ -1049,18 +996,15 @@ local function make_formspec(name)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if CORE_VERSION >= 520 then
 | 
						if CORE_VERSION >= 520 then
 | 
				
			||||||
		fs[#fs + 1] = fmt([[
 | 
							fs[#fs + 1] = fmt([[
 | 
				
			||||||
			style_type[image_button;border=false]
 | 
					 | 
				
			||||||
			style_type[item_image_button;border=false;bgimg_hovered=%s;bgimg_pressed=%s]
 | 
					 | 
				
			||||||
			style[search;fgimg=%s;fgimg_hovered=%s]
 | 
								style[search;fgimg=%s;fgimg_hovered=%s]
 | 
				
			||||||
			style[clear;fgimg=%s;fgimg_hovered=%s]
 | 
								style[clear;fgimg=%s;fgimg_hovered=%s]
 | 
				
			||||||
			style[prev_page;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
 | 
								style[prev_page;fgimg=%s;fgimg_hovered=%s]
 | 
				
			||||||
			style[next_page;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
 | 
								style[next_page;fgimg=%s;fgimg_hovered=%s]
 | 
				
			||||||
		]],
 | 
							]],
 | 
				
			||||||
		PNG.selected, PNG.selected,
 | 
					 | 
				
			||||||
		PNG.search, PNG.search_hover,
 | 
							PNG.search, PNG.search_hover,
 | 
				
			||||||
		PNG.clear, PNG.clear_hover,
 | 
							PNG.clear,  PNG.clear_hover,
 | 
				
			||||||
		PNG.prev, PNG.prev_hover, PNG.prev_hover,
 | 
							PNG.prev,   PNG.prev_hover,
 | 
				
			||||||
		PNG.next, PNG.next_hover, PNG.next_hover)
 | 
							PNG.next,   PNG.next_hover)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 4),
 | 
							fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 4),
 | 
				
			||||||
			sfinv_only and 2.6 or 2.54, -0.06, 0.85, 0.85, "", "search", "",
 | 
								sfinv_only and 2.6 or 2.54, -0.06, 0.85, 0.85, "", "search", "",
 | 
				
			||||||
@@ -1376,20 +1320,20 @@ local function handle_drops_table(name, drop)
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for item, count in pairs(drop_sure) do
 | 
						for item, count in pairs(drop_sure) do
 | 
				
			||||||
		craftguide.register_craft{
 | 
							craftguide.register_craft({
 | 
				
			||||||
			type = "digging",
 | 
								type = "digging",
 | 
				
			||||||
			items = {name},
 | 
								items = {name},
 | 
				
			||||||
			output = fmt("%s %u", item, count),
 | 
								output = fmt("%s %u", item, count),
 | 
				
			||||||
		}
 | 
							})
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for item, data in pairs(drop_maybe) do
 | 
						for item, data in pairs(drop_maybe) do
 | 
				
			||||||
		craftguide.register_craft{
 | 
							craftguide.register_craft({
 | 
				
			||||||
			type = "digging_chance",
 | 
								type = "digging_chance",
 | 
				
			||||||
			items = {name},
 | 
								items = {name},
 | 
				
			||||||
			output = fmt("%s %u", item, data.output),
 | 
								output = fmt("%s %u", item, data.output),
 | 
				
			||||||
			rarity = data.rarity,
 | 
								rarity = data.rarity,
 | 
				
			||||||
		}
 | 
							})
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1398,11 +1342,11 @@ local function register_drops(name, def)
 | 
				
			|||||||
	local dstack = ItemStack(drop)
 | 
						local dstack = ItemStack(drop)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if not dstack:is_empty() and dstack:get_name() ~= name then
 | 
						if not dstack:is_empty() and dstack:get_name() ~= name then
 | 
				
			||||||
		craftguide.register_craft{
 | 
							craftguide.register_craft({
 | 
				
			||||||
			type = "digging",
 | 
								type = "digging",
 | 
				
			||||||
			items = {name},
 | 
								items = {name},
 | 
				
			||||||
			output = drop,
 | 
								output = drop,
 | 
				
			||||||
		}
 | 
							})
 | 
				
			||||||
	elseif is_table(drop) then
 | 
						elseif is_table(drop) then
 | 
				
			||||||
		handle_drops_table(name, drop)
 | 
							handle_drops_table(name, drop)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
@@ -1472,7 +1416,7 @@ local function get_init_items()
 | 
				
			|||||||
		last_str = str
 | 
							last_str = str
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local full_char, empty_char = "▰", "▱"
 | 
						local full_char, empty_char = "o", "."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for name, def in pairs(reg_items) do
 | 
						for name, def in pairs(reg_items) do
 | 
				
			||||||
		ic = ic + 1
 | 
							ic = ic + 1
 | 
				
			||||||
@@ -1482,7 +1426,7 @@ local function get_init_items()
 | 
				
			|||||||
			bar = bar .. (i <= percent / (100 / len) and full_char or empty_char)
 | 
								bar = bar .. (i <= percent / (100 / len) and full_char or empty_char)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		iop(fmt("[craftguide] Caching data  %s  %u%%\r", bar, percent))
 | 
							iop(fmt("[craftguide] Caching data  %s  %u%%\n", bar, percent))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if show_item(def) then
 | 
							if show_item(def) then
 | 
				
			||||||
			if not fuel_cache[name] then
 | 
								if not fuel_cache[name] then
 | 
				
			||||||
@@ -1513,10 +1457,10 @@ local function get_init_items()
 | 
				
			|||||||
			fuel    = fuel_cache,
 | 
								fuel    = fuel_cache,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		http.fetch_async{
 | 
							http.fetch_async({
 | 
				
			||||||
			url = craftguide.export_url,
 | 
								url = craftguide.export_url,
 | 
				
			||||||
			post_data = write_json(post_data),
 | 
								post_data = write_json(post_data),
 | 
				
			||||||
		}
 | 
							})
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	print()
 | 
						print()
 | 
				
			||||||
@@ -1531,7 +1475,6 @@ local function init_data(name)
 | 
				
			|||||||
		pagenum   = 1,
 | 
							pagenum   = 1,
 | 
				
			||||||
		items     = items,
 | 
							items     = items,
 | 
				
			||||||
		items_raw = items,
 | 
							items_raw = items,
 | 
				
			||||||
		favs      = {},
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1594,18 +1537,6 @@ local function fields(player, _f)
 | 
				
			|||||||
			data.pagenum = data.pagemax
 | 
								data.pagenum = data.pagemax
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return true, show_fs(player, name)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	elseif _f.fav then
 | 
					 | 
				
			||||||
		local fav, i = is_fav(data)
 | 
					 | 
				
			||||||
		local total = #data.favs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if total < 6 and not fav then
 | 
					 | 
				
			||||||
			data.favs[total + 1] = data.query_item
 | 
					 | 
				
			||||||
		elseif fav then
 | 
					 | 
				
			||||||
			remove(data.favs, i)
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return true, show_fs(player, name)
 | 
							return true, show_fs(player, name)
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		local item
 | 
							local item
 | 
				
			||||||
@@ -1727,29 +1658,29 @@ else
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	core.register_craft{
 | 
						core.register_craft({
 | 
				
			||||||
		output = "craftguide:book",
 | 
							output = "craftguide:book",
 | 
				
			||||||
		type   = "shapeless",
 | 
							type   = "shapeless",
 | 
				
			||||||
		recipe = {"default:book"}
 | 
							recipe = {"default:book"}
 | 
				
			||||||
	}
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	core.register_craft{
 | 
						core.register_craft({
 | 
				
			||||||
		type = "fuel",
 | 
							type = "fuel",
 | 
				
			||||||
		recipe = "craftguide:book",
 | 
							recipe = "craftguide:book",
 | 
				
			||||||
		burntime = 3
 | 
							burntime = 3
 | 
				
			||||||
	}
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	core.register_craft{
 | 
						core.register_craft({
 | 
				
			||||||
		output = "craftguide:sign",
 | 
							output = "craftguide:sign",
 | 
				
			||||||
		type   = "shapeless",
 | 
							type   = "shapeless",
 | 
				
			||||||
		recipe = {"default:sign_wall_wood"}
 | 
							recipe = {"default:sign_wall_wood"}
 | 
				
			||||||
	}
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	core.register_craft{
 | 
						core.register_craft({
 | 
				
			||||||
		type = "fuel",
 | 
							type = "fuel",
 | 
				
			||||||
		recipe = "craftguide:sign",
 | 
							recipe = "craftguide:sign",
 | 
				
			||||||
		burntime = 10
 | 
							burntime = 10
 | 
				
			||||||
	}
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if rawget(_G, "sfinv_buttons") then
 | 
						if rawget(_G, "sfinv_buttons") then
 | 
				
			||||||
		sfinv_buttons.register_button("craftguide", {
 | 
							sfinv_buttons.register_button("craftguide", {
 | 
				
			||||||
@@ -1965,29 +1896,29 @@ if progressive_mode then
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		data.hud = {
 | 
							data.hud = {
 | 
				
			||||||
			bg = player:hud_add{
 | 
								bg = player:hud_add({
 | 
				
			||||||
				hud_elem_type = "image",
 | 
									hud_elem_type = "image",
 | 
				
			||||||
				position      = {x = 0.78, y = 1},
 | 
									position      = {x = 0.78, y = 1},
 | 
				
			||||||
				alignment     = {x = 1,    y = 1},
 | 
									alignment     = {x = 1,    y = 1},
 | 
				
			||||||
				scale         = {x = 370,  y = 112},
 | 
									scale         = {x = 370,  y = 112},
 | 
				
			||||||
				text          = PNG.bg,
 | 
									text          = PNG.bg,
 | 
				
			||||||
			},
 | 
								}),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			book = player:hud_add{
 | 
								book = player:hud_add({
 | 
				
			||||||
				hud_elem_type = "image",
 | 
									hud_elem_type = "image",
 | 
				
			||||||
				position      = {x = 0.79, y = 1.02},
 | 
									position      = {x = 0.79, y = 1.02},
 | 
				
			||||||
				alignment     = {x = 1,    y = 1},
 | 
									alignment     = {x = 1,    y = 1},
 | 
				
			||||||
				scale         = {x = 4,    y = 4},
 | 
									scale         = {x = 4,    y = 4},
 | 
				
			||||||
				text          = PNG.book,
 | 
									text          = PNG.book,
 | 
				
			||||||
			},
 | 
								}),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			text = player:hud_add{
 | 
								text = player:hud_add({
 | 
				
			||||||
				hud_elem_type = "text",
 | 
									hud_elem_type = "text",
 | 
				
			||||||
				position      = {x = 0.84, y = 1.04},
 | 
									position      = {x = 0.84, y = 1.04},
 | 
				
			||||||
				alignment     = {x = 1,    y = 1},
 | 
									alignment     = {x = 1,    y = 1},
 | 
				
			||||||
				number        = 0xfff,
 | 
									number        = 0xfff,
 | 
				
			||||||
				text          = "",
 | 
									text          = "",
 | 
				
			||||||
			},
 | 
								}),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	end)
 | 
						end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2098,3 +2029,5 @@ register_command("craft", {
 | 
				
			|||||||
		return true, craftguide.show(name, node_name)
 | 
							return true, craftguide.show(name, node_name)
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.log("action", "[craftguide] loaded.")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ License of source code
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
The MIT License (MIT)
 | 
					The MIT License (MIT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Copyright (c) 2015-2020 Jean-Patrick Guerrero and contributors.
 | 
					Copyright (c) 2015-2019 Jean-Patrick Guerrero and contributors.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
				
			||||||
of this software and associated documentation files (the "Software"), to deal
 | 
					of this software and associated documentation files (the "Software"), to deal
 | 
				
			||||||
 
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 916 B  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 1.8 KiB  | 
		Reference in New Issue
	
	Block a user