Module:Equipment/Builds

local p = {} local cargo = mw.ext.cargo

function p.List( frame ) local args = frame.args local fieldstable = { "ItemIcon", "ItemName", "ItemType", "BaseType", "Rarity", "ItemBase", "LevelReq", "ImplicitType", "ImplicitAmount", "SecondImplicitType", "SecondImplicitAmount", "ThirdImplicitType", "ThirdImplicitAmount", "WeaponRange", "affix1", "affix2", "affix3", "affix4", "SetMod1", "SetMod2", "SetName", "flavortext", "Sellprice", "_pageName", }   local tables = 'Equipment' local fields = table.concat(fieldstable,",") -- optional parameters are grouped in one table -- you can omit any or all of them, except joinOn if you use more than one table local cargoquery = { where = args.where, orderBy= args.orderby } local result = mw.ext.cargo.query( tables, fields, cargoquery )

local fieldstable2 = { "ShardName", "Icon", "AffixNickname", "AffixType", "Hybrid", "Modifier", "Modifier2", "ApplicableEquip", "ModT1Min", "ModT1Max", "ModT2Min", "ModT2Max", "ModT3Min", "ModT3Max", "ModT4Min", "ModT4Max", "ModT5Min", "ModT5Max", "Mod2T1Min", "Mod2T1Max", "Mod2T2Min", "Mod2T2Max", "Mod2T3Min", "Mod2T3Max", "Mod2T4Min", "Mod2T4Max", "Mod2T5Min", "Mod2T5Max", "_pageName", }   local tables2 = 'Shards' local fields2 = table.concat(fieldstable2,",") -- optional parameters are grouped in one table -- you can omit any or all of them, except joinOn if you use more than one table local cargoquery2 = { where = args.where2 } local result2 = mw.ext.cargo.query( tables2, fields2, cargoquery2 )

local prebuildstable = mw.text.split( args.equipmentlist, ";" ) local buildstable = { } for i,v in ipairs(prebuildstable) do     table.insert( buildstable, mw.text.split( v, ",")) end

if result[1] == nil then return args.default

