question on xml patching

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

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

Post Reply
unheardof
Posts: 18
Joined: Tue, 18. May 21, 22:48
x4

question on xml patching

Post by unheardof » Sat, 7. May 22, 05:23

im trying to make an xml patch to change the starting ship and its loadout in the pirate start number 1 where you start with the cargo ship i want to change it to a ship from my mod here is the code so far if anyone can point out if i have anything wrong with it id greatly appreciate it

<?xml version="1.0" encoding="utf-8"?>
<diff>
<replace sel="//macro[@name='ship_pir_s_trans_container_01_a_macro']">
<ship macro="ghost_macro">
</replace>
<replace sel="//macro[@name='ship_pir_s_trans_container_01_a_macro']/loadout/macros">
<engine macro="engine_s_ftl_macro" path="../con_engine_02"/>
<engine macro="engine_s_ftl_macro" path="../con_engine_01"/>
<weapon macro="weapon_s_laser_macro" path="../con_weapon_01"/>
<shield macro="shield_s_aegis_macro" path="../con_shield_01"/>
</replace>
<add sel="//macro[@name='ship_pir_s_trans_container_01_a_macro']/loadout/macros">
<weapon macro="weapon_s_laser_macro" path="../con_weapon_02"/>
<weapon macro="weapon_s_mtorpedo_macro" path="../con_weapon_03"/>
<weapon macro="weapon_s_mtorpedo_macro" path="../con_weapon_04"/>
<shield macro="shield_s_aegis_macro" path="../con_shield_02"/>
</add>
</diff>

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1872
Joined: Mon, 23. Nov 15, 18:02

Re: question on xml patching

Post by j.harshaw » Wed, 18. May 22, 17:23

unheardof wrote:
Sat, 7. May 22, 05:23
<replace sel="//macro[@name='ship_pir_s_trans_container_01_a_macro']">
<ship macro="ghost_macro">
</replace>
should be <replace sel="//ship[@macro='ship_pir_s_trans_container_01_a_macro']"> since you're trying to replace this node:

<ship macro="ship_pir_s_trans_container_01_a_macro">
...
</ship>

Also, if going that route, you'll have to populate everything within the ship node in the same go since it'll replace the entire node. (Everything between <ship macro="ship_pir_s_trans_container_01_a_macro"> and the closing </ship> line.)

And make sure your mod specifies a dependency to ego_dlc_pirate to make sure that the DLC is loaded before your mod is.

Post Reply

Return to “X4: Foundations - Scripts and Modding”