EdgeWalkerZero
Chieftain
- Joined
- Nov 11, 2014
- Messages
- 3
With trade routes as massively important in this iteration of Civ, I wanted to make a mod that displays the basic trade route information on the city banner.
Unfortunately, I can't get it it work. In fact, I can't get any string to show up in a XML element other than a literal.
This is the information I'm trying to duplicate near the banner.
This is what I get. The code doesn't change the default text to the A/B trade routes.
I gave the element a unique ID in the XML, and then tried to set the value in the LUA. I simply copied the code that creates the A/B string that appears in the city view, and tried to assign that to the text field in my new label. Nothing happens, though. In fact, I can't create any kind of label and set its string value in the LUA- nothing happens. Here's the code I added:
Added in CityBannerManagement.xml, right between ProductionMeter and CityProductionName elements:
Added in CityBannerManager.lua, in the section following "if city~= nil then..." The TEST string doesn't get assigned.
The logs don't show anything unusual.
Unfortunately, I can't get it it work. In fact, I can't get any string to show up in a XML element other than a literal.
This is the information I'm trying to duplicate near the banner.

This is what I get. The code doesn't change the default text to the A/B trade routes.

I gave the element a unique ID in the XML, and then tried to set the value in the LUA. I simply copied the code that creates the A/B string that appears in the city view, and tried to assign that to the text field in my new label. Nothing happens, though. In fact, I can't create any kind of label and set its string value in the LUA- nothing happens. Here's the code I added:
Added in CityBannerManagement.xml, right between ProductionMeter and CityProductionName elements:
Code:
<Box Anchor="C,T" Offset="0,-100" Size="200,40" Color="0,0,0,128" Hidden="0">
<Stack ID="TradeRouteStack" Anchor="C,C" Offset="0,0" StackGrowth="Right" Padding="0">
<Label ID="TradeRoutesIcon" Anchor="L,C" Offset="0,0" Color="PlayerColor1,255" String="[ICON_ARROW_RIGHT]" />
<Label ID="TradeRoutes" Anchor="L,C" Offset="0,0" Style="FontNormal14" String="STRING LITERAL XML"/>
</Stack>
</Box>
Added in CityBannerManager.lua, in the section following "if city~= nil then..." The TEST string doesn't get assigned.
Code:
controls.TradeRoutes:SetText("TEST");
-- ADDED
-- Update Trade Route Info
if(controls.TradeRoutes) then
local TradeRoutesText = "-";
controls.TradeRoutes:SetText(TradeRoutesText);
local tradeRoutesAllowed = city:GetNumTradeRoutesAllowed();
local tradeRoutesAvailable = city:GetNumTradeRoutesAvailable();
local tradeRoutesOccupied = tradeRoutesAllowed - tradeRoutesAvailable;
controls.TradeRoutes:SetText(tradeRoutesOccupied .. "/" .. tradeRoutesAllowed);
controls.TradeRoutes:SetHide(false);
end
The logs don't show anything unusual.