Replace Function Not Working For Material Library

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

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

DMATH
Posts: 2
Joined: Sat, 1. Dec 18, 00:07
x4

Replace Function Not Working For Material Library

Post by DMATH »

So i recently got into modding X4 and i tried replacing a texture for a test mod, i used the syntax 'replace sel=' but i get the error {'The key name "replace" is not recognised in lookup 'MaterialLibXML'}. The current example that used the replace was from a X-rebirth guide (viewtopic.php?t=347831) and it went a little something like this:


{ <replace sel="/materiallibrary/collection[@name='ads']/material[@name='ads_plasmacells']/properties/property[@name='diffuse_map']">
<property type="BitMap" name="diffuse_map" value="extensions\osr_universe\assets\fx\textures\ads\ads_osr_01"></property>
</replace>}

And what i wrote in x4 was this:


<replace sel="ads_p1_billboardtrims_02" shader="P1_complex_unlit.fx" blendmode="ADDITIVE" preview="none">
<properties>
<property type="BitMap" name="diffuse_map" value="assets\textures\ad_signs\ads_billboard_02_diff" />
<property type="Color" name="color_emissive" r="255" g="255" b="255" a="255" value="(color 255 255 255)" />
<property type="Float" name="diffuseStr" value="1" />
<property type="Integer" name="dblend1" value="1" />
<property type="BitMap" name="diffuse2_map" value="assets\textures\fx\gradient_wave_01_diff" />
<property type="Float" name="diffuse2Str" value="1.0" />
<property type="Integer" name="dblend2" value="3" />
<property type="BitMap" name="diffuse3_map" value="assets\textures\fx\gradient_wave_01_diff" />
<property type="Float" name="diffuse3Str" value="1.0" />
<property type="Float" name="alpha1Str" value="1.0" />
<property type="Float" name="alpha2Str" value="1.0" />
<property type="Float" name="alpha3Str" value="1.0" />
<property type="Float" name="angle_fade_speed" value="1.0" />
<property type="Float" name="angle_fade_offset" value="0.0" />
<property type="Float" name="camera_fade_range_near_start" value="1.0" />
<property type="Float" name="camera_fade_range_near_end" value="10.0" />
<property type="Float" name="camera_fade_range_far_start" value="10000.0" />
<property type="Float" name="camera_fade_range_far_end" value="20000.0" />
<property type="Float" name="softparticle_range_min" value="0.0" />
<property type="Float" name="softparticle_range_max" value="3.0" />
<property type="Float" name="base_hue_shift" value="0.0" />
<property type="Float" name="base_brightness_shift" value="5.0" />
</properties>
</replace>

Has "replace" been depreciated or have i got the syntax wrong?
SirNukes
Posts: 549
Joined: Sat, 31. Mar 07, 23:44
x4

Re: Replace Function Not Working For Material Library

Post by SirNukes »

The "sel" field uses a limited version of xpath syntax. You need to put your replacement into that form, similar to how the quoted example does it. For general diff patch documentation, I have been using https://tools.ietf.org/html/rfc5261.
DMATH
Posts: 2
Joined: Sat, 1. Dec 18, 00:07
x4

Re: Replace Function Not Working For Material Library

Post by DMATH »

Thank you SirNukes, sorry for the delay. I read the API and now i understand, what i should've written was:

<?xml version="1.0" encoding="utf-8"?>
<diff>
<replace sel="/materiallibrary/collection[@name='p1ads']/material[@name='ads_p1_billboardtrims_02']/properties/property[@name='diffuse_map']">
<property type="BitMap" name="diffuse_map" value="extensions\testmod\assets\textures\ad_signs\ads_billboard_02_diff"></property>
</replace>
</diff>

I have never had experience with diff patching before and the thing that i couldn't understand was collections. That API guide was a godsend and i learned a little bit more about xml.

Return to “X4: Foundations - Scripts and Modding”