Module:Skills/Artisan: Difference between revisions

getPotionTable: Move from Module:Items
(category -> categoryID)
(getPotionTable: Move from Module:Items)
Line 151: Line 151:
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
return p._getHerblorePotionTable(category)
return p._getHerblorePotionTable(category)
end
function p.getPotionTable(frame)
local potionName = frame.args ~= nil and frame.args[1] or frame
local recipe = GameData.getEntityByName(SkillData.Herblore.recipes, potionName)
if recipe == nil then
return 'ERROR: No potion named "' .. potionName .. '" was found[[Category:Pages with script errors]]'
end
local resultPart = {}
table.insert(resultPart, '{| class="wikitable"')
table.insert(resultPart, '\r\n!Potion!!Tier!!Charges!!Effect')
for i, potionID in ipairs(recipe.potionIDs) do
local tier = tierSuffix[i]
local potion = Items.getItemByID(potionID)
if potion ~= nil then
local potDesc = potion.customDescription or ''
if potDesc == '' and type(potion.modifiers) == 'table' and not Shared.tableIsEmpty(potion.modifiers) then
potDesc = Constants.getModifiersText(potion.modifiers, false) or ''
end
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n| ' .. Icons.Icon({potion.name, type='item', notext=true, size='60'}))
table.insert(resultPart, '|| ' .. Icons.Icon({potion.name, tier, type='item', noicon=true}))
table.insert(resultPart, '|| ' .. potion.charges .. '|| ' .. potDesc)
end
end
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end
end