Difference between revisions of "Module:OInfobox-Building"

Jump to navigation Jump to search
m
no edit summary
m
m
Line 195: Line 195:
         end
         end
         --/
         --/
        ---SECTION-UNLOCKING
        --SECTION-UNLOCKING
         if buildingData.influence then
         if buildingData.influence then
            local unlockData = {}
        local unlockData = {}
            local first = true;
        local first = true
            for resource, amount in pairs(buildingData.influence) do
          for resource, amount in pairs(buildingData.influence) do
                local displayAmount = amount
          if resource ~= 'tier' then -- Exclude the 'tier' key
                if first and buildingData.influence.tier then
            local displayAmount = amount
                    displayAmount = displayAmount .. ' ' .. buildingData.influence.tier
            if first and buildingData.influence.tier then
                    first = false;
              displayAmount = displayAmount .. ' ' .. buildingData.influence.tier
                end
              first = false
                local resourceIcon = i.icon(resource, nil, nil, com.firstUpper({resource}), 'en')
          end
local tierPosition = string.find(displayAmount, "tier", nil, true) -- Find the last occurrence of "tier"
          local resourceIcon = i.icon(resource, nil, nil, com.firstUpper({resource}), 'en')
          local tierPosition = string.find(displayAmount, "tier", nil, true)
if tierPosition then
       
  local beforeTier = string.sub(displayAmount, 1, tierPosition - 1)
            if tierPosition then
  local theTier = string.sub(displayAmount, tierPosition)
              local beforeTier = string.sub(displayAmount, 1, tierPosition - 1)
  table.insert(unlockData, {label = resourceIcon, value = beforeTier .. "(" .. theTier .. ")"})
              local theTier = string.sub(displayAmount, tierPosition)
else
              table.insert(unlockData, {label = resourceIcon, value = beforeTier .. "(" .. theTier .. ")"})
  table.insert(unlockData, {label = resourceIcon, value = displayAmount})
            else
end
              table.insert(unlockData, {label = resourceIcon, value = displayAmount})
end
            end
 
            if #unlockData > 0 then
                addSection(infobox, unlockData, 'Unlocking Conditions', 2)
             end
             end
        end
          end
       
          if #unlockData > 0 then
            addSection(infobox, unlockData, 'Unlocking Conditions', 2)
          end
          end
         --/
         --/
         ---SECTION-CONSTRUCTION
         ---SECTION-CONSTRUCTION
606

edits

Navigation menu