[TUTORIAL] XML Patch Guide
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
just checked myself: the lines you mentoined are not in that file, only available ones are:
XPath query for GM_Defend_Station.xml: //add_npc_line
Node add_npc_line speaker="$Client" line="3015" weight="50"
Node add_npc_line speaker="$Client" line="3016" weight="50"
Node add_npc_line speaker="$Client" line="3017" weight="50"
Node add_npc_line speaker="$Client" line="3018" weight="50"
Node add_npc_line speaker="$Client" line="3001" weight="50"
Node add_npc_line speaker="$Client" line="3002" weight="50"
Node add_npc_line line="12" comment="Goodbye."
where do you have your pasted Code from? possibly a Version prior to 3.61 or 4.0?
XPath query for GM_Defend_Station.xml: //add_npc_line
Node add_npc_line speaker="$Client" line="3015" weight="50"
Node add_npc_line speaker="$Client" line="3016" weight="50"
Node add_npc_line speaker="$Client" line="3017" weight="50"
Node add_npc_line speaker="$Client" line="3018" weight="50"
Node add_npc_line speaker="$Client" line="3001" weight="50"
Node add_npc_line speaker="$Client" line="3002" weight="50"
Node add_npc_line line="12" comment="Goodbye."
where do you have your pasted Code from? possibly a Version prior to 3.61 or 4.0?
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ah, that's right! Was wondering about this.
In GM_Defend_Station from 3.61, each of those numbers occurs only in one line each. In 4.00, there aren't any with line="13" and line="1031"
@pref, I'm guessing you unpacked 09.cat/dat, then updated to 4.00? If so, your diff is working with a different file.
In GM_Defend_Station from 3.61, each of those numbers occurs only in one line each. In 4.00, there aren't any with line="13" and line="1031"
@pref, I'm guessing you unpacked 09.cat/dat, then updated to 4.00? If so, your diff is working with a different file.
which one did you use? possibly from an earlier catalog than 09? (where the current one is)
if you reference the one in the catalog 08 - that one is from an older Version and not used anymore.
if you reference the one in the catalog 08 - that one is from an older Version and not used anymore.
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Yep, i used the ones from cat08.. would have never thought it has 2 instances of the whole md folder overwriting eachother.
Anyway another OT question: Is there a way to get rid of these diff errors?
The diff file has no errors and is exeecuted peroperly, but still i get one of these for each patch i have.
And thanks for pointing me to cat9, who knows how much time i would have wasted on google if not for you guys
Anyway another OT question: Is there a way to get rid of these diff errors?
Code: Select all
[General] ======================================
[=ERROR=] Error loading MD file extensions\SilenceYouAll\md\NPC_Shiptrader_Small.xml: Ignoring root node 'diff' in XML file 'extensions\SilenceYouAll\md\NPC_Shiptrader_Small.xml'.
And thanks for pointing me to cat9, who knows how much time i would have wasted on google if not for you guys
Hi all,
one question about changing single values in xml files via the diff / replace method.
The file i want to modify is "engineer.player.xml"
this is the source line i want to change:
<set_value name="$maxhullpercent" exact="60 + (30 * this.combinedskill / 100)" comment="between 60% and 100%"/>
to
exact="60 + (40 * this.combinedskill / 100)"
comment="between 60% and 100%"/>
My Problem is to find the right "Sel =" Value for adressing this.
I saw some mods doing this, but they all replace the complete script
even they change only this line:
<replace sel="/aiscript[@name='engineer.player']">
if i only need to change a single value, i dont want to replace the whole script
if possible.
as far is a understand the diff / replace xml patch there should be a way of ding this.
one question about changing single values in xml files via the diff / replace method.
The file i want to modify is "engineer.player.xml"
this is the source line i want to change:
<set_value name="$maxhullpercent" exact="60 + (30 * this.combinedskill / 100)" comment="between 60% and 100%"/>
to
exact="60 + (40 * this.combinedskill / 100)"
comment="between 60% and 100%"/>
My Problem is to find the right "Sel =" Value for adressing this.
I saw some mods doing this, but they all replace the complete script
even they change only this line:
<replace sel="/aiscript[@name='engineer.player']">
if i only need to change a single value, i dont want to replace the whole script
if possible.
as far is a understand the diff / replace xml patch there should be a way of ding this.
the single line is not enough to get a Path, you need the context , too
two possibilities:
long variant:
short Variant ( since //set_value[@name="$maxhullpercent"] is unique in this Script):
you can confirm the sel paths by using » Extensions/XML Tools/Evaluate XPath Expression « in NPP, or similiar functions in other XML Editors
two possibilities:
long variant:
Code: Select all
<replace sel='/aiscript/attention/actions/set_value[@name="$maxhullpercent"]/@exact'>60 + (40 * this.combinedskill / 100)</replace>
Code: Select all
<replace sel='//set_value[@name="$maxhullpercent"]/@exact'>60 + (40 * this.combinedskill / 100)</replace>
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
I didn't realise that you could do this so gave it a try on a small diff file of mine using NPPUniTrader wrote:you can confirm the sel paths by using » Extensions/XML Tools/Evaluate XPath Expression « in NPP, or similiar functions in other XML Editors
It came back with
Validation of current file using XML schema:
ERROR: Element 'diff': This element is not expected.
I have a feeling that the diff element is missing from my rfc5261.xsd https://www.dropbox.com/s/94t86p236o5b4 ... h.xsd?dl=0
I found one from MadJoker my copy https://www.dropbox.com/s/p29kj66zbin45 ... 1.xsd?dl=0 that gets a bit further, it has a diff element at the bottom
ERROR: Element 'add': This element is not expected.
Do you have a working link to your rfc5261.xsd file please ?
Thanks
jth
Thats not what I meant - I meant opening the original file and making an XPath query there - for valid sel expressions there must be exactly one resultjth wrote:I didn't realise that you could do this so gave it a try on a small diff file of mine using NPPUniTrader wrote:you can confirm the sel paths by using » Extensions/XML Tools/Evaluate XPath Expression « in NPP, or similiar functions in other XML Editors
It came back with
Validation of current file using XML schema: Element 'diff': This element is not expected.
And although I have an rfc5261.xsd lying around somewhere I have not used it yet.. The 4 possible nodes it contains can be written from memory and the anycontent in the add node also isn't much help (checking if its well-formed is a must though - but this does not require an xsd)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Thats not what I meant - I meant opening the original file and making an XPath query there - for valid sel expressions there must be exactly one resultjth wrote:I didn't realise that you could do this so gave it a try on a small diff file of mine using NPPUniTrader wrote:you can confirm the sel paths by using » Extensions/XML Tools/Evaluate XPath Expression « in NPP, or similiar functions in other XML Editors
It came back with
Validation of current file using XML schema: Element 'diff': This element is not expected.
And although I have an rfc5261.xsd lying around somewhere I have not used it yet.. The 4 possible nodes it contains can be written from memory and the anycontent in the add node also isn't much help (checking if its well-formed is a must though - but this does not require an xsd)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Oops misunderstood Will continue to write my diff files in MS Visual C# to get the syntax checked there.UniTrader wrote:Thats not what I meant - I meant opening the original file and making an XPath query there - for valid sel expressions there must be exactly one resultjth wrote:I didn't realise that you could do this so gave it a try on a small diff file of mine using NPPUniTrader wrote:you can confirm the sel paths by using » Extensions/XML Tools/Evaluate XPath Expression « in NPP, or similiar functions in other XML Editors
It came back with
Validation of current file using XML schema: Element 'diff': This element is not expected.
And although I have an rfc5261.xsd lying around somewhere I have not used it yet.. The 4 possible nodes it contains can be written from memory and the anycontent in the add node also isn't much help (checking if its well-formed is a must though - but this does not require an xsd)
jth
big thx for the fast answer.
coding xml is (was) a bit new for me
i got myself some xml editors, an read a lot about XR modding
btw anaylsing "engineer.player.xml" i discovered that the onboard
egineer only repairs components.
so even it got my first solution running with changing only some values
via diff/replace doesent help for my target:
"onboad engineer repairs hull too"
at last i learned how to replace some values and not to replace the whole script. (great tutorial at beginning of this thread, big thx)
in my 2nd solution i had to add and reorganize some code , change debug infos etc. , so v2 replaces the whole script. ("engineer.player.xml")
Now my onboard engineer on the skunk repairs my hull, after he
repaired all other stuff. repairpercentage depends on his skills.
i also reduced the repair speed, original took only seconds, far
away from realism, at last on my opinion.
and now looking forward to 25.feb what will bring the XR 4.0 patch
and the new dlc
coding xml is (was) a bit new for me
i got myself some xml editors, an read a lot about XR modding
btw anaylsing "engineer.player.xml" i discovered that the onboard
egineer only repairs components.
so even it got my first solution running with changing only some values
via diff/replace doesent help for my target:
"onboad engineer repairs hull too"
at last i learned how to replace some values and not to replace the whole script. (great tutorial at beginning of this thread, big thx)
in my 2nd solution i had to add and reorganize some code , change debug infos etc. , so v2 replaces the whole script. ("engineer.player.xml")
Now my onboard engineer on the skunk repairs my hull, after he
repaired all other stuff. repairpercentage depends on his skills.
i also reduced the repair speed, original took only seconds, far
away from realism, at last on my opinion.
and now looking forward to 25.feb what will bring the XR 4.0 patch
and the new dlc
currently cannt look in the original file but if you are going for a complete rewrite of a vanilla Script (not preserving Blocking actions or dont want to care about them) i would suggest to copy the original Script to a completely new Script where you can do all your canges freely and call this script from the original Script either as interrupt script or as called Script (latter case only works if there are deactivated blocking actions from before a major overhaul) - this way you dont have to care about the Script Structure and when you remove your changed script it will go back to the old behavior without problems. this may not be the case if you change the original Script and additionally may introduce compatibility issues if ego ecides to update this Script..
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Hi Unitrader,
i copied the the script "engineer.player.xml" from the original game (V3.161)
then i added diff / replace code to replace the complete script,
so i am using a modified original script.
- changed debug statements , added "Filter=error", set chance to 100
to get debug info.
- adde new code for the hull repair with debugstatements.
Blocking actions are new for me, can you provide a linke where
to get detailed infos ?
"Call the script from the original script as interrupt or as called script"
sounds interesting. would like to see some code examples
any links for infos ?
btw thanks
i copied the the script "engineer.player.xml" from the original game (V3.161)
then i added diff / replace code to replace the complete script,
so i am using a modified original script.
- changed debug statements , added "Filter=error", set chance to 100
to get debug info.
- adde new code for the hull repair with debugstatements.
Blocking actions are new for me, can you provide a linke where
to get detailed infos ?
"Call the script from the original script as interrupt or as called script"
sounds interesting. would like to see some code examples
any links for infos ?
btw thanks
Hey everyone, got a question for you...
What do I do if I wish to patch a part of a file that's being added to by another extension?
Case and point: I want to patch weaponmods.xml in the libraries folder. Obviously this includes patching the weaponmods that come with the two DLC's as well. But the DLC's themselves are also considered extensions and they are adding the weaponmods for the new weapons via <add sel= >
I am guessing for my patch to work, it will have to load after the Egosoft extensions... but how do I ensure that?
What do I do if I wish to patch a part of a file that's being added to by another extension?
Case and point: I want to patch weaponmods.xml in the libraries folder. Obviously this includes patching the weaponmods that come with the two DLC's as well. But the DLC's themselves are also considered extensions and they are adding the weaponmods for the new weapons via <add sel= >
I am guessing for my patch to work, it will have to load after the Egosoft extensions... but how do I ensure that?
1. you can change the load order with an
<dependency id="***ID of other mod" optional="true" />
to make sure your mod is loaded after another mod if present (if you leave out the optional the other mod is a requirement and it wont work without)
2. then just do your changes as if the other patch file already did its work. if some f the operations might not be possible because of missing Extensions (or Extensions breaking them) mark them with an optional="true" to suppress related errors (or was it silent="true" ? )
like this:
<add sel="///////////" optional="true"><Your_additional_stuff/></add>
<dependency id="***ID of other mod" optional="true" />
to make sure your mod is loaded after another mod if present (if you leave out the optional the other mod is a requirement and it wont work without)
2. then just do your changes as if the other patch file already did its work. if some f the operations might not be possible because of missing Extensions (or Extensions breaking them) mark them with an optional="true" to suppress related errors (or was it silent="true" ? )
like this:
<add sel="///////////" optional="true"><Your_additional_stuff/></add>
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
You have to set a dependency on the DLCs.
If you want to affect only the load order, but not depend on other extensions, then you can add a line like this in content.xml (note the optional attribute):
However it only works for workshop mods - iirc not even DLCs, so it might be that you have to set a dependency then. If this is the case, you might have to release a compatibility mod for the DLC(s) separately which depends on the DLC(s) and your original mod.
If you want to affect only the load order, but not depend on other extensions, then you can add a line like this in content.xml (note the optional attribute):
Code: Select all
<content ... >
<dependency id="ws_xxxxxxxx" optional="true" name="ModName"></dependency>
</content>
Okay, thank you!
I am trying to find a way to customize the attributes of spawned weaponmods for my cheat script (and since there's no way to specify the attributes of spawned inventory ware directly through script at the moment... had to resort to patching).
So I wrote this as a test (for libraries/weaponmods.xml)
Replacing this:
With:
The weaponmods now spawn with no attributes at all... but I am not sure what's wrong with it. Is the game expecting ONLY min-max values or something?
I am trying to find a way to customize the attributes of spawned weaponmods for my cheat script (and since there's no way to specify the attributes of spawned inventory ware directly through script at the moment... had to resort to patching).
So I wrote this as a test (for libraries/weaponmods.xml)
Replacing this:
Code: Select all
<weapon macro="weapon_player_impulse_mk1_macro" weight="10"><!--0.135-->
<damage min="1.05" max="1.1" weight="18"/>
<cooling min="0.92" max="1.77" weight="2"/>
<reload min="0.6" max="1.04" weight="13"/>
<speed min="0.4" max="1.1" weight="3"/>
<lifetime min="1.05" max="2.0" weight="14"/>
</weapon>
Code: Select all
<replace sel="/weaponmods/weapons/weapon[@macro='weapon_player_impulse_mk1_macro']/damage">
<damage exact="1.5" weight="18"/>
</replace>
<replace sel="/weaponmods/weapons/weapon[@macro='weapon_player_impulse_mk1_macro']/cooling">
<cooling exact="3" weight="2"/>
</replace>
<replace sel="/weaponmods/weapons/weapon[@macro='weapon_player_impulse_mk1_macro']/reload">
<reload exact="1.5" weight="13"/>
</replace>
<replace sel="/weaponmods/weapons/weapon[@macro='weapon_player_impulse_mk1_macro']/speed">
<speed exact="1.5" weight="3"/>
</replace>
<replace sel="/weaponmods/weapons/weapon[@macro='weapon_player_impulse_mk1_macro']/lifetime">
<lifetime exact="2.0" weight="14"/>
</replace>
according to xsd file yes.Simoom wrote:The weaponmods now spawn with no attributes at all... but I am not sure what's wrong with it. Is the game expecting ONLY min-max values or something?
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Hey everyone, sorry for so many questions...
- I am trying to patch some more files right now, and am wondering if there's an easier way to patch an entire block of text, or if I have to do it line by line? I see that <remove> has a ws attribute that allows me to remove a whole node block... but can I do something similar with <replace>?
- Does the line I replace always have to be closed? I need to replace this (from Upkeep.xml) with some values of my own:
But as you can see this tag is not closed, and Visual Studio flags it.
Code: Select all
<do_if value="not $Ship.buildmodule and $Ship.primarypurpose != objectpurpose.mine">