How do I add a edited xml file back into a catalog?

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

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

Post Reply
Midnitewolf
Posts: 564
Joined: Tue, 23. Mar 21, 06:18

How do I add a edited xml file back into a catalog?

Post by Midnitewolf » Thu, 15. Apr 21, 20:45

Hi Guys,

I am a complete newbie at doing anything involving editing files in a game and am trying to figure this out.

I am trying to add the missing drone capacity to TER defensive modules. I have managed to download X Tools from Steam, find the correct catalogs, use the Catalog Tool to extract them, edit the XML file (correctly I hope) and now need to take the modified files and put them back into the catalog and I am not 100% sure how to do this. Can anyone walk me though it?

daBeschi
Posts: 76
Joined: Mon, 28. Jan 19, 14:04
x4

Re: How do I add a edited xml file back into a catalog?

Post by daBeschi » Fri, 16. Apr 21, 10:05

Hello,

This is not the way. You now know the file and path, so you should make a mod with a patch for this file entry. Help for patching HERE.

Put the File in your MOD in subfolder "assets\structures\defence\macros" :

Code: Select all

<diff>
  <add sel="/defence_ter_disc_01_macro/properties">
      <storage unit="15" />
  </add>
</diff>

or

<diff>
  <add sel="macro[@name='defence_ter_disc_01_macro']/properties">
      <storage unit="15" />
  </add>
</diff>
I'm not 100 % sure if this code is correct, but should give you an idea and I hope some experienced community member can correct me if I#m wrong.

Greetings

Midnitewolf
Posts: 564
Joined: Tue, 23. Mar 21, 06:18

Re: How do I add a edited xml file back into a catalog?

Post by Midnitewolf » Sat, 17. Apr 21, 07:18

daBeschi wrote:
Fri, 16. Apr 21, 10:05
Hello,

This is not the way. You now know the file and path, so you should make a mod with a patch for this file entry. Help for patching HERE.

Put the File in your MOD in subfolder "assets\structures\defence\macros" :

Code: Select all

<diff>
  <add sel="/defence_ter_disc_01_macro/properties">
      <storage unit="15" />
  </add>
</diff>

or

<diff>
  <add sel="macro[@name='defence_ter_disc_01_macro']/properties">
      <storage unit="15" />
  </add>
</diff>
I'm not 100 % sure if this code is correct, but should give you an idea and I hope some experienced community member can correct me if I#m wrong.

Greetings
See the biggest issue for me is that as soon as I looked at that guide, it was like trying to read Klingon for me. I feel I am pretty smart in general and compared to the average person, more technicall overall but when it comes to any sort of programing, creating XML files, or anything like that I am lost. For example, I figured out how to modify the XML macro or whatever that file was by looking at the Split defensive module and then making sure the TER file looked exactly the same using an XML editor program I found on the net. The problem is I have no clue why the line of code, text or whatever goes there or the significance of the spaces, /, > or what any of that means.

So yeah, adding a few lines, saving the file and putting in back where it goes is about the extent of things with me. Actually making those two files I edited into a mod that the game would actually read and use....yeah no. Honestly it probably isn't that hard, but I know my limitations. I ended up just adding some Teladi defensive modules to my Terran Defense Platforms since it sort of matches ok. Kind of a pain and not nearly as efficient as having the TER structures having their own drones, but at least I got it where I have about 100 drones each on my stations. Maybe the devs will fix this in the next patch or someone not totally useless like me when it comes to modding will make it into a real mod some day.

chip56
Posts: 500
Joined: Mon, 13. Apr 20, 21:52

Re: How do I add a edited xml file back into a catalog?

Post by chip56 » Sat, 17. Apr 21, 10:32

Midnitewolf wrote:
Sat, 17. Apr 21, 07:18

See the biggest issue for me is that as soon as I looked at that guide, it was like trying to read Klingon for me. I feel I am pretty smart in general and compared to the average person, more technicall overall but when it comes to any sort of programing, creating XML files, or anything like that I am lost. For example, I figured out how to modify the XML macro or whatever that file was by looking at the Split defensive module and then making sure the TER file looked exactly the same using an XML editor program I found on the net. The problem is I have no clue why the line of code, text or whatever goes there or the significance of the spaces, /, > or what any of that means.

