572
edits
No edit summary |
No edit summary |
||
Line 567: | Line 567: | ||
local cost = p._GetBuildingBaseCost(building) | local cost = p._GetBuildingBaseCost(building) | ||
table.insert(ret, '\r\n|'..cost) | table.insert(ret, '\r\n|'..cost) | ||
end | |||
-- Generate a row | |||
-- textFunc: returns nil if no data for a building, or else returns a string | |||
local function BuildOptionalRow(header, textFunc) | |||
local texts = {} | |||
local hasTexts = false | |||
for _, building in ipairs(buildingList) do | |||
local text = textFunc(building) | |||
hasTexts = hasTexts == true or text ~= nil | |||
texts = texts ~= nil and texts or '' | |||
table.insert(texts, text) | |||
end | |||
if hasTexts == true then | |||
texts = table.concat(texts, '\r\n|') | |||
table.insert(ret, header..texts) | |||
end | |||
end | end | ||
-- Benefits | -- Benefits | ||
BuildOptionalRow('\r\n|-\r\n! Benefits\r\n|', p._GetBuildingBenefits) | |||
local benefits = {} | local benefits = {} | ||
local hasBenefits = false | local hasBenefits = false |
edits