Anonymous

Module:Skills: Difference between revisions

From Melvor Idle
getMasteryUnlockTable: Ensure content is sorted by mastery level
(getSkillUnlockCostTable: Fix to include all skills, even if they don't have an explicitly defined unlock cost)
(getMasteryUnlockTable: Ensure content is sorted by mastery level)
Line 235: Line 235:


local _, localSkillID = GameData.getLocalID(skillID)
local _, localSkillID = GameData.getLocalID(skillID)
local unlockTable = SkillData[localSkillID].masteryLevelUnlocks
-- Clone so that we can sort by level
local unlockTable = Shared.clone(SkillData[localSkillID].masteryLevelUnlocks)
if unlockTable == nil then
if unlockTable == nil then
return 'ERROR: Failed to find Mastery Unlock data for '..skillName
return 'ERROR: Failed to find Mastery Unlock data for '..skillName
end
end
table.sort(unlockTable, function(a, b) return (a.level == b.level and a.descriptionID < b.descriptionID) or a.level < b.level end)


local result = '{|class="wikitable"\r\n!Level!!Unlock'
local result = '{|class="wikitable"\r\n!Level!!Unlock'