편집 요약 없음
Minejango2 (토론 | 기여) 잔글편집 요약 없음 |
Alswo96284 (토론 | 기여) 편집 요약 없음 |
||
local prefixes = slot.i18n.prefixes
local function map(tbl, func)
local newtbl = {}
for i,v in pairs(tbl) do
newtbl[i] = func(v)
end ▼
return newtbl
end
-- Flatten a nested array, only doing the numerically-indexed parts.
local function flatten(tbl)
local newtbl = {}
local function _flat(arr)
for _, v in ipairs(arr) do
if type(v) == "table" and v[1] then
_flat(v)
else ▼
table.insert(newtbl, v)
end ▼
end ▼
end
_flat(tbl)
return newtbl
end
--[[Escapes special characters in ingredient names, and returns the correct
pattern depending on the match type
local escaped = Reverselink.xlink( ingredient:gsub( '([^%w])', patternChars ) )
if not matchTypes then
patterns[i] = '
else
local matchType = matchTypes[i] or matchTypes
if matchType == 'start' then
patterns[i] = '
elseif matchType == 'end' then
patterns[i] = escaped .. '
else
patterns[i] = escaped
-- Loops through the wanted ingredients, and checks if the name contains it
-- REQUIREMENT: name starts and ends with the NUL (\0) character. Simplifies operation
-- for multiple names in the variable.
local function containsIngredients( name, ingredientPatterns )
for _, ingredient in pairs( ingredientPatterns ) do
required frame numbers, or true if all of them are required
--]]
local function findRequiredFrameNums( parsedCArgs, ingredientPatterns )
local requiredFrameNums = {}
local hasRequiredFrames
for arg, frames in pairs( parsedCArgs ) do
if arg ~= 'Output' then
local requiredFrames = {}
local count = 0
for i, frame in ipairs( frames ) do
-- Guess what? If we only take the first we lose the subframes.
if containsIngredients( frame.name or frame[1].name, ingredientPatterns ) then▼
-- And then 'Cobblestone or Blackstone' starts breaking.
requiredFrames[i] = true▼
local tframe = frame[1] and flatten(frame) or { frame }
count = count + 1▼
local names = '\0' .. table.concat(map(tframe, function (fr) return type(fr) == 'table' and fr.name or '' end), '\0') .. '\0'
end▼
▲ end
▲ requiredFrames[i] = true
if count > 0 then▼
end
▲ if count > 0 then
if count == #frames then
hasRequiredFrames = true▼
return true
▲ end
requiredFrameNums[arg] = requiredFrames▼
▲ hasRequiredFrames = true
▲ end
▲ end
▲ requiredFrameNums[arg] = requiredFrames
end ▼
return hasRequiredFrames and requiredFrameNums▼
end
▲ return hasRequiredFrames and requiredFrameNums
end
end
--[[Performs the DPL query which retrieves the arguments from the crafting
templates on the pages within the requested categories.
If more than four categories are given, break them down into batches of four.
--]]
local function
return mw.getCurrentFrame():callParserFunction( '#dpl:', {▼
category = category,▼
if type(category) == 'string' then
nottitleregexp = ignore,▼
category = mw.text.split(category, '|')
include = '{' .. i18n.templateCrafting .. '}:' .. table.concat( argList, ':' ),▼
else
mode = 'userformat',▼
assert(type(category) == 'table')
secseparators = '====',▼
end
multisecseparators = '===='▼
local j = 1
local count = #category
local catSlice = table.concat(category, '|', i, math.min(i + 3, count))
▲ nottitleregexp = ignore,
include = includeStr,
▲ mode = 'userformat',
▲ secseparators = '====',
▲ multisecseparators = '===='
})
j = j + 1
end
end
local data
if args.category then
data =
else
-- Need to format the catparts
local catParts = text.split( i18n.queryCategory, '%$1' )
▲ data = {}
local
end)
▲ local catParts = text.split( i18n.queryCategory, '%$1' )
data = dplQueryWrapper( cats, args.ignore )
▲ for i = 1, ingredientCount, 4 do
▲ catParts[2] .. '|' .. catParts[1],
▲ )
▲ end
▲ data = table.concat( data )
end
|