Module:EnemyNav: Difference between revisions
From IdleOn MMO Wiki
Kiokurashi (talk | contribs) mNo edit summary |
Kiokurashi (talk | contribs) mNo edit summary |
||
Line 5: | Line 5: | ||
local enemyType = frame.args.Type | local enemyType = frame.args.Type | ||
local midEnemy = frame.args.Enemy -- Pagename | local midEnemy = frame.args.Enemy -- Pagename | ||
local navList = {} | |||
-- branch data load based on type | -- branch data load based on type | ||
if enemyType == 'Normal' then navList = Lists.enemyList | |||
elseif enemyType == 'Boss' then navList = Lists.bossList | |||
elseif enemyType == 'Event' then navList = Lists.eventList | |||
elseif enemyType == 'Dungeon' then navList = Lists.dungeonList | |||
elseif enemyType == 'Rift' then navList = Lists.riftList | |||
else return "This type doesn't have an associate Navigation list." end | |||
-- Iterate until self found. | -- Iterate until self found. | ||
local i | |||
for i=1, #navList do | |||
if navList[i] == midEnemy then | |||
break -- Index foound, break loop. | |||
end | |||
return "This enemy is not in the " .. enemyType .. " list." | |||
end | |||
-- Using self-index get previous and next enemies, if they exist. | -- Using self-index get previous and next enemies, if they exist. | ||
local prevEnemy = navList[i-1] ~= nil and navList[i-1] or '' | |||
local nextEnemy = navList[i+1] ~= nil and navList[i+1] or '' | |||
-- construct output. | -- construct output. | ||
local navBar = [[<div class='EnemyNav'><div class='EnemyNavLeft'>%s</div><div class='EnemyNavCenter'>Enemies</div><div class='EnemyNavRight'>%s</div></div>]] | |||
return | local enemySect = "[[File:%s_icon.png|16px|link=%s]] [[%s]]" | ||
local pFormat = prevEnemy ~= '' and string.format("[[File:ArrowLeft.png|15px|link=%s]]" .. enemySect, prevEnemy, prevEnemy, prevEnemy, prevEnemy) or '' | |||
local nFormat = nextEnemy ~= '' and string.format(enemySect .. "[[File:ArrowRight.png|15px|link=%s]]", nextEnemy, nextEnemy, nextEnemy, nextEnemy) or '' | |||
return string.format(navBar, prevEnemy, nextEnemy) | |||
end | end | ||
local p | local p |
Revision as of 14:37, 3 April 2024
Documentation for this module may be created at Module:EnemyNav/doc
local p = {}
local Lists = require("Module:EnemyNav\data")
function p.BuildNav( frame )
local enemyType = frame.args.Type
local midEnemy = frame.args.Enemy -- Pagename
local navList = {}
-- branch data load based on type
if enemyType == 'Normal' then navList = Lists.enemyList
elseif enemyType == 'Boss' then navList = Lists.bossList
elseif enemyType == 'Event' then navList = Lists.eventList
elseif enemyType == 'Dungeon' then navList = Lists.dungeonList
elseif enemyType == 'Rift' then navList = Lists.riftList
else return "This type doesn't have an associate Navigation list." end
-- Iterate until self found.
local i
for i=1, #navList do
if navList[i] == midEnemy then
break -- Index foound, break loop.
end
return "This enemy is not in the " .. enemyType .. " list."
end
-- Using self-index get previous and next enemies, if they exist.
local prevEnemy = navList[i-1] ~= nil and navList[i-1] or ''
local nextEnemy = navList[i+1] ~= nil and navList[i+1] or ''
-- construct output.
local navBar = [[<div class='EnemyNav'><div class='EnemyNavLeft'>%s</div><div class='EnemyNavCenter'>Enemies</div><div class='EnemyNavRight'>%s</div></div>]]
local enemySect = "[[File:%s_icon.png|16px|link=%s]] [[%s]]"
local pFormat = prevEnemy ~= '' and string.format("[[File:ArrowLeft.png|15px|link=%s]]" .. enemySect, prevEnemy, prevEnemy, prevEnemy, prevEnemy) or ''
local nFormat = nextEnemy ~= '' and string.format(enemySect .. "[[File:ArrowRight.png|15px|link=%s]]", nextEnemy, nextEnemy, nextEnemy, nextEnemy) or ''
return string.format(navBar, prevEnemy, nextEnemy)
end
local p