Various fixes

This commit is contained in:
Jean-Patrick Guerrero 2018-11-11 19:34:26 +01:00
parent 9625542468
commit 8b309106c3

View File

@ -101,7 +101,7 @@ function craftguide:get_tooltip(item, recipe_type, cooktime, groups)
return has_extras and tooltip .. "]" or "" return has_extras and tooltip .. "]" or ""
end end
function craftguide:get_recipe(iY, xoffset, tooltip, item, recipe_num, recipes, show_usage) function craftguide:get_recipe(iY, xoffset, recipe_num, recipes, show_usage)
local formspec, recipes_total = "", #recipes local formspec, recipes_total = "", #recipes
if recipes_total > 1 then if recipes_total > 1 then
formspec = formspec .. formspec = formspec ..
@ -161,9 +161,8 @@ function craftguide:get_recipe(iY, xoffset, tooltip, item, recipe_num, recipes,
"image[" .. (xoffset - 1) .. "," .. (iY + 2.35) .. "image[" .. (xoffset - 1) .. "," .. (iY + 2.35) ..
";0.9,0.7;craftguide_arrow.png]" .. ";0.9,0.7;craftguide_arrow.png]" ..
"item_image_button[" .. (xoffset - 2) .. "," .. (iY + 2.2) .. ";1,1;" .. "item_image_button[" .. (xoffset - 2) .. "," .. (iY + 2.2) .. ";1,1;" ..
output .. ";" .. output .. ";" .. output .. ";]" ..
(show_usage and output or item) .. ";]" .. self:get_tooltip(output:match("%S+"))
tooltip
end end
function craftguide:get_formspec(player_name, is_fuel) function craftguide:get_formspec(player_name, is_fuel)
@ -221,21 +220,19 @@ function craftguide:get_formspec(player_name, is_fuel)
end end
if data.item and reg_items[data.item] then if data.item and reg_items[data.item] then
local tooltip = self:get_tooltip(data.item)
if not data.recipes_item or (is_fuel and not get_recipe(data.item).items) then if not data.recipes_item or (is_fuel and not get_recipe(data.item).items) then
formspec = formspec .. formspec = formspec ..
"image[" .. (xoffset - 1) .. "," .. (iY + 2.35) .. "image[" .. (xoffset - 1) .. "," .. (iY + 2.35) ..
";0.9,0.7;craftguide_arrow.png]" .. ";0.9,0.7;craftguide_arrow.png]" ..
"item_image_button[" .. xoffset .. "," .. (iY + 2.2) .. "item_image_button[" .. xoffset .. "," .. (iY + 2.2) ..
";1,1;" .. data.item .. ";" .. data.item .. ";]" .. ";1,1;" .. data.item .. ";" .. data.item .. ";]" ..
tooltip .. self:get_tooltip(data.item) ..
"image[" .. (xoffset - 2) .. "," .. "image[" .. (xoffset - 2) .. "," ..
(iY + 2.18) .. ";1,1;craftguide_fire.png]" (iY + 2.18) .. ";1,1;craftguide_fire.png]"
else else
local show_usage = data.show_usage local show_usage = data.show_usage
formspec = formspec .. formspec = formspec ..
self:get_recipe(iY, xoffset, tooltip, self:get_recipe(iY, xoffset,
data.item,
data.rnum, data.rnum,
(show_usage and data.usages or data.recipes_item), (show_usage and data.usages or data.recipes_item),
show_usage) show_usage)
@ -447,6 +444,8 @@ mt.register_on_player_receive_fields(function(player, formname, fields)
if item:find(":") then if item:find(":") then
if item:sub(-4) == "_inv" then if item:sub(-4) == "_inv" then
item = item:sub(1,-5) item = item:sub(1,-5)
elseif item:find("%s") then
item = item:match("%S*")
end end
local is_fuel = get_fueltime(item) > 0 local is_fuel = get_fueltime(item) > 0