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 ignorelist = opts.ignorelist 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		local str = retkey and v[retkey] or k		if (not (ignorelist and table.includes(ignorelist, str))) then ret[#ret + 1] = string.ucfirst(str) end 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, { ignorelist = { '7t' } }) p.allStats = libU.bind(genericSort, statdata, { retkey = 'name' })

return p