Module:Skills: Difference between revisions

Automate some Thieving tables/navigation
(Revise Thieving NPC drop chances to display effective drop chance per successful attempt)
(Automate some Thieving tables/navigation)
Line 124: Line 124:
     table.insert(returnPart, '* ' .. string.rep(' ', math.max(0, (maxDropLen - string.len(dropChance)) * 2)) .. dropChance .. '% ' .. itemText)
     table.insert(returnPart, '* ' .. string.rep(' ', math.max(0, (maxDropLen - string.len(dropChance)) * 2)) .. dropChance .. '% ' .. itemText)
   end
   end
  return table.concat(returnPart, '\r\n')
end
function p.getThievingNPCTable()
  local returnPart = {}
  -- Create table header
  table.insert(returnPart, '{| class="wikitable sortable stickyHeader"')
  table.insert(returnPart, '|- class="headerRow-0"\r\n!Target!!Name!!' .. Icons.Icon({'Thieving', type='skill', notext=true}).. ' Level!!Experience!!Max Hit!!Max Coins')
 
  local linkOverrides = { ['Golbin'] = 'Golbin (thieving)' }
  -- Create row for each NPC
  for i, npc in Shared.skpairs(SkillData.Thieving) do
    local linkText = npc.name
    if linkOverrides[npc.name] ~= nil then
      linkText = linkOverrides[npc.name] .. '|' .. npc.name
    end
    table.insert(returnPart, '|-\r\n|style="text-align: left;" |' .. Icons.Icon({npc.name, type='thieving', size=50, notext=true}))
    table.insert(returnPart, '|style="text-align: left;" |[[' .. linkText .. ']]')
    table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'level'))
    table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'xp'))
    table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'maxHit'))
    table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'maxCoins'))
  end
  table.insert(returnPart, '|}')
  return table.concat(returnPart, '\r\n')
end
function p.getThievingNavbox()
  local returnPart = {}
  -- Create table header
  table.insert(returnPart, '{| class="wikitable" style="text-align:center; clear:both; margin:auto; margin-bottom:1em;"')
  table.insert(returnPart, '|-\r\n!' .. Icons.Icon({'Thieving', type='skill', notext=true}) .. '[[Thieving|Thieving Targets]]')
  table.insert(returnPart, '|-\r\n|')
 
  local npcList = {}
  local linkOverrides = { ['Golbin'] = 'Golbin (thieving)' }
  -- Create row for each NPC
  for i, npc in Shared.skpairs(SkillData.Thieving) do
    local linkText = npc.name
    if linkOverrides[npc.name] ~= nil then
      linkText = linkOverrides[npc.name] .. '|' .. npc.name
    end
    table.insert(npcList, Icons.Icon({npc.name, type='thieving', notext=true}) .. ' [[' .. linkText .. ']]')
  end
  table.insert(returnPart, table.concat(npcList, ' • '))
  table.insert(returnPart, '|}')


   return table.concat(returnPart, '\r\n')
   return table.concat(returnPart, '\r\n')