Diff code to add mining to all turrets on a ship?

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

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

User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Diff code to add mining to all turrets on a ship?

Post by apricotslice »

How would you do a diff file to add the word mining into every turret definition for a ship?

Is that even possible?

If so, can someone post the code for it?

With the XL miners mod defunct, I'm trying to modify the only ship mod I have working to also work as a miner.

But I've no idea how to do the diff file to add mining onto every turret, and there's too many to do each one, plus I'm not even sure how to do each one for a diff file. The ship is an XL. I've got gas mining going fine, but need the turrets changed to mount mining turrets, without which it won't mine solids.

If need be, if I only get one turret changed, that might be enough. But I need the diff code for that, or at least an example of it I can follow to do the right code.

Anyone help with some code?
sprIder
Posts: 135
Joined: Sat, 3. Jul 10, 23:23
x4

Re: Diff code to add mining to all turrets on a ship?

Post by sprIder »

I don't know if there is an easier way, but: Replace the tags of every turret.

Example: Argon carrier, the old one. File: ship_arg_xl_carrier_01.xml at "\assets\units\size_xl"

You maybe want to copy that file to the same file structure in your mod: extensions\YourMod\assets\units\size_xl\ship_arg_xl_carrier_01.xml

Now, your diff code needs to catch the corresponding turret and replace the tags:

Part of the original code:

Code: Select all

<components>
	<component name="ship_arg_xl_carrier_01" class="ship_xl">
		 ... 
			<connection name="con_turret_l_001" group="group_up_mid_mid " tags="turret large standard missile  combat ">
				<offset>
					<position x="0" y="159.3311" z="-242.3653"/>
				</offset>
			</connection>
			...
		</connections>
	</component>
</components> 
Your code

Code: Select all

<?xml version="1.0"?>
<diff>
	<replace sel="//connection[@name='con_turret_l_001']/@tags">turret large standard missile  combat mining </replace>
</diff>
This "replace code" would be needed then for every turret.

Just adding the tag "mining" seems not to work:

Code: Select all

<?xml version="1.0"?>
<diff>
	<add sel="//connection[@name='con_turret_l_001']/@tags"> mining </add>
</diff>
I hope this helps.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

Great, thanks. :D

With luck, only one turret will be needed. Or maybe 3 or 4 tops.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

Not working. The tags on the turret display are not changing, and no mining guns showing. And yet, there is nothing in the debug at all for the file.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff> 
  <replace sel="con_turret_001" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_002" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_003" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_004" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_005" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_006" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_007" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_008" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_009" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_010" tags="turret medium mining standard missile hittable  combat " />
  </replace>
  <replace sel="con_turret_laser_l_01" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_02" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_03" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_04" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_05" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_06" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_07" tags="turret large mining standard missile  combat " />
  </replace>
  <replace sel="con_turret_laser_l_08" tags="turret large mining standard missile  combat " />
  </replace>
 </diff>
 
This is the actual original code:

Code: Select all

<connection name="con_turret_02" group="group_back_mid_right" tags="turret medium standard missile hittable  combat">
				<offset>
					<position x="38.10917" y="4.43782" z="-224.1925"/>
					<quaternion qx="-2.065182E-07" qy="3.441969E-07" qz="0.7071068" qw="-0.7071068"/>
				</offset>
			</connection>
Any suggestions?
YellowBelllyBlackSnake
Posts: 19
Joined: Sun, 12. Jan 14, 23:05
x4

Re: Diff code to add mining to all turrets on a ship?

Post by YellowBelllyBlackSnake »

Comparing it to SprIder 's code, the "replace sel=" part of the code isn't right. It should look something like this.

Code: Select all

<replace sel="//connection[@name='con_turret_001']/@tags">turret medium mining standard missile hittable  combat </replace>
Also if you're only changing a few turrets, make sure that you change all the turrets in the same group, otherwise it likely won't work.

sprIder wrote: Thu, 8. Aug 24, 19:13 Just adding the tag "mining" seems not to work:

Code: Select all

