Thalassicus
Bytes and Nibblers
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.
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.
Spoiler :
This produced an error, "attempt to concatenate global 'strToolTip' (a nil value)":
This did not error, but does not show the "----------------" line at all:
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.
