Little xml help please...

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

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

Post Reply
Eukatae
Posts: 52
Joined: Thu, 28. Feb 13, 16:22
x4

Little xml help please...

Post by Eukatae » Sun, 19. Dec 21, 18:35

I am trying to do this:

Code: Select all

<replace sel="/macros/macro[@name='character_argon_female_cau_crew_01_macro']/properties/models//model[@type='torso']">
        <model type="torso" selection="random">
          <select weight="20" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
          <select weight="20" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_leather_01" />
          <select weight="50" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_ter_f_pilot_suit_01" />
          <select weight="10" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01" />
        </model>
</replace>
But when I do I get a debug error saying it matches multiple nodes and skips it. I think it is because of an error in the original file:

Code: Select all

        <model type="torso" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
        <model type="torso" selection="random">
          <select weight="50" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
          <select weight="50" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_leather_01" />
        </model>
Note the two <model type="torso"> nodes.

This didn't work, same error:

Code: Select all

<remove sel="/macros/macro[@name='character_argon_female_cau_pilot_01_macro']/properties/models//model[@type='torso']"/>

<add sel="/macros/macro[@name='character_argon_female_cau_pilot_01_macro']/properties/models//model[@type='torso']">
        <model type="torso" selection="random">
          <select index="1" weight="20" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
          <select index="1" weight="20" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_leather_01" />
          <select index="1" weight="50" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_ter_f_pilot_suit_01" />
          <select index="1" weight="10" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01" />
        </model>
</add>
So what do I need to do?
Feel free to call me a maroon, I am anything but proficient with xml.

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

Re: Little xml help please...

Post by j.harshaw » Sun, 19. Dec 21, 23:21

Eukatae wrote:
Sun, 19. Dec 21, 18:35
I am trying to do this:

Code: Select all

<replace sel="/macros/macro[@name='character_argon_female_cau_crew_01_macro']/properties/models//model[@type='torso']">
        <model type="torso" selection="random">
          <select weight="20" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
          <select weight="20" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_leather_01" />
          <select weight="50" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_ter_f_pilot_suit_01" />
          <select weight="10" ref="extensions/ego_dlc_terran/assets/characters/terran/bodies/char_pio_f_pilot_suit_01" />
        </model>
</replace>
But when I do I get a debug error saying it matches multiple nodes and skips it. I think it is because of an error in the original file:

Code: Select all

        <model type="torso" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
        <model type="torso" selection="random">
          <select weight="50" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
          <select weight="50" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_leather_01" />
        </model>
Note the two <model type="torso"> nodes.
Path you specified resolves to two possible nodes as the error suggests so it's unclear which node you want replaced. Not sure if specifying two attributes is supported. You could give this a try:

Code: Select all

sel="//macro[@name='character_argon_female_cau_crew_01_macro']//model[@type='torso'][@selection='random']"
This might be useful for testing xpath until you get the hang of it:

http://www.whitebeam.org/library/guide/ ... stbed.rhtm

edit: going through the logs, i'm not seeing a state of character_macros.xml where both of those torso nodes are present, however. are you trying to mod a mod or something?

Eukatae
Posts: 52
Joined: Thu, 28. Feb 13, 16:22
x4

Re: Little xml help please...

Post by Eukatae » Mon, 20. Dec 21, 05:32

j.harshaw wrote:
Sun, 19. Dec 21, 23:21
Path you specified resolves to two possible nodes as the error suggests so it's unclear which node you want replaced. Not sure if specifying two attributes is supported. You could give this a try:

Code: Select all

sel="//macro[@name='character_argon_female_cau_crew_01_macro']//model[@type='torso'][@selection='random']"
This might be useful for testing xpath until you get the hang of it:

http://www.whitebeam.org/library/guide/ ... stbed.rhtm

edit: going through the logs, i'm not seeing a state of character_macros.xml where both of those torso nodes are present, however. are you trying to mod a mod or something?
The code:

