- 欢迎光临Satisfactory国区BWIKI。请登录您的B站账号,方可使用页面编辑与评论功能。
全站通知:
模块:RecipeUsage
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:RecipeUsage/doc创建
local p = {}
local cargo = mw.ext.cargo
p.argList = {
'_pageName', 'alternateRecipe', 'recipeName', 'researchTier', 'craftingTime',
'product', 'productCount', 'productsPerMinute',
'product2', 'productCount2', 'productsPerMinute2',
'product3', 'productCount3', 'productsPerMinute3',
'product4', 'productCount4', 'productsPerMinute4',
'ingredient1', 'quantity1', 'ingredient2', 'quantity2', 'ingredient3', 'quantity3',
'ingredient4', 'quantity4', 'ingredient5', 'quantity5', 'ingredient6', 'quantity6',
'ingredient7', 'quantity7', 'ingredient8', 'quantity8', 'ingredient9', 'quantity9',
'ingredient10', 'quantity10'
}
--[[Creates recipe table for given recipes
--]]
local function createTable(recipes)
local tbl = {}
for i, recipe in ipairs(recipes) do
if i == #recipes then
recipe.tableEnd = 1
end
recipe.structure = 'hidden'
recipe.makeVisible = 1
tbl[i] = mw.getCurrentFrame():expandTemplate{title='CraftingTable', args=recipe}
end
return table.concat(tbl)
end
p.table = function(frame)
local ingredient = mw.title.getCurrentTitle().text
local fields = table.concat(p.argList, ',')
local languageCheck = ''
if string.match(mw.title.getCurrentTitle():fullUrl(), "satisfactory.gamepedia") then
local pageContent = mw.title.getCurrentTitle():getContent()
local languageCategory = string.match(pageContent, "%[%[Category:([%w%s%-]-) -translation%]%]")
if languageCategory == nil then languageCategory = "" end
if mw.language.isKnownLanguageTag(string.lower(languageCategory)) then
languageCheck = '(_pageName like "%/' .. string.lower(languageCategory) .. '" OR _pageName not like "%/%") AND '
if mw.title.getCurrentTitle().isSubpage and mw.language.isKnownLanguageTag(mw.title.getCurrentTitle().subpageText) then
ingredient = string.match(pageContent, "{{Infobox .-= ?(.-)\n")
end
else
languageCheck = '_pageName not like "%/%" AND '
end
end
if ingredient == nil then
return 'no valid ingredient given, no data to show'
end
local args = {
where = languageCheck .. 'product IS NOT NULL AND (ingredient1="' .. ingredient .. '" OR ingredient2="' .. ingredient .. '" OR ingredient3="' .. ingredient .. '" OR ingredient4="' .. ingredient .. '" OR ingredient5="' .. ingredient .. '" OR ingredient6="' .. ingredient .. '" OR ingredient7="' .. ingredient .. '" OR ingredient8="' .. ingredient .. '" OR ingredient9="' .. ingredient .. '" OR ingredient10="' .. ingredient .. '")',
orderBy = 'alternateRecipe ASC, researchTier ASC, product ASC'
}
local recipes = cargo.query('crafting_recipes', fields, args)
return createTable(recipes)
end
return p