elseif result[1] ~= nil then --Start the table local tbl = mw.html.create('table') tbl:addClass('wikitable sortable mw-datatable') tbl:tag("th"):wikitext("Equipment"):done tbl:tag("th"):wikitext("Implicits"):done tbl:tag("th"):wikitext("Shard 1"):done tbl:tag("th"):wikitext("Shard 2"):done tbl:tag("th"):wikitext("Shard 3"):done tbl:tag("th"):wikitext("Shard 4"):done tbl:done --Construct the rows in the table for i,v in ipairs(buildstable) do	 for _,row in ipairs(result) do            if (row._pageName == v[1]) then tr = tbl:tag("tr") tr:tag("td"):css("text-align", "center"):wikitext("" .. row.ItemName .. " "):done tr:tag("td"):wikitext( row.ImplicitAmount .. ' ' .. row.ImplicitType .. (row.SecondImplicitAmount ~= '' and row.SecondImplicitAmount and ' ' or ) .. (row.SecondImplicitAmount or ) .. (row.SecondImplicitType ~=  and ' ' or ) .. row.SecondImplicitType .. (row.ThirdImplicitAmount ~= '' and row.ThirdImplicitAmount and ' ' or ) .. (row.ThirdImplicitAmount or ) .. (row.ThirdImplicitType ~=  and ' ' or ) .. row.ThirdImplicitType .. (row.WeaponRange ~= '' and row.WeaponRange and ' Weapon Range: ' or ) .. (row.WeaponRange or ) .. (row.WeaponRange ~=  and row.WeaponRange and 'm' or ) ):done if (row.Rarity == 'Unique' or row.Rarity == 'Set') then tr:tag("td"):wikitext( row.affix1 ):done tr:tag("td"):wikitext( row.affix2 ):done tr:tag("td"):wikitext( row.affix3 ):done tr:tag("td"):wikitext( row.affix4 ):done else for h,k in ipairs(result2) do                   if (k._pageName == v[2]) then tr:tag("td"):css("text-align","center"):wikitext( "" .. k.ShardName .. " - \"" ..k.AffixNickname .."\"" ):tag('table'):addClass('wikitable'):css("margin-left", "auto"):css("margin-right","auto"):tag("tr"):tag("th"):attr("colspan","5"):wikitext(k.Modifier):tag("tr"):tag("td"):wikitext(k.ModT1Min .. "-" .. k.ModT1Max):tag("td"):wikitext(k.ModT2Min .. "-" .. k.ModT2Max):tag("td"):wikitext(k.ModT3Min .. "-" .. k.ModT3Max):tag("td"):wikitext(k.ModT4Min .. "-" .. k.ModT4Max):tag("td"):wikitext(k.ModT5Min .. "-" .. k.ModT5Max ):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "th" or ):attr("colspan","5"):wikitext(k.Modifier2):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T1Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T1Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T2Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T2Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T3Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T3Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T4Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T4Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T5Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T5Max )                   end                 end                 for h,k in ipairs(result2) do                    if (k._pageName == v[3]) then                       tr:tag("td"):css("text-align","center"):wikitext( "" .. k.ShardName .. " - \"" ..k.AffixNickname .."\"" ):tag('table'):addClass('wikitable'):css("margin-left", "auto"):css("margin-right","auto"):tag("tr"):tag("th"):attr("colspan","5"):wikitext(k.Modifier):tag("tr"):tag("td"):wikitext(k.ModT1Min .. "-" .. k.ModT1Max):tag("td"):wikitext(k.ModT2Min .. "-" .. k.ModT2Max):tag("td"):wikitext(k.ModT3Min .. "-" .. k.ModT3Max):tag("td"):wikitext(k.ModT4Min .. "-" .. k.ModT4Max):tag("td"):wikitext(k.ModT5Min .. "-" .. k.ModT5Max ):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "th" or ):attr("colspan","5"):wikitext(k.Modifier2):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T1Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T1Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T2Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T2Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T3Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T3Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T4Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T4Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T5Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T5Max )                   end                 end                 for h,k in ipairs(result2) do                    if (k._pageName == v[4]) then                       tr:tag("td"):css("text-align","center"):wikitext( "" .. k.ShardName .. " - \"" ..k.AffixNickname .."\"" ):tag('table'):addClass('wikitable'):css("margin-left", "auto"):css("margin-right","auto"):tag("tr"):tag("th"):attr("colspan","5"):wikitext(k.Modifier):tag("tr"):tag("td"):wikitext(k.ModT1Min .. "-" .. k.ModT1Max):tag("td"):wikitext(k.ModT2Min .. "-" .. k.ModT2Max):tag("td"):wikitext(k.ModT3Min .. "-" .. k.ModT3Max):tag("td"):wikitext(k.ModT4Min .. "-" .. k.ModT4Max):tag("td"):wikitext(k.ModT5Min .. "-" .. k.ModT5Max ):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "th" or ):attr("colspan","5"):wikitext(k.Modifier2):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T1Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T1Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T2Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T2Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T3Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T3Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T4Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T4Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T5Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T5Max )                   end                 end                 for h,k in ipairs(result2) do                    if (k._pageName == v[5]) then                       tr:tag("td"):css("text-align","center"):wikitext( "" .. k.ShardName .. " - \"" ..k.AffixNickname .."\"" ):tag('table'):addClass('wikitable'):css("margin-left", "auto"):css("margin-right","auto"):tag("tr"):tag("th"):attr("colspan","5"):wikitext(k.Modifier):tag("tr"):tag("td"):wikitext(k.ModT1Min .. "-" .. k.ModT1Max):tag("td"):wikitext(k.ModT2Min .. "-" .. k.ModT2Max):tag("td"):wikitext(k.ModT3Min .. "-" .. k.ModT3Max):tag("td"):wikitext(k.ModT4Min .. "-" .. k.ModT4Max):tag("td"):wikitext(k.ModT5Min .. "-" .. k.ModT5Max ):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "th" or ):attr("colspan","5"):wikitext(k.Modifier2):tag(k.Modifier2 ~=  and "tr" or ):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T1Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T1Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T2Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T2Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T3Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T3Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T4Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T4Max):tag(k.Modifier2 ~=  and "td" or ):wikitext(k.Mod2T5Min .. (k.Modifier2 ~=  and "-" or ) .. k.Mod2T5Max )                   end                 end               end             end	 end         end	 return tbl    end --  . . . end return p