Module:Products: Difference between revisions
"pre-sort by output item" doesnt work because it was sorting by page that had the recipe, instead simply sort by level of the recipe
(extend module to work on data from Profession info as well as Infobox Recipe) |
("pre-sort by output item" doesnt work because it was sorting by page that had the recipe, instead simply sort by level of the recipe) |
||
Line 12:
local function recipe_sort(recipe_a, recipe_b)
--if
if (recipe_a.level == nil) ~= (recipe_b.level == nil) then
return recipe_b.level == nil
end
-- if
return recipe_a.output[1].name < recipe_b.output[1].name
end▼
-- if neither is nil, sort first by level
if recipe_a.level ~= recipe_b.level then
return recipe_a.level < recipe_b.level
end
--
return recipe_a.output[1].name < recipe_b.output[1].name
end
Line 49 ⟶ 55:
end
-- Create a list of all recipes
local
for _, product in ipairs(smw_data) do
-- this part will need to be addressed if a page has both a recipe and an activity
local jsons = product['Recipe JSON'] or product['Activity JSON']
if type(jsons) == 'string' then
jsons = { jsons }
end
for _, json in ipairs(jsons) do
local json = mw.text.jsonDecode(json)
Line 64 ⟶ 70:
return mat.name == item
end) then
table.insert(
end
end
end
-- Sort list of recipes by the
table.sort(
▲ if first1 == nil then
▲ end
-- Calculate shop prices
|