Module:CraftingDPL: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function explode(inputstr, sep) | function p.explode(inputstr, sep) | ||
local t={} | local t={} | ||
local i=1 | local i=1 | ||
Line 13: | Line 13: | ||
function p.parseCats(frame) | function p.parseCats(frame) | ||
local s = tostring(frame.args[1]) | local s = tostring(frame.args[1]) | ||
local arr = explode(s, ";") | local arr = p.explode(s, ";") | ||
local s2 = "" | local s2 = "" | ||
for k,v in pairs(arr) do | for k,v in pairs(arr) do |
Revision as of 19:30, 13 February 2014
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(inputstr, sep)
local t={}
local i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i+1
end
return t
end
function p.parseCats(frame)
local s = tostring(frame.args[1])
local arr = p.explode(s, ";")
local s2 = ""
for k,v in pairs(arr) do
s2 = s2.."[[Category:Recipe using "..v.."]] "
end
return s2
end
return p