1
0
Fork 0

`mcl_craftguide`: Autoformat and fix misleading variable names

This commit is contained in:
AFCMS 2022-11-22 23:34:45 +01:00
parent a3fbb2e0c9
commit f8e934c1dd
Signed by untrusted user: AFCMS
GPG Key ID: 8720389A25B652E3
1 changed files with 63 additions and 63 deletions

View File

@ -24,11 +24,11 @@ local ESC = M.formspec_escape
local S = M.get_translator("mcl_craftguide") local S = M.get_translator("mcl_craftguide")
local maxn, sort, concat, insert, copy = local maxn, sort, concat, insert, copy =
table.maxn, table.sort, table.concat, table.insert, table.maxn, table.sort, table.concat, table.insert,
table.copy table.copy
local fmt, find, gmatch, match, sub, split, lower = local fmt, find, gmatch, match, sub, split, lower =
string.format, string.find, string.gmatch, string.match, string.format, string.find, string.gmatch, string.match,
string.sub, string.split, string.lower string.sub, string.split, string.lower
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
@ -192,7 +192,7 @@ function mcl_craftguide.set_recipe_filter(name, f)
assert(name, func .. "filter name missing") assert(name, func .. "filter name missing")
assert(f and type(f) == "function", func .. "filter function missing") assert(f and type(f) == "function", func .. "filter function missing")
recipe_filters = {[name] = f} recipe_filters = { [name] = f }
end end
function mcl_craftguide.get_recipe_filters() function mcl_craftguide.get_recipe_filters()
@ -305,7 +305,7 @@ local function get_item_usages(item)
end end
if fuel_cache[item] then if fuel_cache[item] then
usages[#usages + 1] = {type = "fuel", width = 1, items = {item}} usages[#usages + 1] = { type = "fuel", width = 1, items = { item } }
end end
return usages return usages
@ -373,7 +373,7 @@ local function get_recipes(item, data, player)
end end
local function get_burntime(item) local function get_burntime(item)
return get_result({method = "fuel", width = 1, items = {item}}).time return get_result({ method = "fuel", width = 1, items = { item } }).time
end end
local function cache_fuel(item) local function cache_fuel(item)
@ -430,13 +430,13 @@ local function get_tooltip(item, groups, cooktime, burntime)
tooltip = groupstr tooltip = groupstr
else else
local groupstr, c = {}, 0 local grouptable, c = {}, 0
for i = 1, #groups do for i = 1, #groups do
c = c + 1 c = c + 1
groupstr[c] = colorize(gcol, groups[i]) grouptable[c] = colorize(gcol, groups[i])
end end
groupstr = concat(groupstr, ", ") groupstr = concat(grouptable, ", ")
tooltip = S("Any item belonging to the groups: @1", groupstr) tooltip = S("Any item belonging to the groups: @1", groupstr)
end end
else else
@ -475,7 +475,7 @@ local function get_recipe_fs(data, iY)
end end
local rows = ceil(maxn(recipe.items) / width) local rows = ceil(maxn(recipe.items) / width)
local rightest, btn_size, s_btn_size = 0, 1.1 local rightest, btn_size, s_btn_size = 0, 1.1, nil
local btn_lab = data.show_usages and local btn_lab = data.show_usages and
ESC(S("Usage @1 of @2", data.rnum, #data.recipes)) or ESC(S("Usage @1 of @2", data.rnum, #data.recipes)) or
@ -741,7 +741,7 @@ mcl_craftguide.add_search_filter("groups", function(item, groups)
for i = 1, #groups do for i = 1, #groups do
local group = groups[i] local group = groups[i]
if not itemdef.groups[group] then if not itemdef.groups[group] then
has_groups = nil has_groups = false
break break
end end
end end