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, invslotDatasheet = loader.lazy.loadData('Pet/Data', 'Minion/Data', 'Minion/Aliases', 'RarityTier/Data', 'Statname/Data', 'Skillname/Data', 'Collection/Data', 'Staff/Members', 'Enchantment/Data', 'Potion/Data', 'Inventory slot/Datasheet')

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' })

-- This utility is to be run in the console using =p.getUnknownCharacters function p.getUnknownCharacters -- please provide here a list of known code points (IF IN BASE 16, PREPEND NUMBER WITH 0x) -- it is assumed that 0x0000-0x00FF are known, without needing to specify below local knownCharacters = { 0x2002, 0x2800, 0x3000, 0x2248, 0x221e, 0x00b0, 0x00f1, 0x2584, 0x03b1, 0x2741, 0x2764, 0x2748, 0x2742, 0x2726, 0x270e, 0x2623, 0x2620, 0x2694, 0x2afd, 0x272f, 0x2663, 0x0e51, 0x2e15, 0x2727, 0x2618, 0x2e0e, 0x02ac, 0x2668, 0x24c5, 0x2602, 0x262f, 0x0b8f, 0x2b31, 0x168f, 0x1805, 0x2763, 0x2706, 0x272a, 0x2600, 0x263d, 0x23e3, 0x270c, 0x2672, 0x26a0, 0x25c6, 0x273f, 0x266a, 0x266b, 0x24ea, 0x25b2, 0x204d, 0x269a, 0x2716, 0x2714, 0x279c, 0xfd3e, 0xfd3f, 0x262c, 0x2604, 0x2691, 0x24b6, 0x24b7, 0x24b8, 0x24b9, 0x24ba, 0x24bb, 0x24bc, 0x24bd, 0x24be, 0x24bf, 0x24c0, 0x24c1, 0x24c2, 0x24c3, 0x24c4, 0x24c5, 0x24c6, 0x24c7, 0x24c8, 0x24c9, 0x24ca, 0x24cb, 0x24cc, 0x24cd, 0x24ce, 0x24cf, 0x263a, 0x265e, 0x2737, 0x2624, 0x29be, 0x0489, 0x1750, 0x2051, 0x046a, 0x24c4, 0x2665, 0x2122, 0xfb17, 0x2197, 0x25b8, 0x16e4, 0x22d7, 0xfe35, 0x253b, 0x2501, 0x256f, 0x25a1, 0x00a6, 0x00a9, 0x222b, 0x26bd, 0x25ac, 0x25cb, 0x26a1, 0x25b6, 0x25fc, 0x127e, 0x2692, 0x2190, 0x2192, 0x25bc, 0x2713, 0x2730, 0x2023, 0x2581, 0x2582, 0x2583, 0x2585, 0x2586, 0x2022, 0x27a4, 0x2019, 0x21e6, 0x21e8, 0x27a1, }	-- please specify if it should print in hexadecimal local printInHex = true -- please specify if it should also print the character out local appendCharacter = true -- main program local knownCharactersMap = {} for _, kc in ipairs(knownCharacters) do		knownCharactersMap[kc] = true end local unknownCharactersMap = {} local function chkstr(s) if #s == 0 then return end local codepoints = { mw.ustring.codepoint(s, 1, #s) } for _, cp in pairs(codepoints) do			if cp > 0xFF and not knownCharactersMap[cp] and not unknownCharactersMap[cp] then unknownCharactersMap[cp] = true end end end -- check all characters appearing in invslot datasheet for key, value in pairs(invslotDatasheet) do		if value.title then chkstr(value.title) end if value.text then chkstr(value.text) end end -- check all characters appearing in statname for key, value in pairs(statdata) do		if value.character then chkstr(value.character) end end -- print all unknown characters for uc, _ in pairs(unknownCharactersMap) do mw.log((printInHex and string.format('%x', uc) or uc) .. (appendCharacter and ('(' .. mw.ustring.char(uc) .. ')') or '')) end mw.log('The above results were printed in base ' .. (printInHex and '16.' or '10.')) end

return p