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, libU = loader.require('String', 'Table', 'LibU')

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

return p