Can't get lua to change string in XML element

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.
549dox.jpg


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



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.
 
Looks fine to me. I'd guess you forgot to set your replacement CityBannerManager.lua VFS=true.

If that's not it, then it'd be much easier to troubleshoot if you attach a copy of your built mod (either the .CivBEmod from your solution's Packages folder, or just zip up the copy in your Mods folder).
 
Uhm, VFS...? I assume that's my problem, since I have no idea what that means. Thanks for the reply - I'll try searching for help relating to that.

EDIT: I should mention that I'm just writing my mod in a text editor, I'm not using any kind of app or IDE, so if that requires another tool, I'll have to figure that out separately.
 
Solved - you were right, I had to get the mod to import the files specifically by adding lines to the .modinfo file.

Thank you! It works great, and now I can see trade route info from the city banner.
 
Back
Top Bottom