[HELP] <diff> do_elseif selector

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

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

Strawberry04
Posts: 3
Joined: Thu, 25. Mar 21, 23:17
x4

[HELP] <diff> do_elseif selector

Post by Strawberry04 »

Hello, anyone have clue about selectors for do_if? I want to do <diff> for xml script inside md folder structure which looks like this:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<mdscript name="A" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<cues>
		<cue name="B">
			<SomeOtherStuff></SomeOtherStuff>
			<cues>	
				<SomeOtherStuff></SomeOtherStuff>
				<cue name="C">
					<do_if value="$XX">Doing stuff</do_if>
					<do_if value="$YY">
						<do_if value="$YY.macro.name == readtext.{20101}.{40101}">Doing stuff</do_if>
						<!-- I want to add my new condition here -->
						<do_elseif value="$YY.macro.name == readtext.{20101}.{42601}">Doing stuff</do_elseif>
Does following code look right to you? It does not work and I do not know what is wrong. Also is there any way to skip part of the path and dive directly to concrete <do_elseif> ? So i do not need to write entire path for complicated xml's like this?

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>			
<diff>
	<Add sel="/mdscript[@name='A']/cues/cue[@name='B']/cues/cue[@name='C']/do_if[@value='$YY']/do_elseif[@value='$YY.macro.name == readtext.{20101}.{42601}']" pos="before">
		<do_elseif value="$YY.macro.name == readtext.{1}.{1111}">Doing my own stuff</do_elseif>
	</add>
</diff>
I am new to this stuff. Thank's for all possible solutions.
BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7465
Joined: Mon, 15. Dec 03, 18:53
x4

Re: [HELP] <diff> do_elseif selector

Post by BlackRain »

Strawberry04 wrote: Mon, 5. Apr 21, 14:04 Hello, anyone have clue about selectors for do_if? I want to do <diff> for xml script inside md folder structure which looks like this:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<mdscript name="A" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<cues>
		<cue name="B">
			<SomeOtherStuff></SomeOtherStuff>
			<cues>	
				<SomeOtherStuff></SomeOtherStuff>
				<cue name="C">
					<do_if value="$XX">Doing stuff</do_if>
					<do_if value="$YY">
						<do_if value="$YY.macro.name == readtext.{20101}.{40101}">Doing stuff</do_if>
						<!-- I want to add my new condition here -->
						<do_elseif value="$YY.macro.name == readtext.{20101}.{42601}">Doing stuff</do_elseif>
Does following code look right to you? It does not work and I do not know what is wrong. Also is there any way to skip part of the path and dive directly to concrete <do_elseif> ? So i do not need to write entire path for complicated xml's like this?

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>			
<diff>
	<Add sel="/mdscript[@name='A']/cues/cue[@name='B']/cues/cue[@name='C']/do_if[@value='$YY']/do_elseif[@value='$YY.macro.name == readtext.{20101}.{42601}']" pos="before">
		<do_elseif value="$YY.macro.name == readtext.{1}.{1111}">Doing my own stuff</do_elseif>
	</add>
</diff>
I am new to this stuff. Thank's for all possible solutions.
A simple

<add sel="//do_elseif[@value='$YY.macro.name == readtext.{20101}.{42601}']" pos="before"> should work I think.
Strawberry04
Posts: 3
Joined: Thu, 25. Mar 21, 23:17
x4

Re: [HELP] <diff> do_elseif selector

Post by Strawberry04 »

BlackRain wrote: Mon, 5. Apr 21, 14:19 A simple

<add sel="//do_elseif[@value='$YY.macro.name == readtext.{20101}.{42601}']" pos="before"> should work I think.
Thank you, I will try it. Also does folder structure matter if i want to do diff for xml files? I already did some simple diff mods, but i am still unsure how to do folder structure, especially for .cat files and when i mod some dlc stuff or other mods.
For example:
mod A xml file resides in path (starting from X4 root folder):

Code: Select all

extensions\ModAFolder
That folder contains cat file which has listed path for desired xml:

Code: Select all

md/desiredFile.xml 1111 1111111111 11111b111b1b1b1b1b1
I want to do mod B which changes something mod A does in desiredFile.xml (<diff>)
So i create

Code: Select all

extensions\ModBFolder\md\desiredFile.xml
Put my diff code in it.
Try to run game without generating .cat file. Is this right or should mod B structure look different?

If i generate cat file for mod B, path inside .cat will look like this:

Code: Select all

md/desiredFile.xml 2222 222222222 122221b111b1b1b1b1b1
Is this right? Or should my cat file look like this:

Code: Select all

extensions/ModAFolder/md/desiredFile.xml 2222 222222222 122221b111b1b1b1b1b1

Return to “X4: Foundations - Scripts and Modding”