<?xml version="1.0"?>
<diff>
	<add sel="//connection[@name='con_turret_l_001']/@tags"> mining </add>
</diff>
Shame it doesn't work, would make combining mods with different weapon tags a lot easier. My guess is that it doesn't appended "mining" into "tag", but instead makes it a child of "connection" or "tag".
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

YellowBelllyBlackSnake wrote: Fri, 9. Aug 24, 10:27 Comparing it to SprIder 's code, the "replace sel=" part of the code isn't right. It should look something like this.

Code: Select all

<replace sel="//connection[@name='con_turret_001']/@tags">turret medium mining standard missile hittable  combat </replace>
Also if you're only changing a few turrets, make sure that you change all the turrets in the same group, otherwise it likely won't work.
That isn't the same code as I have in my mods, so maybe that's why other things don't work now. They changed the format of the diff code?

I'll try that and see what happens.

sprIder wrote: Thu, 8. Aug 24, 19:13 Just adding the tag "mining" seems not to work:

Code: Select all

<?xml version="1.0"?>
<diff>
	<add sel="//connection[@name='con_turret_l_001']/@tags"> mining </add>
</diff>
Shame it doesn't work, would make combining mods with different weapon tags a lot easier. My guess is that it doesn't appended "mining" into "tag", but instead makes it a child of "connection" or "tag".
I think that code replaces the original tags with just mining. Just guessing, but without the combat tag, the ship won't fire to protect itself.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

Changing the code didn't work either. :(

This is what it looks like now.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff> 
<replace sel="//connection[@name='con_turret_001']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_002']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_003]/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_004']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_005']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_006']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_007']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_008']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_009']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_010']/@tags">turret medium mining standard missile hittable  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_01']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_02']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_03']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_04']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_05']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_06']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_07']/@tags">turret large mining standard missile  combat </replace>
<replace sel="//connection[@name='con_turret_laser_l_08']/@tags">turret large mining standard missile  combat </replace>
 </diff>
 
I did originally try doing a custom version of ship_spl_xl_carrier_01.xml, but I must have missed entries for it in other files, since that didn't work either.
YellowBelllyBlackSnake
Posts: 19
Joined: Sun, 12. Jan 14, 23:05
x4

Re: Diff code to add mining to all turrets on a ship?

Post by YellowBelllyBlackSnake »

Just tried your code and it does work, but only group L2 and M5 has mining turrets. I did find that the format of the names of the large turrets changes slightly after the first two, which is why only group L2 has mining turrets.

Here's the code with the names fixed up.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff> 
	<replace sel="//connection[@name='con_turret_001']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_002']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_003]/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_004']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_005']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_006']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_007']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_008']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_009']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_010']/@tags">turret medium mining standard missile hittable  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_01']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_02']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_003']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_004']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_005']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_006']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_007']/@tags">turret large mining standard missile  combat </replace>
	<replace sel="//connection[@name='con_turret_laser_l_008']/@tags">turret large mining standard missile  combat </replace>
 </diff>
apricotslice wrote: Fri, 9. Aug 24, 11:12
YellowBelllyBlackSnake wrote: Fri, 9. Aug 24, 10:27 Comparing it to SprIder 's code, the "replace sel=" part of the code isn't right. It should look something like this.

Code: Select all

<replace sel="//connection[@name='con_turret_001']/@tags">turret medium mining standard missile hittable  combat </replace>
Also if you're only changing a few turrets, make sure that you change all the turrets in the same group, otherwise it likely won't work.
That isn't the same code as I have in my mods, so maybe that's why other things don't work now. They changed the format of the diff code?

I'll try that and see what happens.
I don't think anything has changed with the formatting of diff code.
apricotslice wrote: Fri, 9. Aug 24, 11:12
sprIder wrote: Thu, 8. Aug 24, 19:13 Just adding the tag "mining" seems not to work:

Code: Select all

<?xml version="1.0"?>
<diff>
	<add sel="//connection[@name='con_turret_l_001']/@tags"> mining </add>
