String Functions

platyping

Sleeping Dragon
Joined
Oct 22, 2010
Messages
4,626
Location
Emerald Dreams
Playing around with string functions.
Code:
ReligionInfo = gc.getReligionInfo(iReligion)
sReligion = ReligionInfo.getAdjectiveKey()
ABC = sReligion.upper() + "_TEMPLE"

If I print sReligion directly, it will display as Jewish, Hindu etc, but when I print ABC, it displays as TXT_KEY_RELIGION_TAOISM_ADJECTIVE_TEMPLE instead.

On the other hand, if I use getDescription instead of AdjectiveKey, it will display as Taoism, followed by TAOISM_TEMPLE correctly.

Any idea why is it so funny with the getAdjectiveKey :D
 
The .getAdjectiveKey() function gets the key, not the text that the key translates to. It returns TXT_KEY_RELIGION_TAOISM_ADJECTIVE, not whatever the text for that is in your currently selected language for the game.

I assume by "print" you mean you are displaying it as a message in the scrollable message area or something along those lines, not just a Python "print" statement. It is presumably processing the passed text via gDLL->getText(...) in the DLL (the equivalent of using CyTranslator.getText (...) in Python) to convert it to the actual "Taoism" as per your current language setting if you just pass it sReligion.

By appending more text to the text key you have made an invalid text key. There is no result from a lookup of TXT_KEY_RELIGION_TAOISM_ADJECTIVE_TEMPLE and when the text does not exist as a key it uses what you sent literally (which is why you can just specify text in a Description tag, rather than a text key with translations, and it will work).

The getDescription function returns what the specified description text key translates to based on your current language setting, not the text key for it.

If you actually want the type key for the religion, RELIGION_TAOISM, I think the .getType() returns that. For the description text key, TXT_KEY_RELIGION_TAOISM, it is probably the .getTextKey() function.
 
Ah thanks, I understand it is returning the TXT_KEY_XXXXXX since it is getAdjectiveKey(), just surprised that it returns Taoist directly if no modification was done to it.

Hmm, actually was trying to find a way to find the temple/monastery/cathedral of a specific religion without using the traditional way of looping through the whole list of buildings, so trying to see if there is a way I can get the word "TAOIST" from the religion info, and add "BUILDING_" and "_TEMPLE" to it to get the temple directly.

Since like can't be done since getAdjective() is not available for religion info.
 
If you have the adjective text key then you have the adjective - just translate it manually via CyTranslator().getText(...).

Uh, well... I have no idea what languages other than English give for the various religions though, so doing this sort of thing has a very good chance of not actually working if the language is set to something else.
 
Seldom play around with strings, so not too familiar with all the commands yet. Thanks :D

Hmm true, forgot about the other languages, have to check it up to see if they are similar.
Quite irritating to loop through 100+ buildings just to find its temple, so doing some experiments to see if there is a more efficient way :D
 
Back
Top Bottom