12,704
edits
Falterfire (talk | contribs) (Added npcId to getThievingSourcesForItem) |
(Use printError function) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 68: | Line 68: | ||
local npc = p.getThievingNPC(npcName) | local npc = p.getThievingNPC(npcName) | ||
if npc == nil then | if npc == nil then | ||
return | 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 | return Shared.printError('Failed to find a skill ID for ' .. skillName) | ||
end | end | ||
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 ' | 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) | |||
local result = '{|class="wikitable"\r\n!Level!!Unlock' | local result = '{|class="wikitable"\r\n!Level!!Unlock' | ||
Line 253: | Line 255: | ||
local skillID = Constants.getSkillID(skillName) | local skillID = Constants.getSkillID(skillName) | ||
if skillID == nil then | if skillID == nil then | ||
return | return Shared.printError('Failed to find a skill ID for ' .. skillName) | ||
end | end | ||
Line 259: | Line 261: | ||
local checkpoints = SkillData[localSkillID].masteryCheckpoints | local checkpoints = SkillData[localSkillID].masteryCheckpoints | ||
if checkpoints == nil then | if checkpoints == nil then | ||
return ' | return Shared.printError('Failed to find Mastery Unlock data for ' .. skillName) | ||
end | end | ||
Line 325: | Line 327: | ||
local advMode = GameData.getEntityByID('gamemodes', 'melvorF:Adventure') | local advMode = GameData.getEntityByID('gamemodes', 'melvorF:Adventure') | ||
if advMode ~= nil then | if advMode ~= nil then | ||
local unlockCount = Shared.tableCount(GameData.skillData) - Shared.tableCount(advMode.startingSkills) | |||
local costLength = Shared.tableCount(advMode.skillUnlockCost) | |||
local returnPart = {} | local returnPart = {} | ||
table.insert(returnPart, '{| class="wikitable stickyHeader"\r\n|- class="headerRow-0"\r\n!Unlock!!Cost!!Cumulative Cost') | table.insert(returnPart, '{| class="wikitable stickyHeader"\r\n|- class="headerRow-0"\r\n!Unlock!!Cost!!Cumulative Cost') | ||
local accCost = 0 | local accCost = 0 | ||
for i, cost | for i = 1, unlockCount, 1 do | ||
local cost = advMode.skillUnlockCost[math.min(i, costLength)] | |||
accCost = accCost + cost | accCost = accCost + cost | ||
table.insert(returnPart, '|-') | table.insert(returnPart, '|-') | ||
Line 349: | 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 ' | return Shared.printError('Invalid Smithing category: "' .. tableType .. '"') | ||
end | end | ||