Module:Monsters/Tables: Difference between revisions
From Melvor Idle
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
function p.getFullStormsnapTable(frame) | function p.getFullStormsnapTable(frame) | ||
local monsterIDs = {} | local monsterIDs = {} | ||
for i = 0, Shared.tableCount(MonsterData.Monsters) - 1, 1 do | for i = 0, Shared.tableCount(Monsters.MonsterData.Monsters) - 1, 1 do | ||
table.insert(monsterIDs, i) | table.insert(monsterIDs, i) | ||
end | end |
Revision as of 12:02, 4 December 2021
Documentation for this module may be created at Module:Monsters/Tables/doc
p = {}
local Monsters = require('Module:Monsters')
local Shared = require('Module:Monsters')
local Icons = require('Module:Icons')
function p.getFullStormsnapTable(frame)
local monsterIDs = {}
for i = 0, Shared.tableCount(Monsters.MonsterData.Monsters) - 1, 1 do
table.insert(monsterIDs, i)
end
return p._getStormsnapTable(monsterIDs, false)
end
function p._getStormsnapTable(monsterIDs, excludeDungeons)
--Making a single function for getting a table of monsters given a list of IDs.
local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false
local tableParts = {}
table.insert(tableParts, '{| class="wikitable sortable stickyHeader"')
table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name ')
table.insert(tableParts, '!!style="padding:1 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true}) .. ' Magic Level')
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true}) .. ' Ranged Attack Bonus')
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Strength', type='skill', notext=true}) .. ' Ranged Strength Bonus')
-- Generate row per monster
for i, monsterID in Shared.skpairs(monsterIDs) do
local monster = Monsters.getMonsterByID(monsterID)
local magicLevel = Monsters._getMonsterLevel(monster, 'Magic')
local rangedStrBonus = 111 + math.floor((6 * magicLevel)/33)
local rangedAttBonus = math.floor(102 * (1 + ((6 * magicLevel)/5500)))
if magicLevel > 1 then
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true}))
table.insert(tableParts, '\r\n|style="text-align:left" |' .. Icons.Icon({monster.name, type='monster', noicon=true}))
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. magicLevel .. '" |' .. Shared.formatnum(magicLevel))
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. rangedAttBonus .. '" |' .. Shared.formatnum(rangedAttBonus))
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. rangedStrBonus .. '" |' .. Shared.formatnum(rangedStrBonus))
end
end
table.insert(tableParts, '\r\n|}')
return table.concat(tableParts)
end
return p