Module:SimilarEquipment

local cargo = mw.ext.cargo local Equipment = require('Module:Equipment').List

local p = {} function p.Shell( frame ) local args = frame.args local fieldstable = { "ItemName", "ItemType", "BaseType", "Rarity", "ItemBase", "LevelReq", "ImplicitType", "ImplicitAmount", "SecondImplicitType", "SecondImplicitAmount", "ThirdImplicitType", "ThirdImplicitAmount", "WeaponRange", "affix1", "affix2", "affix3", "affix4", "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 = ('ItemName="%s"'):format(args.name) } local row = cargo.query( tables, fields, cargoquery )[1] if not row then return args.default end if row.Rarity == 'Unique' then return args.default end local simquery = Equipment{where = ('ItemType="%s" AND Rarity="%s" AND (ImplicitType%s OR SecondImplicitType%s OR ThirdImplicitType%s) AND (ImplicitType%s %s SecondImplicitType%s %s ThirdImplicitType%s) AND (ImplicitType%s OR SecondImplicitType%s %s ThirdImplicitType%s) AND NOT ItemName="%s"'):format(row.ItemType,row.Rarity,(row.ImplicitType ~=  and '="' .. row.ImplicitType .. '" ' or ' IS NULL '),(row.ImplicitType ~=  and '="' .. row.ImplicitType .. '" ' or ' IS NULL '),(row.ImplicitType ~=  and '="' .. row.ImplicitType .. '" ' or ' IS NULL '),(row.SecondImplicitType ~=  and '="' .. row.SecondImplicitType .. '" ' or ' IS NULL '),(row.ImplicitType ==  and 'AND' or 'OR'),(row.SecondImplicitType ~=  and '="' .. row.SecondImplicitType .. '" ' or ' IS NULL '),(row.ImplicitType ==  and 'AND' or 'OR'),(row.SecondImplicitType ~=  and '="' .. row.SecondImplicitType .. '" ' or ' IS NULL '),(row.ThirdImplicitType ~= '' and '="' .. row.ThirdImplicitType .. '" ' or ' IS NULL '),(row.ThirdImplicitType ~= '' and '="' .. row.ThirdImplicitType .. '" ' or ' IS NULL '),(row.SecondImplicitType ==  and 'AND' or 'OR'),(row.ThirdImplicitType ~=  and '="' .. row.ThirdImplicitType .. '" ' or ' IS NULL '),row.ItemName) }   if not simquery then return args.default end    return mw.html.create:wikitext(' Similar Equipment \nThe following similar equipment has the same implicit modifiers and equipment type, however they may have differing names, models, base types, or implicit values.'), simquery end --  . . . return p