Minor edits

This commit is contained in:
Jean-Patrick Guerrero 2018-11-12 12:51:18 +01:00
parent 39ed2c2c45
commit 5fce8ddbda

View File

@ -17,7 +17,6 @@ craftguide.intllib = S
-- https://github.com/kilbith/xdecor/blob/master/handlers/helpers.lua#L1 -- https://github.com/kilbith/xdecor/blob/master/handlers/helpers.lua#L1
local remove, maxn, sort = table.remove, table.maxn, table.sort local remove, maxn, sort = table.remove, table.maxn, table.sort
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
local unpack = unpack
local DEFAULT_SIZE = 10 local DEFAULT_SIZE = 10
local MIN_LIMIT, MAX_LIMIT = 9, 12 local MIN_LIMIT, MAX_LIMIT = 9, 12
@ -60,8 +59,7 @@ local function extract_groups(str)
end end
local function colorize(str) local function colorize(str)
-- If client <= 0.4.14, don't colorize for compatibility. return mt.colorize("#FFFF00", str)
return mt.colorize and mt.colorize("#FFFF00", str) or str
end end
local function get_fueltime(item) local function get_fueltime(item)
@ -233,13 +231,16 @@ function craftguide:get_formspec(player_name, is_fuel)
if data.item and reg_items[data.item] then if data.item and reg_items[data.item] then
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 + (sfinv_only and 2.85 or 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 + (sfinv_only and 2.7 or 2.2)) ..
";1,1;" .. data.item .. ";" .. data.item .. ";]" .. ";1,1;" .. data.item .. ";" .. data.item .. ";]" ..
self:get_tooltip(data.item) .. self:get_tooltip(data.item) ..
"image[" .. (xoffset - 2) .. "," .. "image[" .. (xoffset - 2) .. "," ..
(iY + 2.18) .. ";1,1;craftguide_fire.png]" (iY + (sfinv_only and 2.68 or 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 ..
@ -407,25 +408,21 @@ function craftguide:get_item_usages(item)
end end
local function get_fields(player, ...) local function get_fields(player, ...)
local args = {...} local args, formname, fields = {...}
local formname, fields if sfinv_only then
if #args == 1 then
formname = "craftguide"
fields = args[1] fields = args[1]
else else
formname, fields = unpack(args) formname, fields = args[1], args[2]
end end
if formname ~= "craftguide" then return end if not sfinv_only and formname ~= "craftguide" then return end
local player_name = player:get_player_name() local player_name = player:get_player_name()
local data = datas[player_name] local data = datas[player_name]
local show_fs = function(is_fuel) local show_fs = function(is_fuel)
local context = sfinv.get_or_create_context(player)
context.fuel = is_fuel
if sfinv_only then if sfinv_only then
local context = sfinv.get_or_create_context(player)
context.fuel = is_fuel
sfinv.set_player_inventory_formspec(player, context) sfinv.set_player_inventory_formspec(player, context)
else else
craftguide:get_formspec(player_name, is_fuel) craftguide:get_formspec(player_name, is_fuel)