Railroads

You can't, directly. There's no Lua access function for that; it looks like it's all handled internally.

BUT, there's an indirect way to do it. The City View UI creates the Production tooltip in the upper-left corner of the city screen using the command
local strProductionHelp = GetProductionTooltip(pCity);
which has a line giving the "+25% production for railroad connection" or something similar. So all you'd need to do is parse that Production tooltip string to see if the word "railroad" appears in it in the appropriate spot. If so, then the city has a rail connection.

The only problem I can think of would be localization; you'd have problems with other languages. So you'd want to find whatever text key says "railroad" in the database, and search for THAT string.
 
That's a good idea, I didn't think of doing a find on that string. It's probably very inefficient but should work! Isn't it weird how yield tooltips are done internally, unlike most of the UI? :crazyeye:

The problem with localization is a lot of nouns change their spelling in other languages depending on context. I don't think even searching for the localized form of TXT_KEY_ROUTE_RAILROAD would always work... but hey, it's better than nothing. I need it solely for graphical elements so it won't have a negative gameplay impact if it doesn't work.
 
The problem with localization is a lot of nouns change their spelling in other languages depending on context.

The other problem is that Civ5 uses English as the backup if it can't find a text key in the language the player prefers. So it's possible, even if unlikely, that the language used for TXT_KEY_ROUTE_RAILROAD wouldn't be the same one used for that tooltip. But at that point, I think you just have to give up on the idea of it being a 100% effective fix.
 
Back
Top Bottom