Anonymous

Module:Shop: Difference between revisions

From Melvor Idle
130 bytes removed ,  27 December 2022
Use printError function
(getToolTable: Move from Module:Skills/Gathering; getCookingUtilityTable: Use getToolTable & implement additional modifier columns)
(Use printError function)
(One intermediate revision by the same user not shown)
Line 75: Line 75:


if Shared.tableIsEmpty(purchaseList) then
if Shared.tableIsEmpty(purchaseList) then
return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]"
return Shared.printError("Couldn't find purchase with name '" .. purchaseName .. "'")
else
else
local resultPart = {}
local resultPart = {}
Line 283: Line 283:
             table.insert(reqArray, reqText)
             table.insert(reqArray, reqText)
         else
         else
             table.insert(reqArray, 'ERROR: Unknown requirement: ' .. (req.type or 'nil') .. '[[Category:Pages with script errors]]')
             table.insert(reqArray, Shared.printError('Unknown requirement: ' .. (req.type or 'nil')))
         end
         end
     end
     end
Line 364: Line 364:


if purchase == nil then
if purchase == nil then
return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]"
return Shared.printError("Couldn't find purchase with name '" .. purchaseName .. "'")
else
else
return p._getPurchaseContents(purchase, asList)
return p._getPurchaseContents(purchase, asList)
Line 405: Line 405:
if purchase == nil then
if purchase == nil then
return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]"
return Shared.printError("Couldn't find purchase with name '" .. purchaseName .. "'")
else
else
return p._getPurchaseBuyLimit(purchase, asList)
return p._getPurchaseBuyLimit(purchase, asList)
Line 437: Line 437:


if purchase == nil then
if purchase == nil then
return "ERROR: Couldn't find purchase with name '" .. tostring(purchaseName) .. "'[[Category:Pages with script errors]]"
return Shared.printError("Couldn't find purchase with name '" .. tostring(purchaseName) .. "'")
else
else
args[1] = purchase
args[1] = purchase
Line 606: Line 606:
     local shopCat = GameData.getEntityByName('shopCategories', cat)
     local shopCat = GameData.getEntityByName('shopCategories', cat)
if shopCat == nil then
if shopCat == nil then
return 'ERROR: Invalid category '..cat..'[[Category:Pages with script errors]]'
return Shared.printError('Invalid category ' .. cat)
else
else
         local catPurchases = p.getPurchases(function(purch) return purch.category == shopCat.id end)
         local catPurchases = p.getPurchases(function(purch) return purch.category == shopCat.id end)
Line 683: Line 683:
local item = Items.getItem(itemName)
local item = Items.getItem(itemName)
if item == nil then
if item == nil then
return "ERROR: No item named "..itemName.." exists in the data module"
return Shared.printError('No item named ' .. itemName .. ' exists in the data module')
end
end


Line 958: Line 958:
local validCategories = {'Cooking Fire', 'Furnace', 'Pot'}
local validCategories = {'Cooking Fire', 'Furnace', 'Pot'}
if category == nil or not Shared.contains({'Cooking Fire', 'Furnace', 'Pot'}, category) then
if category == nil or not Shared.contains({'Cooking Fire', 'Furnace', 'Pot'}, category) then
return 'ERROR: Invalid category specified. Must be one of the following: ' .. mw.text.listToText(validCategories, ', ', ' or ')
return Shared.printError('Invalid category specified. Must be one of the following: ' .. mw.text.listToText(validCategories, ', ', ' or '))
end
end


Line 965: Line 965:
['Cooking Fire'] = {
['Cooking Fire'] = {
{ name = 'increasedSkillXP', skillID = 'melvorD:Cooking', header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP', sign = '+', suffix = '%' },
{ name = 'increasedSkillXP', skillID = 'melvorD:Cooking', header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP', sign = '+', suffix = '%' },
{ name = 'increasedChancePerfectCookFire', header = 'Fire Perfect Cook Chance', sign ='+', suffix = '%' },
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '-', suffix = '%' },
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '-', suffix = '%' },
{ name = 'increasedChancePerfectCookFire', header = 'Fire Perfect Cook Chance', sign ='+', suffix = '%' },
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' },
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' },
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '-', suffix = '%' }
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '-', suffix = '%' }