Module:Items: Difference between revisions

Added ability to force number formatting on getItemStat
(Created a currently empty p.getItemCategories function)
(Added ability to force number formatting on getItemStat)
Line 103: Line 103:
   local StatName = args[2]
   local StatName = args[2]
   local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false'
   local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false'
  local FormatNum = args.FormatNum ~= nil and args.FormatNum ~= '' and args.FormatNum ~= 'false'
   local item = p.getItem(ItemName)
   local item = p.getItem(ItemName)
   if item == nil then
   if item == nil then
     return "ERROR: No item named "..ItemName.." exists in the data module"
     return "ERROR: No item named "..ItemName.." exists in the data module"
   end
   end
   return p._getItemStat(item, StatName, ZeroIfNil)
   local result = p._getItemStat(item, StatName, ZeroIfNil)
  if FormatNum then result = Shared.formatnum(result) end
  return result
end
end