Module:CraftingDPL
Returns a list of categories based on the string of items that are used for crafting. Used in the creation of DPL categories for crafting templates.
local p = {}
function p.explode(delimiter, text)
local list = {}; local pos = 1
if string.find("", delimiter, 1) then
-- We'll look at error handling later!
error("delimiter matches empty string!")
end
while 1 do
local first, last = string.find(text, delimiter, pos)
if first then
table.insert(list, string.sub(text, pos, first-1))
pos = last+1
else
table.insert(list, string.sub(text, pos))
break
end
end
return list
end
function p.parseCats(frame)
local s = tostring(frame.args[1])
local arr = p.explode(";", s)
local s2 = "1"
for i=1, #arr do
s2 = s2 .. "[[Category:Recipe using " .. arr[i] .. "]] "
end
return "\[\[Category:Recipe using " .. arr[1] .. "\]\]"
end
return p