How to change policy tooltips?

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
I'd like to add lines showing policy_flavor values for each policy tooltip, for debugging purposes. I found where it gets the Help text for policies in SocialPolicyPopup.lua and made a change.

Spoiler :
This produced an error, "attempt to concatenate global 'strToolTip' (a nil value)":
PHP:
-- Tooltip
local strTooltip = Locale.ConvertTextKey( policyInfo.Help ) or " ";

-- AI Flavor Debug
strToolTip = strToolTip .. "[NEWLINE][NEWLINE]----------------[NEWLINE]AI Priorites (debug info):"
for flavorInfo in GameInfo.Policy_Flavors(string.format("PolicyType = '%s'", policyInfo.Type)) do
	strToolTip = strToolTip .. string.format("[NEWLINE]%s %s", flavorInfo.Flavor, Locale.ToLower(string.gsub(flavorInfo.FlavorType, "FLAVOR_", "")));
end

This did not error, but does not show the "----------------" line at all:
PHP:
-- Tooltip
local strTooltip = Locale.ConvertTextKey( policyInfo.Help );

-- AI Flavor Debug
strToolTip = (strToolTip or " ") .. "[NEWLINE][NEWLINE]----------------[NEWLINE]AI Priorites (debug info):"
for flavorInfo in GameInfo.Policy_Flavors(string.format("PolicyType = '%s'", policyInfo.Type)) do
	strToolTip = strToolTip .. string.format("[NEWLINE]%s %s", flavorInfo.Flavor, Locale.ToLower(string.gsub(flavorInfo.FlavorType, "FLAVOR_", "")));
end

I'm really confused. It's almost like the "AI Flavor Debug" block of code I added is not in the scope of the rest of the code, so it does not see the local strToolTip, and searches for a global instead. It doesn't make any sense, but is the only explanation I can think of. I've been programming six hours and getting rather tired so I suspect I'm overlooking something really obvious. :think:
 
I suspect I'm overlooking something really obvious.

As I thought! :crazyeye:

I see how this happened... Firaxis used this for policy trees:
Code:
local strToolTip = Locale.ConvertTextKey(policyBranchInfo.Help);

for policies:
Code:
local strTooltip = Locale.ConvertTextKey( policyInfo.Help );
In the same function! :lol:

Seriously, they need more code standardization in their work... thanks for the help!
 
Back
Top Bottom