Jump to: navigation, search

Module:CraftingDPL: Difference between revisions

No edit summary
No edit summary
Line 5: Line 5:
     local arr = explode(";", s)
     local arr = explode(";", s)
     local s2 = ""
     local s2 = ""
     for k,v in pairs(arr) do s2 = s2.."[[Category:Recipe using "..v.."]] " end
     for v in arr do s2 = s2.."[[Category:Recipe using "..v.."]] " end
     return s2
     return s2
end
end
Line 13: Line 13:
     local t={}
     local t={}
     local i=1
     local i=1
        for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
                t[i] = str
        t[i] = str
                i = i + 1
        i = i+1
        end
    end
        return t
    return t
end
end


return p
return p

Revision as of 19:18, 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.parseCats(frame)
    local s = tostring(frame.args[1])
    local arr = explode(";", s)
    local s2 = ""
    for v in arr do s2 = s2.."[[Category:Recipe using "..v.."]] " end
    return s2
end

function explode(inputstr, sep)
    if sep == nil then sep = "%s" end
    local t={}
    local i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i+1
    end
    return t
end

return p


Cookies help us deliver our services. By using our services, you agree to our use of cookies.