Trade Logic Issue?

daviiadams

Prince
Joined
Jul 7, 2011
Messages
369
Location
London
I've become stuck with an issue that is affecting the trade table, during diplomacy, but can't figure out where exactly the problem starts..

In a previous version of the mod in question (Bottom Panel Info), I'd amended some diplo screen files, then realised later I should have gone via the DiploUIAddin route, but it did work without issue, yet since trimming all the unnecessary fat and looking to go about the diplo addin screen differently, I've manage to break something. Now, it doesn't appear to make any odds what I do :sad:

In starting a game, I get this in Live Tuner:

Spoiler :
Code:
 Map Script: Determining continents for art purposes (MapGenerator.Lua)
 CivilopediaScreen: SetSelectedCategory(12)
 CivilopediaScreen: CivilopediaCategory[CategoryTerrain].DisplayList
 CivilopediaScreen: SetSelectedCategory(1)
 CivilopediaScreen: CivilopediaCategory[CategoryHomePage].DisplayList
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\WorldView\Tr..."]:3071: attempt to call global 'TruncateString' (a nil value)
stack traceback:
	[string "Assets\DLC\Expansion\UI\InGame\WorldView\Tr..."]:3071: in main chunk
	[C]: in function 'include'
	[string "Assets\UI\InGame\WorldView\SimpleDiploTrade..."]:4: in main chunk
	[C]: ?
 Tutorial: Loaded Additional Tutorial checks - Assets\DLC\Expansion\Tutorial\lua\TutorialInclude_Expansion1.lua
 GenericPopup: Loaded Popup - Assets\DLC\Expansion\UI\InGame\PopupsGeneric\DeclareWarMovePopup.lua
 GenericPopup: Loaded Popup - Assets\DLC\Expansion\UI\InGame\PopupsGeneric\PuppetCityPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmImprovementRebuildPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\NetworkKickedPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\CityPlotManagementPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmCommandPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\MinorCivEnterTerritoryPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\LiberateMinorPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ReturnCivilianPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\AnnexCityPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\DeclareWarMovePopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\BarbarianRansomPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmGiftPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmCityTaskPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\PuppetCityPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\DeclareWarRangeStrikePopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmPolicyBranchPopup.lua
 GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\MinorCivGoldPopup.lua
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\WorldView\Tr..."]:3071: attempt to call global 'TruncateString' (a nil value)
stack traceback:
	[string "Assets\DLC\Expansion\UI\InGame\WorldView\Tr..."]:3071: in main chunk
	[C]: in function 'include'
	[string "Assets\UI\InGame\Popups\DiploCurrentDeals.l..."]:5: in main chunk
	[C]: ?
 ChoosePantheonPopup: -21
 ChoosePantheonPopup: 963
 ChoosePantheonPopup: 942
 Runtime Error: [string "Assets\UI\InGame\Menus\GameMenu.lua"]:334: attempt to call global 'TruncateString' (a nil value)
stack traceback:
	[string "Assets\UI\InGame\Menus\GameMenu.lua"]:334: in function 'PopulateGameOptions'
	[string "Assets\UI\InGame\Menus\GameMenu.lua"]:528: in main chunk
	[C]: ?
 Runtime Error: Error loading Assets\UI\InGame\Menus\GameMenu.lua.
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\WorldView\Tr..."]:3071: attempt to call global 'TruncateString' (a nil value)
stack traceback:
	[string "Assets\DLC\Expansion\UI\InGame\WorldView\Tr..."]:3071: in main chunk
	[C]: in function 'include'
	[string "C:\Users\Davii\Documents\My Games\Sid Meier..."]:3: in main chunk
	[C]: ?
 Demographics: Dequeuing demographics
 Demographics: Dequeuing demographics
 Runtime Error: [string "Assets\UI\InGame\Menus\GameMenu.lua"]:334: attempt to call global 'TruncateString' (a nil value)
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\DiploList.lu..."]:222: attempt to call global 'TruncateString' (a nil value)
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\DiploList.lu..."]:222: attempt to call global 'TruncateString' (a nil value)
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\DiploList.lu..."]:222: attempt to call global 'TruncateString' (a nil value)
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\DiploList.lu..."]:222: attempt to call global 'TruncateString' (a nil value)
 Runtime Error: [string "Assets\DLC\Expansion\UI\InGame\DiploList.lu..."]:222: attempt to call global 'TruncateString' (a nil value)
 TechTree: REFRESHING TECH DISPLAY

I've tried a few times to trace back through that info, but left completely :confused:

Mod zip file, for any of those wanting to have a look with it running:

Bottom Panel Info v2 zip

Pre game issues come up too - when attempting to list saved games, for example, I get an error, which in the past I'd thought to be an xml mistake somewhere (having spotted a character error), but I've yet to spot anything like that this time around.

Any ideas?

Some of the Live Tuner info seems odd too - TradeLogic doesn't get near 3071 lines, or have I misunderstood that?
 
Welcome to the hell that is Firaxis' idea of programming.

Contrary to popular belief, the line

Code:
include( "SupportFunctions"  );

does NOT include the specific file "SupportFunctions.lua" but will include the first file in the VFS that matches the pattern "SupportFunctions"

Unfortunately all your BPSupportFunctions_Xyz.lua files meet this criteria, so DiploList.lua et al are randomly picking one of your files instead of the required SupportFunctions.lua file (that contains the TruncateString() function) and hence are throwing errors when they try to use that function.

Edit: For those wanting to do "weird" things with include (which takes a second parameter!), check out the last few lines in GameCalendarUtilities.lua
For more info, see this thread http://forums.2kgames.com/showthread.php?109126-Weirdness-in-the-VFS, specifically post #7
 
My solution to this is to always include the ".lua" extension in the include string. You can still run afoul of this ... feature ... but it prevents many such problems including the one above.

@whoward69, I thought that it would include all matches to the string (not just the first). But maybe that's what the second parameter is for...
 
My solution to this is to always include the ".lua" extension in the include string. You can still run afoul of this ... feature ... but it prevents many such problems including the one above.

Except the one above is in the core code, so unless you modify all the Firaxis files to use "SupportFunctions.lua" the only way to avoid this is to make sure you pick names for your files that don't contain any "file names" that Firaxis use.

@whoward69, I thought that it would include all matches to the string (not just the first). But maybe that's what the second parameter is for...

Correct, if the second parameter is true, all files will be included. If it's omitted (nil) or false, only the first is used. And that's the first as in "the first that happened to be found" so can (and will) vary depending on mod load order
 
Does this mean that my best option would be to have one file, done normally as a UIAddin, to include the supporting functions, rather than a control file with separate supporting ones?

Or change the file names to not include the words support/function?
 
Just tried renaming the support files and their folder, omitting "SupportFunctions" in their names and all is working again :)
 
Back
Top Bottom