Editing Module:UnitData
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 10: | Line 10: | ||
return string.format("%.0f", amount * 100) .. "%" | return string.format("%.0f", amount * 100) .. "%" | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
function unit.getData(frame) | function unit.getData(frame) | ||
if not frame then return '' end | if not frame then return '' end | ||
− | local unitDefName = | + | local unitDefName = frame.args[1] |
local ud = unitData[unitDefName] | local ud = unitData[unitDefName] | ||
if not (ud) then return 'unitdef ' .. unitDefName .. ' not found' end | if not (ud) then return 'unitdef ' .. unitDefName .. ' not found' end | ||
− | local property = | + | local property = frame.args[2] |
local result = ud[property] | local result = ud[property] | ||
return result or '' | return result or '' | ||
Line 37: | Line 23: | ||
function unit.getAbilityInfoboxTemplate(abType, args) | function unit.getAbilityInfoboxTemplate(abType, args) | ||
− | local tbl = {title = "Infobox zkability " .. abType, | + | local tbl = {title = "Infobox zkability " .. abType, args} |
return tbl | return tbl | ||
end | end | ||
Line 45: | Line 31: | ||
local tbl = {title = "Infobox zkunit", args = {}} | local tbl = {title = "Infobox zkunit", args = {}} | ||
local u = tbl.args | local u = tbl.args | ||
− | local | + | local ud = unitData[args.defname] |
− | + | if not (ud) then return 'unitdef ' .. args.defname .. ' not found' end | |
− | if not (ud) then return 'unitdef ' .. | ||
for key, value in pairs(ud) do | for key, value in pairs(ud) do | ||
Line 56: | Line 41: | ||
u.weaponIDs = nil | u.weaponIDs = nil | ||
u.shieldIDs = nil | u.shieldIDs = nil | ||
− | |||
return tbl | return tbl | ||
Line 63: | Line 47: | ||
function unit.printAbilityInfoboxes(frame) | function unit.printAbilityInfoboxes(frame) | ||
if not frame then return '' end | if not frame then return '' end | ||
− | local unitDefName = frame.args.defname | + | local unitDefName = frame.args.defname |
local ud = unitData[unitDefName] | local ud = unitData[unitDefName] | ||
if not (ud) then return 'unitdef ' .. unitDefName .. ' not found' end | if not (ud) then return 'unitdef ' .. unitDefName .. ' not found' end | ||
local result = '' | local result = '' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
if ud.buildSpeed then | if ud.buildSpeed then | ||
result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("construction", {buildpower = ud.buildSpeed})) | result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("construction", {buildpower = ud.buildSpeed})) | ||
end | end | ||
− | if ud. | + | if ud.transportCapacity then |
local light = ud.transportLightSpeed | local light = ud.transportLightSpeed | ||
− | local medium = | + | local medium = cp.transportMediumSpeed |
− | local heavy = | + | local heavy = cp.transportHeavySpeed |
local args = {} | local args = {} | ||
− | if light then args.light = light | + | if light then args.light = toPercent(light) end |
− | if medium then args.medium = medium | + | if medium then args.medium = toPercent(medium) end |
− | if heavy then args.heavy = heavy | + | if heavy then args.heavy = toPercent(heavy) end |
result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("transport", args)) | result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("transport", args)) | ||
end | end | ||
− | if ud. | + | if ud.cloakCost or ud.idleCloak then |
local args = {} | local args = {} | ||
if (ud.cloakCost or 0) > 0 then | if (ud.cloakCost or 0) > 0 then | ||
args.upkeepidle = ud.cloakCost | args.upkeepidle = ud.cloakCost | ||
− | args.upkeepmobile = | + | args.upkeepmobile = ud.cloakCostMoving |
− | elseif ud. | + | elseif ud.idle_cloak then |
args.customdata1 = "Only when idle" | args.customdata1 = "Only when idle" | ||
args.customdata2 = "Free and automated" | args.customdata2 = "Free and automated" | ||
Line 130: | Line 99: | ||
if ud.radarDistance or ud.jammerDistance then | if ud.radarDistance or ud.jammerDistance then | ||
local args = {} | local args = {} | ||
− | if | + | if unitDef.radardistancejam then |
− | if not | + | if not unitDef.radardistance then |
args.name = "Radar Jammer" | args.name = "Radar Jammer" | ||
end | end | ||
args.jam = ud.jammerDistance | args.jam = ud.jammerDistance | ||
end | end | ||
− | if | + | if unitDef.radardistance then |
args.radar = ud.radarDistance | args.radar = ud.radarDistance | ||
end | end | ||
Line 142: | Line 111: | ||
end | end | ||
if ud.jumpRange then | if ud.jumpRange then | ||
− | local args = {range = ud.jumpRange, reload = ud.jumpReload, speed = ud.jumpSpeed, midairjump = ud.midairJump | + | local args = {range = ud.jumpRange, reload = ud.jumpReload, speed = ud.jumpSpeed, midairjump = ud.midairJump} |
result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("jump", args)) | result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("jump", args)) | ||
end | end | ||
Line 148: | Line 117: | ||
local args = {} | local args = {} | ||
if ud.idleRegenTime then | if ud.idleRegenTime then | ||
− | args.idleregen = ud.idleRegen | + | if unitDef.idletime > 0 then |
− | + | args.idleregen = ud.idleRegen | |
− | + | args.timetoenable = ud.idleRegenTime | |
− | + | else | |
+ | args.combatregen = ud.combatRegen | ||
+ | end | ||
end | end | ||
if ud.waterRegen then | if ud.waterRegen then | ||
Line 169: | Line 140: | ||
if ud.armorDamageReduction then | if ud.armorDamageReduction then | ||
local args = {reduction = ud.armorDamageReduction .. '%'} | local args = {reduction = ud.armorDamageReduction .. '%'} | ||
+ | abilities = abilities .. "\n\t" .. writeHeaderLine("Infobox zkability armored") | ||
if ud.armorForceClose then | if ud.armorForceClose then | ||
args.special1 = "Forced for " .. ud.armorForceClose .. "s on damage" | args.special1 = "Forced for " .. ud.armorForceClose .. "s on damage" | ||
Line 174: | Line 146: | ||
result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("armored", args)) | result = result .. frame:expandTemplate(unit.getAbilityInfoboxTemplate("armored", args)) | ||
end | end | ||
+ | |||
local args = {} | local args = {} | ||
Line 208: | Line 181: | ||
function unit.printWeaponInfoboxes(frame) | function unit.printWeaponInfoboxes(frame) | ||
if not frame then return '' end | if not frame then return '' end | ||
− | local unitDefName = frame.args.defname | + | local unitDefName = frame.args.defname |
local ud = unitData[unitDefName] | local ud = unitData[unitDefName] | ||
if not (ud) then return 'unitdef ' .. unitDefName .. ' not found' end | if not (ud) then return 'unitdef ' .. unitDefName .. ' not found' end | ||
Line 220: | Line 193: | ||
end | end | ||
− | + | return result or '' | |
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||