Code: Select all

  <macro name="character_argon_female_cau_pilot_01_macro" class="npc" ref="character_argon_female_cau_base_01_macro">
    <component ref="character_argon_female_01" />
    <properties>
      <models>
        <model type="head" ref="assets/characters/argon/heads/char_arg_f_dyn_blend_head" />
        <model type="torso" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
        <model type="torso" selection="random">
          <select weight="50" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01" />
          <select weight="50" ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_leather_01" />
        </model>
        <model type="props" selection="random">
          <select weight="8" ref="assets/characters/argon/props/Ter_f_hair_bun_01" />
          <select weight="6" ref="assets/characters/argon/props/Ter_f_hair_bun_black_01" />
          <select weight="10" ref="assets/characters/argon/props/Ter_f_hair_bun_blonde_01" />
          <select weight="4" ref="assets/characters/argon/props/Ter_f_hair_bun_ginger_01" />
          <select weight="2" ref="assets/characters/argon/props/Ter_f_hair_bun_green_01" />
          <select weight="2" ref="assets/characters/argon/props/Ter_f_hair_bun_pink_01" />
          <select weight="8" ref="assets/characters/argon/props/Ter_f_hair_short_01" />
          <select weight="6" ref="assets/characters/argon/props/Ter_f_hair_short_black_01" />
          <select weight="10" ref="assets/characters/argon/props/Ter_f_hair_short_blonde_01" />
          <select weight="4" ref="assets/characters/argon/props/Ter_f_hair_short_ginger_01" />
          <select weight="2" ref="assets/characters/argon/props/Ter_f_hair_short_green_01" />
          <select weight="2" ref="assets/characters/argon/props/Ter_f_hair_short_pink_01" />
          <select weight="8" ref="assets/characters/argon/props/Ter_f_hair_bangs_01" />
          <select weight="6" ref="assets/characters/argon/props/Ter_f_hair_bangs_black_01" />
          <select weight="10" ref="assets/characters/argon/props/Ter_f_hair_bangs_blonde_01" />
          <select weight="4" ref="assets/characters/argon/props/Ter_f_hair_bangs_ginger_01" />
          <select weight="2" ref="assets/characters/argon/props/Ter_f_hair_bangs_green_01" />
          <select weight="2" ref="assets/characters/argon/props/Ter_f_hair_bangs_pink_01" />
        </model>
      </models>
    </properties>
  </macro>
Is from the original character_macros.xml in libraries\character_macros.xml as of 4.2.
I assume there shouldn't be two identical attributes, should there?
I would like to replace both with my single node.

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Re: Little xml help please...

Post by |K.O.S.H. » Mon, 20. Dec 21, 10:43

Should not solve the problem, but you edit character_argon_female_cau_crew_01_macro (crew), but you posted the xml for "character_argon_female_cau_pilot_01_macro" (pilot).

However, as you say, the property is defined twice in the original code.
I think you are right, this is a bug in the original file. (in my x-perience the first aappearance will be used)

You can try to select the 3rd element instead.
But that will not be very future proofe, specially, when this issue gets fixed...

or you select the element where @ref="assets/characters/argon/bodies/char_arg_f_jacket_fighterpilot_01"
but the same problem will occur, when this gets fixed..

Safe way would be to replace the whole properties-tag
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Re: Little xml help please...

Post by j.harshaw » Mon, 20. Dec 21, 12:09

|K.O.S.H. wrote:
Mon, 20. Dec 21, 10:43
Should not solve the problem, but you edit character_argon_female_cau_crew_01_macro (crew), but you posted the xml for "character_argon_female_cau_pilot_01_macro" (pilot).
Thanks for pointing this out. Have informed the dev responsible for character macros.
Eukatae wrote:
Mon, 20. Dec 21, 05:32
I would like to replace both with my single node.
You'd have to act on the two nodes separately, similar to what you earlier posted but the xpath expressions specified in the sel attribute have to resolve to only one node each; and you'll want remove and replace rather than remove and add. Or replace the parent node as |K.O.S.H. said.

Post Reply

Return to “X4: Foundations - Scripts and Modding”