So yeah, adding a few lines, saving the file and putting in back where it goes is about the extent of things with me. Actually making those two files I edited into a mod that the game would actually read and use....yeah no. Honestly it probably isn't that hard, but I know my limitations. I ended up just adding some Teladi defensive modules to my Terran Defense Platforms since it sort of matches ok. Kind of a pain and not nearly as efficient as having the TER structures having their own drones, but at least I got it where I have about 100 drones each on my stations. Maybe the devs will fix this in the next patch or someone not totally useless like me when it comes to modding will make it into a real mod some day.
Guess, i shouldnt have only pointed you at the file itself and what line you would need there. The others are actually right that the correct way would be to patch the drones in and use it as extension.

The solution they propose is actually not that much harder. The biggest hurdle is actually finding the right stuff by extracting the files from the catalog and you managed to do that already.

1) You go to your extension folder in the x4 folder. If i does not exist you create a folder with it and a subolder for your mod. you should now have a folder "X4 Foundations\extensions\mydronemod" or however you want to call your mod.
2) Since you are editing a file from "assets\structures\defence\macros" you should follow that folder logic and put those subfolders in too.
3) in That subfolder you need to put an xml file that adds the line <storage unit="15" /> into the right positions. Dont worry thats not as hard as it sounds now. We are going to this the easy way: just copy your edited file there for now.
4) You now know what line you have and to what module you want to add it, after all you have this file already. So you do what Dabeschi wrote. You simple write his code into that file. Remove everything else so that only his text is in that file. You actually only need the main file so that you know what module you want to edit and what the correct thing for addign drones is. You already know that by now.
<add sel="/defence_ter_disc_01_macro/properties"> means you add more lines to the defence_ter_disc_01_macro file and you add them in the /properties part. If you only want to edit the disc you only need to add it there. If you want to add it to other modules too you can do that in one file. The <something> and </something> are the start and end of something. <add> means now you start adding the part that follows and </add> means this one additon is finished now. if you would do another <add> then you could edit a second module. If the <add> instead looks like <add sel "something"> it is a parameter that explains where exactly it should be added.
5) save the file
6) create a content xml in the "X4 Foundations\extensions\mydronemod" folder. I recommend you just download any other mod, copy paste it and just change your name, description and so on. That file should be pretty self explaining, especially since you only need to change the text.
7) Enter x4 and make sure your extension is activated.

daBeschi
Posts: 76
Joined: Mon, 28. Jan 19, 14:04
x4

Re: How do I add a edited xml file back into a catalog?

Post by daBeschi » Sat, 17. Apr 21, 12:12

Hello,

Got it to work. You need your MOD folder and one other ...
...\extensions\YOURMODNAMEHERE\extensions\ego_dlc_terran\assets\structures\defence\macros

1) at YOURMODNAMEHERE you copy/create a "content.xml" file containing something like ...

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<content id="YOURMODNAMEHERE" name="YOURMODNAMEHERE" description="Your MOD description" author="You" version="1" date="2019-04-17" save="0" enabled="1">
	<text language="44" name="YOURMODNAMEHERE" description="Your MOD description shown in the game" author="You" />
	<text language="49" name="YOURMODNAMEHERE" description="Your MOD description shown in the game" author="You" />
</content>
- I always matched content id, name and MOD folder name
- the number behind <text language> should be your game language (49 stands for german and 44 english for example)

2) easiest way seems to copy the files you want to edit to ...\extensions\YOURMODNAMEHERE\extensions\ego_dlc_terran\assets\structures\defence\macros
then you can replace all with

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<add sel="/macros/macro/properties">
		<storage unit="15" />
	</add>
</diff>
in both files (i assume disc and bridge). You also can comment out the other lines with "<!--" and "-->" at the end of the comment section like here

Code: Select all

<!--Exported by: nick (192.168.3.124) at 06.01.2020_16-32-21-->
3) save your files, load the game, make sure you activate the extension and the effect should be instantly visible on existing modules and in the encyclopedia

It took me an hour because I am stupid and missed first that COH is an extension (... therefore \extensions\ego_dlc_terran\ ...) and second I had a typo in <add sel="/macros/macro/properties"> (...properties"/>).

Hope now you can create your MOD.

Greetings

Post Reply

Return to “X4: Foundations - Scripts and Modding”