17,101
edits
Falterfire (talk | contribs) (Added p.getOtherMonsterBoxText) |
(_getMonsterTable: Optimise by using table.concat() instead of repeated string concatenation) |
||
Line 980: | Line 980: | ||
--Making a single function for getting a table of monsters given a list of IDs. | --Making a single function for getting a table of monsters given a list of IDs. | ||
local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | ||
local | local tableParts = {} | ||
table.insert(tableParts, '{| class="wikitable sortable stickyHeader"') | |||
-- First header row | -- First header row | ||
table.insert(tableParts, '\r\n|- class="headerRow-0"\r\n! colspan="5" | !! colspan="4" |Offensive Stats !! colspan="3" |Evasion Rating !! colspan="4" |') | |||
-- Second header row | -- Second header row | ||
table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name !!ID !!Combat Level ') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})) | |||
table.insert(tableParts, '!!Attack Type !!Attack Speed (s) !!Max Hit !!Accuracy ') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})) | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})) | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})) | |||
table.insert(tableParts, '!!Drop Chance !!Coins !!Bones !!Locations') | |||
-- Generate row per monster | -- Generate row per monster | ||
Line 1,017: | Line 1,018: | ||
end | end | ||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: left;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |[[' .. monster.name .. ']]') | |||
table.insert(tableParts, '\r\n|style="text-align:right" |' .. monsterID) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. monster.hitpoints .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | |||
table.insert(tableParts, '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterStyleIcon({monster, nolink='true'})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. lootChance .. '" |' .. lootChance .. '%') | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (gpRange[1] + gpRange[2]) / 2 .. '" |' .. gpTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterAreas(monster, hideDungeons)) | |||
end | end | ||
table.insert(tableParts, '\r\n|}') | |||
return | return table.concat(tableParts) | ||
end | end | ||
return p | return p |