Module:Skills/Artisan: Difference between revisions

Use printError function
(Added exception to fix case where Bird Nest Potion has the wrong name in code.)
(Use printError function)
Line 101: Line 101:
categoryID = 'melvorF:SkillPotions'
categoryID = 'melvorF:SkillPotions'
else
else
return 'ERROR: No such potion category ' .. (categoryName or 'nil') .. '[[Category:Pages with script errors]]'
return Shared.printError('No such potion category ' .. (categoryName or 'nil'))
end
end


Line 162: Line 162:
local recipe = GameData.getEntityByName(SkillData.Herblore.recipes, potionName)
local recipe = GameData.getEntityByName(SkillData.Herblore.recipes, potionName)
if recipe == nil then
if recipe == nil then
return 'ERROR: No potion named "' .. potionName .. '" was found[[Category:Pages with script errors]]'
return Shared.printError('No potion named "' .. potionName .. '" was found')
end
end


Line 221: Line 221:
-- Validation: Parameters
-- Validation: Parameters
if type(skillName) ~= 'string' then
if type(skillName) ~= 'string' then
return 'ERROR: skillName must be a string'
return Shared.printError('skillName must be a string')
elseif not Shared.contains({'string', 'nil'}, type(categoryName)) then
elseif not Shared.contains({'string', 'nil'}, type(categoryName)) then
return 'ERROR: category must be a string or nil'
return Shared.printError('category must be a string or nil')
elseif type(columnList) ~= 'table' or Shared.tableIsEmpty(columnList) then
elseif type(columnList) ~= 'table' or Shared.tableIsEmpty(columnList) then
return 'ERROR: columnList must be a table with 1+ elements'
return Shared.printError('columnList must be a table with 1+ elements')
end
end


Line 234: Line 234:
}
}
if not Shared.contains(supportedSkills, skillName) then
if not Shared.contains(supportedSkills, skillName) then
return 'ERROR: The ' .. skillName .. ' skill is not supported by this function'
return Shared.printError('The ' .. skillName .. ' skill is not supported by this function')
end
end


Line 244: Line 244:
table.insert(catNames, cat.name)
table.insert(catNames, cat.name)
end
end
return 'ERROR: No such category ' .. categoryName .. ' for skill ' .. skillName .. ', the following are available: ' .. table.concat(catNames, ', ')
return Shared.printError('No such category ' .. categoryName .. ' for skill ' .. skillName .. ', the following are available: ' .. table.concat(catNames, ', '))
end
end
local actionInterval = SkillData[skillName].baseInterval/1000
local actionInterval = SkillData[skillName].baseInterval/1000
Line 251: Line 251:
local recipeKey = 'recipes'
local recipeKey = 'recipes'
if SkillData[skillName] == nil then
if SkillData[skillName] == nil then
return 'ERROR: Could not locate skill data for ' .. skillName
return Shared.printError('Could not locate skill data for ' .. skillName)
elseif SkillData[skillName][recipeKey] == nil then
elseif SkillData[skillName][recipeKey] == nil then
return 'ERROR: Could not locate recipe data for ' .. skillName
return Shared.printError('Could not locate recipe data for ' .. skillName)
end
end


Line 272: Line 272:
for i, colID in ipairs(columnList) do
for i, colID in ipairs(columnList) do
if columnDef[colID] == nil then
if columnDef[colID] == nil then
return 'ERROR: Invalid column ' .. colID .. ' requested'
return Shared.printError('Invalid column ' .. colID .. ' requested')
else
else
table.insert(resultPart, '\r\n! ' .. columnDef[colID].header)
table.insert(resultPart, '\r\n! ' .. columnDef[colID].header)