Module:Items: Difference between revisions

Added getSpecialAttackTable function
(Added 'Items With Special Attacks' category)
(Added getSpecialAttackTable function)
Line 322: Line 322:
   end
   end
   result = result..'\r\n|}'
   result = result..'\r\n|}'
  return result
end
function p.getSpecialAttackTable(frame)
  local spAttTable = {}
 
  for i, item in Shared.skpairs(ItemData.Items) do
    if item.hasSpecialAttack then
      if spAttTable[item.specialAttackID] == nil then spAttTable[item.specialAttackID] = {sortName=item.name, Icons = {}} end
      table.insert(spAttTable[item.specialAttackID].Icons, Icons.Icon({item.name, type='item'}))
    end
  end 
  local result = '{|class="wikitable sortable stickyHeader"'
  result = result..'\r\n|-class="headerRow-0"'
  result = result..'\r\n!Weapon(s)!!Name!!Chance!!Effect'
  for i, spAttData in Shared.skpairs(spAttTable) do
    local spAtt = p.getSpecialAttackByID(i)
    result = result..'\r\n|-'
    result = result..'\r\n|data-sort-value="'..spAttData.sortName..'"|'..table.concat(spAttData.Icons, '<br/>')
    result = result..'||'..spAtt.name..'||data-sort-value="'..spAtt.chance..'"|'..spAtt.chance..'%'
    result = result..'||'..spAtt.description
  end
  result = result..'\r\n|}'
   return result
   return result
end
end


return p
return p