Anonymous

Module:Items/ComparisonTables: Difference between revisions

From Melvor Idle
Added Desert Gloves to overrides, added includeDescription option
(Added style overrides on a few things)
(Added Desert Gloves to overrides, added includeDescription option)
Line 17: Line 17:


local styleOverrides = {
local styleOverrides = {
   Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves'},
   Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Gloves'},
   Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)'},
   Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)'},
   Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves'},
   Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves'},
Line 23: Line 23:
}
}


function p._getEquipmentTable(itemList, includeModifiers)
function p._getEquipmentTable(itemList, includeModifiers, includeDescription)
   if includeModifiers == nil then includeModifiers = false end
   if includeModifiers == nil then includeModifiers = false end


Line 94: Line 94:
     result = result..'\r\n!colspan="'..lvlReqCols..'"style="padding:0 0.5em 0 0.5em;"|Lvl Req'
     result = result..'\r\n!colspan="'..lvlReqCols..'"style="padding:0 0.5em 0 0.5em;"|Lvl Req'
   end
   end
   if includeModifiers then
   if includeModifiers and includeDescription then
    result = result..'\r\n!colspan="3"|'
  elseif includeModifiers or includeDescription then
     result = result..'\r\n!colspan="2"|'
     result = result..'\r\n!colspan="2"|'
   else
   else
Line 163: Line 165:
   if includeModifiers then
   if includeModifiers then
     result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Modifiers'
     result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Modifiers'
  end
  --If includeDescription is set to 'true', add the Description column
  if includeDescription then
    result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Description'
   end
   end


Line 196: Line 202:
         result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
         result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
         result = result..Constants.getModifiersText(item.modifiers, true)
         result = result..Constants.getModifiersText(item.modifiers, true)
      end
      --If requested, add description
      if includeDescription then
        result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
        result = result..(item.description ~= nil and item.description or '')
       end
       end
       --Finally, the Sources
       --Finally, the Sources
Line 220: Line 231:
         result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
         result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
         result = result..Constants.getModifiersText(item.modifiers, true)
         result = result..Constants.getModifiersText(item.modifiers, true)
      end
      --If requested, add description
      if includeDescription then
        result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
        result = result..(item.description ~= nil and item.description or '')
       end
       end
       --Finally, the Sources
       --Finally, the Sources
Line 292: Line 308:
end
end


function p._getCategoryTable(style, slot, other, includeModifiers)
function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription)
   if type(slot) == 'string' then
   if type(slot) == 'string' then
     slot = Constants.getEquipmentSlotID(slot)
     slot = Constants.getEquipmentSlotID(slot)
Line 340: Line 356:
     end)
     end)


   return p._getEquipmentTable(itemList, includeModifiers)
   return p._getEquipmentTable(itemList, includeModifiers, includeDescription)
end
end


Line 348: Line 364:
   local other = frame.args ~= nil and frame.args[3] or frame[3]
   local other = frame.args ~= nil and frame.args[3] or frame[3]
   local includeModifiers = frame.args ~= nil and frame.args.includeModifiers or frame.includeModifiers
   local includeModifiers = frame.args ~= nil and frame.args.includeModifiers or frame.includeModifiers
  local includeDescription = frame.args ~= nil and frame.args.includeDescription or frame.includeDescription


   includeModifiers = includeModifiers ~= nil and string.upper(includeModifiers) == 'TRUE' or false
   includeModifiers = includeModifiers ~= nil and string.upper(includeModifiers) == 'TRUE' or false
  includeDescription = includeDescription ~= nil and string.upper(includeDescription) == 'TRUE' or false


   return p._getCategoryTable(style, slot, other, includeModifiers)
   return p._getCategoryTable(style, slot, other, includeModifiers, includeDescription)
end
end