[Help] Editing Language Files

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
Delta180
Posts: 92
Joined: Wed, 11. Aug 04, 13:26
x4

[Help] Editing Language Files

Post by Delta180 »

I've been messing around modding turret stats, and essentially turned Terran Beam turrets into Meson Stream turrets.
Delving into the \t\0001-l044.xml file, I see there's actually Egosoft placeholders for Meson Turrets, so I have modded the turret's identification parameters to point from the "Beam turret" entries to the "Meson turret" entries.
This works fine, and my TER beam turrets correctly get relabelled as Meson turrets in game.
Similar to missile turrets, Meson turrets don't have an in-game description beyond the default "No information available" entry so I'd like to add my own descriptions.

I see most mods add a new page id to the language files for this. I'm wondering if its possible to edit existing entries in the language files instead?
I've tried what I think is the right XML file location & syntax to do this, but it does nothing. Running the game in debug mode doesn't give any errors.

So I've got: C:/Users/[me]/Documents/Egosoft/X4/Extensions/[mod]/extensions/ego_dlc_terran/assets/props/WeaponSystems/energy/macros/turret_ter_m_beam_01_mk1_macro.xml

Code: Select all

<diff>
<replace sel="//macros/macro/properties/identification/@name">{20105,4924}</replace>
<replace sel="//macros/macro/properties/identification/@basename">{20105,4921}</replace>
<replace sel="//macros/macro/properties/identification/@shortname">{20105,4925}</replace>
<replace sel="//macros/macro/properties/identification/@description">{20105,4922}</replace>
</diff>
(And an identical file for "turret_ter_m_beam_02_mk1_macro.xml" as well)
This bit is definitely working

And then got: C:/Users/[me]/Documents/Egosoft/X4/Extensions/[mod]/t/0001-l044.xml

Code: Select all

<diff>
<replace sel="//language[@id='44']/page[@id='20105']/t[@id='4922']">My description here.</replace>
<replace sel="//language[@id='44']/page[@id='20105']/t[@id='5402']">{20105,4922}\n\nExtra description for L turret here.</replace>
</diff>
This doesn't seem to do anything.

Any help greatly appreciated!
Forleyor
Posts: 43
Joined: Thu, 11. Jun 15, 19:09
x4

Re: [Help] Editing Language Files

Post by Forleyor »

Shadow_180 wrote: Fri, 17. Jan 25, 14:55 I see most mods add a new page id to the language files for this. I'm wondering if its possible to edit existing entries in the language files instead?
Just had a look in the X4 modding discord channel (never tried it or needed to myself) and it does look like its possible, to quote UniTrader
to change the existing texts you must target the language specific ones since ego doesnt use the generic entries
for reference: t/0001-L044.xml:

Code: Select all

<diff>
 <replace sel="//page[@id='1001']/t[@id='410']/text()">\033RScripting \033Gin \033UProgress\033W.\033A.\033Z.</replace>
</diff>
worked for me.
Followed by
also just tried the imo better method and it did work too:

Code: Select all

<language id="44">
  <page id="1001">
    <t id="410">\033RScripting \033Gin \033UProgress\033W.\033A.\033Z.{5554301,2025}0.</t>
  </page>
</language>
Yours does look a little off to what Uni has so you could try those two.

Most people do add a new page as you say though, its the more accepted way to do it since it makes it less intrusive to vanilla data plus if you ever planned to make a release it as a mod (or even for your own personal use) you could make it an entirely new turret.

Of course if you are just exploring and tinkering then the above sentence isnt really relevant.
sprIder
Posts: 133
Joined: Sat, 3. Jul 10, 23:23
x4

Re: [Help] Editing Language Files

Post by sprIder »

Forleyor was faster.

Nevertheless:
Firstly, please do NOT use the Documents-folder for the mods. Mods belong to the extensions-folder in the installation folder of X4. E.g. steam: Steam\steamapps\common\X4 Foundations\extensions\[mod]
Shadow_180 wrote: Fri, 17. Jan 25, 14:55 I see most mods add a new page id to the language files for this.
That is the best and perhaps safest way to proceed. If your pageid is unique, nothing will interfere with your own text file. Think of the situation, if most modders will use existing page and text ids and more than one modder changes the same page and text id. This will end in chaos. So, please use your own page and text id.

But, yes, it is possible to change an existing entry. The game will load first the base game, then the dlcs and at last the mods. And if you have set a dependency to the terran dlc in your content file, everything should be in the correct load order.
For the text file you do not have to use "replace". Just add the page and text id again, which will overwrite the original entry.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
	<add sel="/language">
		<page id="20105" title="Weapons and Turrets" descr="Names and descriptions of weapons and turrets" voice="no">
			<t id="4922">My description here.</t>
			<t id="5402">{20105,4922}\n\nExtra description for L turret here.</t>
		</page>
	</add>
</diff>
Forleyor
Posts: 43
Joined: Thu, 11. Jun 15, 19:09
x4

Re: [Help] Editing Language Files

Post by Forleyor »

sprIder wrote: Fri, 17. Jan 25, 15:29 Firstly, please do NOT use the Documents-folder for the mods. Mods belong to the extensions-folder in the installation folder of X4. E.g. steam: Steam\steamapps\common\X4 Foundations\extensions\[mod]
Oh yes, extra bit of info on that: Documents folder for mods has been known to cause issues with mods loading correctly (windows 7 for example seems to fail at this alot more than later versions of windows)

Glad you pointed it out since I forgot to!

Return to “X4: Foundations - Scripts and Modding”