Module:Calculator Update

--- -- This module is for getting a list of values, useful for updating calculator fields -- -- ---

local loader = require('Module:Loader')

local string, table = loader.require('String', 'Table')

local petdata, miniondata, minionaliases, raritydata, statdata, skilldata, collectiondata, staffmembers, enchantmentdata, potiondata = loader.loadData('Pet/Data', 'Minion/Data', 'Minion/Aliases', 'RarityTier/Data', 'Statname/Data', 'Skillname/Data', 'Collection/Data', 'Staff/Members', 'Enchantment/Data', 'Potion/Data')

local p = {}

local function genericSort(data, opts) opts = opts or {} local sortkey = opts.sortkey local retkey = opts.retkey local ret = {} for k, v in (sortkey and table.sortedPairsByValue(data, function(a, b)		return a[sortkey] < b[sortkey] end) or table.sortedPairs(data)) do		ret[#ret + 1] = string.ucfirst(retkey and v[retkey] or k)	end return table.concat(ret, ',') end

p.allCollections = bind(genericSort, collectiondata) p.allEnchantments = bind(genericSort, enchantmentdata) p.allFuel = bind(genericSort, minionaliases.fuelData) p.allMinions = bind(genericSort, miniondata) p.allPets = bind(genericSort, petdata) p.allPotions = bind(genericSort, potiondata) -- ERROR ? p.allRarities = bind(genericSort, raritydata, { sortkey = 'order', retkey = 'name' }) p.allSkills = bind(genericSort, skilldata, { retkey = 'name' }) p.allStaff = bind(genericSort, staffmembers) p.allStats = bind(genericSort, statdata, { retkey = 'name' })

return p