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 2: | Line 2: | ||
local unit = {} | local unit = {} | ||
local unitData = mw.loadData('Module:UnitData/data') | local unitData = mw.loadData('Module:UnitData/data') | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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 14: | ||
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 | ||
function unit.printAbilityInfoboxes(frame) | function unit.printAbilityInfoboxes(frame) | ||
+ | -- TODO | ||
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 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 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
function unit.printWeaponInfoboxes(frame) | function unit.printWeaponInfoboxes(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 | ||
Line 220: | Line 45: | ||
end | end | ||
− | + | return result or '' | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
return unit | return unit |