Module:Equipment

local p = {}

local EquipmentData = mw.loadData( 'Module:Configdata/Equipment' ) local RankData     = mw.loadData( 'Module:Configdata/Rank' ) local ArmyData     = mw.loadData( 'Module:Configdata/Army' )

function p.getEquipment(NameID) local equipment = EquipmentData[NameID] -- try direct access via ID   if equipment ~= nil then return equipment else                                   -- apparently not found, so input may be a name and not an ID        for key, Equipment in Shared.skpairs(EquipmentData) do            if(Equipment.Name == NameID) then return Equipment end end end return nil end

local function getValue(Equipment, Value, giveDefault, asString) if(giveDefault == nil) then giveDefault = false end if(asString == nil) then asString = false end if Equipment == nil then return nil end ValName = string.upper(Value) if(ValName == "NAME") then if(Equipment.Name ~= nil) then return Equipment.Name else if (asString) then return "" else return nil end end

elseif(ValName == "TYPE") then -- EquipmentType_Weapon return Equipment.EquipmentType:sub(15)

elseif(ValName == "RARITY") then return RankData[Equipment.Rank].Desc

elseif(ValName == "DESCRIPTION") then return Equipment.Desc

elseif(ValName == "Icon") then -- "UI/Icon/Equip_ABS/Equip_Dagger1.png" return Equipment.Icon:sub(19)

elseif(ValName == "ARMY") then local t = { } for k,v in ipairs(Equipment.ArmyIds) do           t[#t+1] = ArmyData[v].Name end return table.concat(t,"\n") end

end

return p