Module:Counters
From SWGoH Wiki
Jump to navigationJump to search
DOCUMENTATION
This module has the following functions:
- images
{{#invoke: MODULE_NAME | MODULE_FUNCTION | parameters}}
Images Function
The images function display a row of unit images and is primarily built to be used with Team pages to display the full team and substitutes.
Parameters
This function takes 5 parameters in a specific order and has 5 named parameters. Named parameters can be in any order.
{{#invoke:Counters|images| LEADER_NAME | ALLY_1_NAME | ALLY_2_NAME | ALLY_3_NAME | ALLY_4_NAME |subs= |locks= |size= |txt= |type= |squadType=}}
- 1st Parameter = The full in-game name of the Leader of the team, or first unit image to display
- 2nd Parameter = OPTIONAL: The full in-game name of the ally on the team, or second unit image to display
- 3rd Parameter = OPTIONAL: The full in-game name of the ally on the team, or third unit image to display
- 4th Parameter = OPTIONAL: The full in-game name of the ally on the team, or fourth unit image to display
- 5th Parameter = OPTIONAL: The full in-game name of the ally on the team, or fifth unit image to display
- subs = OPTIONAL: The full name of each substitute separated by a comma with no spaces.
- size = This will adjust the size of the image. Options: med, lg
- locks = OPTIONAL: Adds a lock image on the units and makes them the same size as the leader image. Options: 1-5. Corresponds to image in parameter position.
- txt = OPTIONAL: This is used to add the units name under the image. Options: y or omit
- type = OPTIONAL: This is used to adjust the css for the box element and to hide the popup for the images. Specifically added for Team Counter Lists page so it corrects the placement of the team detail popup. Option: for or omit
- squadType = OPTIONAL: The type of units on the team. Options: Ship, Character. If omitted Character will be chosen by default.
Example
{{#invoke:Counters|images|Mother Talzin|Old Daka|Nightsister Zombie|Nightsister Spirit|Nightsister Acolyte|subs=Asajj Ventress|locks=1,2,3|size=med|txt=|type=|}}
local counters = {}
function split(inputstr, sep)
if sep == nil then
sep = ","
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, trim(str))
end
return t
end
function trim(s)
return s:match( "^%s*(.-)%s*$" )
end
function counters.images(a)
lead = a.args[1]
if(a.args[2] ~= nil) then
ally1 = split(a.args[2],",")
end
if(a.args[3] ~= nil) then
ally2 = split(a.args[3],",")
end
if(a.args[4] ~= nil) then
ally3 = split(a.args[4],",")
end
if(a.args[5] ~= nil) then
ally4 = split(a.args[5],",")
end
if(a.args.subs ~= nil) then
subs = split(a.args.subs,",")
end
if(a.args.locks ~= nil) then
locks = a.args.locks
else
locks = 0
end
if(a.args.squadType ~= nil) then
squad = a.args.squadType
else
squad = "Character"
end
if(a.args.type == "for") then
class = "team-unit-wrap"
css = "display:none;"
else
class = "team-unit-wrap tooltip"
css = ""
end
txt = a.args.txt
size = a.args.size
if(size == "med") then
boxSize=70
lockSize="20"
elseif(size == "lg") then
boxSize="90"
lockSize="27"
end
smBoxSize="45"
smLockSize="15"
result = ""
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(boxSize + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(boxSize+2)..'px}};border:1px solid gold;position:relative;">'
if(string.find(locks,"1") ~= nil) then
result = result..'<div style="position:absolute;top:0px;">[[File:Game-Icon-Lock.png|'..lockSize..'px|link=]]</div>'
end
result = result..'[[File:Unit-'..squad..'-'..lead..'-portrait.png|'..boxSize..'px|link='..lead..']]</div><span style="'..css..'" class="tooltiptext">'..lead..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..lead
end
result = result..'</div>'
if(ally1 ~= nil) then
if(string.find(locks,"2") ~= nil) then
box = boxSize
else
box = smBoxSize
end
for i, ally in ipairs(ally1) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(box + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(box+2)..'px}};border:1px solid gold;position:relative;">'
if(string.find(locks,"2") ~= nil) then
result = result..'<div style="position:absolute;top:0px;">[[File:Game-Icon-Lock.png|'..lockSize..'px|link=]]</div>'
end
result = result..'[[File:Unit-'..squad..'-'..ally..'-portrait.png|'..box..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
end
if(ally2 ~= nil) then
if(string.find(locks,"3") ~= nil) then
box = boxSize
else
box = smBoxSize
end
for i, ally in ipairs(ally2) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(box + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(box+2)..'px}};border:1px solid gold;position:relative;">'
if(string.find(locks,"3") ~= nil) then
result = result..'<div style="position:absolute;top:0px;">[[File:Game-Icon-Lock.png|'..lockSize..'px|link=]]</div>'
end
result = result..'[[File:Unit-'..squad..'-'..ally..'-portrait.png|'..box..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
end
if(ally3 ~= nil) then
if(string.find(locks,"4") ~= nil) then
box = boxSize
else
box = smBoxSize
end
for i, ally in ipairs(ally3) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(box + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(box+2)..'px}};border:1px solid gold;position:relative;">'
if(string.find(locks,"4") ~= nil) then
result = result..'<div style="position:absolute;top:0px;">[[File:Game-Icon-Lock.png|'..lockSize..'px|link=]]</div>'
end
result = result..'[[File:Unit-'..squad..'-'..ally..'-portrait.png|'..box..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
end
if(ally4 ~= nil) then
if(string.find(locks,"5") ~= nil) then
box = boxSize
else
box = smBoxSize
end
for i, ally in ipairs(ally4) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(box + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(box+2)..'px}};border:1px solid gold;position:relative;">'
if(string.find(locks,"5") ~= nil) then
result = result..'<div style="position:absolute;top:0px;">[[File:Game-Icon-Lock.png|'..lockSize..'px|link=]]</div>'
end
result = result..'[[File:Unit-'..squad..'-'..ally..'-portrait.png|'..box..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
end
if(subs ~= nil) then
for i, ally in ipairs(subs) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(box + 2)..'px;word-wrap:break-wor;"><div style="box-shadow:0 0 3px #000;width:'..(box+2)..'px}};border:1px solid gold;position:relative;">'
result = result..'[[File:Unit-'..squad..'-'..ally..'-portrait.png|'..box..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
end
return result
end
function counters.shipImages(a)
layout = a.args[1]
if(layout == "default") then
frontline = split(a.args[2],",")
boxSize=70
lockSize="20"
else
frontline = split(a.args[2],",")
boxSize="90"
lockSize="27"
if(a.args[3] ~= nil) then
reinforce1 = split(a.args[3],",")
end
if(a.args[4] ~= nil) then
reinforce2 = split(a.args[4],",")
end
if(a.args[5] ~= nil) then
reinforce3 = split(a.args[5],",")
end
if(a.args[6] ~= nil) then
reinforce4 = split(a.args[6],",")
end
end
if(a.args.subs ~= nil) then
subs = split(a.args.subs,",")
end
if(a.args.locks ~= nil) then
locks = a.args.locks
else
locks = ""
end
if(a.args.type == "for") then
class = "team-unit-wrap"
css = "display:none;"
else
class = "team-unit-wrap tooltip"
css = ""
end
txt = a.args.txt
smBoxSize="45"
smLockSize="15"
result = ""
for i, ally in ipairs(frontline) do
if(ally ~= "ignore") then
if(string.find(locks,i) ~= nil) then
box = boxSize
else
if(layout == "lineup") then
box = boxSize
else
box = smBoxSize
end
end
end
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(box + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(box+2)..'px}};border:1px solid gold;position:relative;">'
if(string.find(locks,i) ~= nil) then
result = result..'<div style="position:absolute;top:0px;">[[File:Game-Icon-Lock.png|'..lockSize..'px|link=]]</div>'
end
result = result..'[[File:Unit-Ship-'..ally..'-portrait.png|'..box..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
if(subs ~= nil) then
for i, ally in ipairs(subs) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(smBoxSize + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(smBoxSize+2)..'px}};border:1px solid gold;position:relative;">'
result = result..'[[File:Unit-Ship-'..ally..'-portrait.png|'..smBoxSize..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span>'
if(string.find(txt,"y") ~= nil) then
result = result..ally
end
result = result..'</div>'
end
end
if(layout == "lineup") then
result = result..'<div><table>'
if(reinforce1 ~= nil) then
result = result..'<td style="vertical-align:top;">'
for i, ally in ipairs(reinforce1) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(smBoxSize + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(smBoxSize+2)..'px}};border:1px solid gold;position:relative;">'
result = result..'[[File:Unit-Ship-'..ally..'-portrait.png|'..smBoxSize..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span></div><br />'
end
result = result..'</td>'
end
if(reinforce2 ~= nil) then
result = result..'<td style="vertical-align:top;">'
for i, ally in ipairs(reinforce2) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(smBoxSize + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(smBoxSize+2)..'px}};border:1px solid gold;position:relative;">'
result = result..'[[File:Unit-Ship-'..ally..'-portrait.png|'..smBoxSize..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span></div><br />'
end
result = result..'</td>'
end
if(reinforce3 ~= nil) then
result = result..'<td style="vertical-align:top;">'
for i, ally in ipairs(reinforce3) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(smBoxSize + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(smBoxSize+2)..'px}};border:1px solid gold;position:relative;">'
result = result..'[[File:Unit-Ship-'..ally..'-portrait.png|'..smBoxSize..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span></div><br />'
end
result = result..'</td>'
end
if(reinforce4 ~= nil) then
result = result..'<td style="vertical-align:top;">'
for i, ally in ipairs(reinforce4) do
result = result..'<div class="'..class..'" style="margin:4px;font-weight:bold;text-align:center;position:relative;width:'..(smBoxSize + 2)..'px;"><div style="box-shadow:0 0 3px #000;width:'..(smBoxSize+2)..'px}};border:1px solid gold;position:relative;">'
result = result..'[[File:Unit-Ship-'..ally..'-portrait.png|'..smBoxSize..'px|link='..ally..']]</div><span style="'..css..'" class="tooltiptext">'..ally..'</span></div><br />'
end
result = result..'</td>'
end
result = result..'</table></div>'
end
return result
end
function counters.test(a)
lead = a.args[1]
return lead
end
return counters