Module:Skills: Difference between revisions

Use printError function
(getMasteryUnlockTable: Ensure content is sorted by mastery level)
(Use printError function)
Line 68: Line 68:
local npc = p.getThievingNPC(npcName)
local npc = p.getThievingNPC(npcName)
if npc == nil then
if npc == nil then
return "ERROR: Invalid Thieving NPC "..npcName.."[[Category:Pages with script errors]]"
return Shared.printError('Invalid Thieving NPC ' .. npcName)
end
end


Line 231: Line 231:
local skillID = Constants.getSkillID(skillName)
local skillID = Constants.getSkillID(skillName)
if skillID == nil then
if skillID == nil then
return "ERROR: Failed to find a skill ID for "..skillName
return Shared.printError('Failed to find a skill ID for ' .. skillName)
end
end


Line 238: Line 238:
local unlockTable = Shared.clone(SkillData[localSkillID].masteryLevelUnlocks)
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 Shared.printError('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)
table.sort(unlockTable, function(a, b) return (a.level == b.level and a.descriptionID < b.descriptionID) or a.level < b.level end)
Line 255: Line 255:
local skillID = Constants.getSkillID(skillName)
local skillID = Constants.getSkillID(skillName)
if skillID == nil then
if skillID == nil then
return "ERROR: Failed to find a skill ID for "..skillName
return Shared.printError('Failed to find a skill ID for ' .. skillName)
end
end


Line 261: Line 261:
local checkpoints = SkillData[localSkillID].masteryCheckpoints
local checkpoints = SkillData[localSkillID].masteryCheckpoints
if checkpoints == nil then
if checkpoints == nil then
return 'ERROR: Failed to find Mastery Unlock data for '..skillName
return Shared.printError('Failed to find Mastery Unlock data for ' .. skillName)
end
end


Line 354: Line 354:
local category = GameData.getEntityByName(SkillData.Smithing.categories, tableType)
local category = GameData.getEntityByName(SkillData.Smithing.categories, tableType)
if category == nil then
if category == nil then
return 'ERROR: Invalid Smithing category: "' .. tableType .. '"[[Category:Pages with script errors]]'
return Shared.printError('Invalid Smithing category: "' .. tableType .. '"')
end
end