Replies: 0 (Who?), Viewed: 6543 times.
Pettifogging Legalist!retired moderator
#1 21st Feb 2016 at 7:03 PM Last edited by justJones : 7th May 2018 at 12:15 AM.
Thanks: 406505 in 1086 Posts
How to add a custom string resource (STBL) to somethingI'm using a custom(ised) object for this example but this also applies to, say, tuning mods or anything else that needs custom strings.
If you need to manage a lot of strings and their translations, you might be better off using something like DP's STBL Editor -- but when you just need to add one string in the course of editing other stuff too, this is is probably a quicker way.
For general resource naming conventions (why/when to set the high bits and so on), see the Maxis CC guide (see also link in sticky in Modding Discussion in case they ever move that).
The most recent version of s4pe is available here.
The object in my example already has strings for the name and description, but the description reads "**DEBUG**" so I'm changing it to a custom one instead:
- First create a new STBL (string table) resource: in the top menu, select Resource > Add.
- This opens a popup to specify what you want to add exactly. In the first field type "st" and select "STBL 0x220557DA" from the dropdown that comes up, in the second field put "0x80000000" for the group, then put a sensible name in the Name field, hit the FNV64 button, and change the first two digits of the instance (third field) to the locale that you use (00 for US English). See this post for a list of locale codes + some other info on STBL.
- Now you will need a new, unique key to use for your description. Go to top menu > Tools > FNV hash, type a name to use for the string hash key in the top field, hit Calculate, hit "Set High Bit". Copy the value from FNV32 (in my case, "0xC4CAFFDB"). You can also use tools like fogity's toolbox for this, or an online calculator like this one.
- Select the newly added STBL and hit "Grid". In the data grid window that opens, hit the three buttons next to "Entries" to add a new entry.
- Paste your FNV32 hash into the KeyHash field and type the text you want into the StringValue field.
- Hit "OK", hit "Commit". Now the preview of your STBL shows the newly added entry.
- To use this as a description for an obect, open the COBJ resource and in "DescriptionHash", paste the key of your new string entry (0xC4CAFFDB in this case. Or if the string is referred to in some XML tuning, paste the key in there.
When you're done adding all the strings you need and have made sure there's no leftover typos in them, and you want to upload your mod somewhere, you (probably) need to create STBLs for the other languages too. Copy the one you have, rightclick > paste, and change the locale code in the instance to match the missing locales as you go. A list of the locale codes that are currently supported is in the Maxis post linked above.
Again this is the simple manual way -- see the link above (STBL Editor) for a tool that can generate the translations automatically.
2 users say thanks for this. (Who?)