</diff>
Shame it doesn't work, would make combining mods with different weapon tags a lot easier. My guess is that it doesn't appended "mining" into "tag", but instead makes it a child of "connection" or "tag".
I think that code replaces the original tags with just mining. Just guessing, but without the combat tag, the ship won't fire to protect itself.
In theory it should append "mining" into "tags", but from testing it out yesterday, it doesn't actually affect anything (turrets are exactly the same as normal), which is why I'm thinking it places "mining" somewhere outside of "tags".
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

YellowBelllyBlackSnake wrote: Fri, 9. Aug 24, 13:22 Just tried your code and it does work, but only group L2 and M5 has mining turrets. I did find that the format of the names of the large turrets changes slightly after the first two, which is why only group L2 has mining turrets.
It's still not working for me.

This is a recurring theme for me. My code works for other people, but not for me, and it drives me nuts.

Where exactly did you put the file? Just in case I've got it wrong?
YellowBelllyBlackSnake
Posts: 19
Joined: Sun, 12. Jan 14, 23:05
x4

Re: Diff code to add mining to all turrets on a ship?

Post by YellowBelllyBlackSnake »

apricotslice wrote: Fri, 9. Aug 24, 14:23 Where exactly did you put the file? Just in case I've got it wrong?
I put it in "X4 Foundations\extensions\MOD-NAME\extensions\ego_dlc_split\assets\units\size_xl"
Because the Raptor is a DLC ship, you need to put it into an extensions folder in your mod's folder.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

YellowBelllyBlackSnake wrote: Fri, 9. Aug 24, 14:53
apricotslice wrote: Fri, 9. Aug 24, 14:23 Where exactly did you put the file? Just in case I've got it wrong?
I put it in "X4 Foundations\extensions\MOD-NAME\extensions\ego_dlc_split\assets\units\size_xl"
Because the Raptor is a DLC ship, you need to put it into an extensions folder in your mod's folder.
:o

Learn something new every day.

Thanks.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

Nope still not working.

I created the folders under the split DLC folder, and the diff file in size_xl.

Nothing changed.

What else am I missing, because I must be missing something?
YellowBelllyBlackSnake
Posts: 19
Joined: Sun, 12. Jan 14, 23:05
x4

Re: Diff code to add mining to all turrets on a ship?

Post by YellowBelllyBlackSnake »

Only thing I can think of is checking that the diff file name is "ship_spl_xl_carrier_01.xml", otherwise I'm really not sure why it isn't working.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

YellowBelllyBlackSnake wrote: Fri, 9. Aug 24, 14:53 I put it in "X4 Foundations\extensions\MOD-NAME\extensions\ego_dlc_split\assets\units\size_xl"
Wait. What?

I didn't read that properly. Extensions within the mod? :o :? :D

Okay, seems to be working now. The mining turrets are showing, although when you save the fitout, it's greyed out as incompatible equipment selected.

I'll try it in game and see if it will actually mine dirt.

Thanks.

Edit: SUCCESS! The 2 turrets are enough to get dirt mining working.

HUGE THANK YOU!!
sprIder
Posts: 135
Joined: Sat, 3. Jul 10, 23:23
x4

Re: Diff code to add mining to all turrets on a ship?

Post by sprIder »

apricotslice wrote: Sat, 10. Aug 24, 13:57 Okay, seems to be working now. The mining turrets are showing, although when you save the fitout, it's greyed out as incompatible equipment selected.
Is it still greyed out? Maybe check if you are missing at con_turret_003 the closing " ' " right " after con_turret_003 ".

wrong:

Code: Select all

<replace sel="//connection[@name='con_turret_003]/@tags">turret medium mining standard missile hittable  combat </replace>
correct:

Code: Select all

<replace sel="//connection[@name='con_turret_003']/@tags">turret medium mining standard missile hittable  combat </replace>
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Re: Diff code to add mining to all turrets on a ship?

Post by apricotslice »

Thanks for that. I'll check it next game play.

The ships are working nicely now, but really crappy at fighting though. Makes me think either miners were dumbed down for defending themselves, or freighter crews are just like that.

Anyway, it works, and that makes a world of difference to my game.

Return to “X4: Foundations - Scripts and Modding”