Jump to content

XPath Modding Explanation Thread


sphereii

Recommended Posts

Can the set command replace an enitre node?

 

for example, if I were to change

 

<biome name="city">
<spawn maxcount="3" respawndelay="1" time="Day" entitygroup="ZombiesAll" />
<spawn maxcount="5" respawndelay="1" time="Night" entitygroup="ZombiesNight" />
<spawn maxcount="1" respawndelay="1" time="Any" entitygroup="ZombieDogGroup" />
</biome>

 

to

 

 	
<biome name="city">
<spawn maxcount="10" respawndelay="0.25" time="Day" entitygroup="ZombiesAll" />
<spawn maxcount="6" respawndelay="0.5" time="Night" entitygroup="ZombiesNight" />
<spawn maxcount="1" respawndelay="0.5" time="Any" entitygroup="ZombieDogGroup" />
</biome>

 

could I do that in a single set command, and what would be the syntax if so?

Link to comment
Share on other sites

Can the set command replace an enitre node?

 

for example, if I were to change

 

<biome name="city">
<spawn maxcount="3" respawndelay="1" time="Day" entitygroup="ZombiesAll" />
<spawn maxcount="5" respawndelay="1" time="Night" entitygroup="ZombiesNight" />
<spawn maxcount="1" respawndelay="1" time="Any" entitygroup="ZombieDogGroup" />
</biome>

 

to

 

 	
<biome name="city">
<spawn maxcount="10" respawndelay="0.25" time="Day" entitygroup="ZombiesAll" />
<spawn maxcount="6" respawndelay="0.5" time="Night" entitygroup="ZombiesNight" />
<spawn maxcount="1" respawndelay="0.5" time="Any" entitygroup="ZombieDogGroup" />
</biome>

 

could I do that in a single set command, and what would be the syntax if so?

 

No, this would be multiple sets for each attribute you wanted to change. Alternatively, you could just remove the biome[@name=city] and append a new one.

Link to comment
Share on other sites

for a shareable modlet, yes. You won't know what changes were done previously.

 

If you were just doing an Overhaul, it'd be fine.

 

Just to be clear, when I said overwrite the XML, I meant using <remove> and then <append>

Link to comment
Share on other sites

I just tried using the method with spawning.XML and I got the notification that it failed parsing the XML because "multiple document element was detected". I could successfully start a world, but zombies wouldn't spawn. I used Guppy's technique of exporting the resultant XML, and that looked okay. I presume I have some syntax error or my filenames aren't correct. Can you give advice on what's wrong with this this modlet?[ATTACH]27012[/ATTACH]

DimpySpawn.zip

Link to comment
Share on other sites

<append xpath="">

- it also may allow us to append a value to an existing value. ( this needs testing )

example:

This line could potentially add noammo to the existing value of 9mmbullet.

<append xpath="/items/item/property[@class='action0']/property[@name='magazine_items' and @value='9mmbullet']/@value">,noammo</append>

 

Forgive me for not reading the whole thread, but I just tested this and I can report it does appear to work. My mod added this code...

	<append xpath="/items/item[starts-with(@name,'hazmat')]/effect_group[@tiered='false']/passive_effect[@name='ElementalDamageResist']/@tags">,heat</append>

 

...and, using exportcurrentconfigs, I got this result...

<item name="hazmatBoots">
<property name="Extends" value="hazmatClothingMaster" param1="CustomIcon" />
<property name="Tags" value="lowerbody,feet,clothing" />
<property name="EquipSlot" value="Feet" />
<property class="UMA">
	<property name="Mesh" value="armor_hazmat_feet" />
	<property name="Overlay0" value="armor_hazmat_boots" />
	<property name="Layer" value="0" />
	<property name="UISlot" value="Footwear" />
</property>
<effect_group tiered="false">
	<passive_effect name="ModSlots" operation="base_set" value="1" />
	<passive_effect name="HypothermalResist" operation="base_add" value="6"><!--Attribute "value" replaced by: "ComSenMod"--></passive_effect>
	<passive_effect name="HyperthermalResist" operation="base_add" value="1" />
[color="#FF8C00"]		<passive_effect name="ElementalDamageResist" operation="base_add" value="5" tags="lowerbody,feet,radiation,toxic,[b]heat[/b]" match_all_tags="true"><!--Attribute "tags" appended by: "ComSenMod"--></passive_effect>
[/color]	</effect_group>
</item>

 

Now it doesn't have the desired effect, mind you - I'm still figuring that out. But at least I can confirm that append can modify the script in this way. :)

Link to comment
Share on other sites

Tried to add a new Item to GameStart. can anyone explain my mistake ?

<set xpath="/entity_classes/entity_class[@name='playerMale']/proberty[@name='ItemsOnEnterGame.GameModeSurvival']/@value">keystoneBlock,qc_welcomeMod</set>

 

It's /property, not /proberty :)

Link to comment
Share on other sites

That didn't work. The error message did change though. Now it says "object reference not set to an instance of object"

 

I'm not familiar with the syntax required to remove all of a file. You could try something like

 

<remove xpath="/spawning/*" />
...

Link to comment
Share on other sites

	<remove xpath="/spawning"/>

does not delete the whole file (fine by me); Just the part that is contained in

<spawning></spawning>

I looked at the resultant XML from exportcurrentconfigs and on one iteration of the Append syntax, everything except the header comment was gone, so I think the issue is with the append syntax. I changed the append syntax and the code reappeared, but it wasn't the code I told it to put back in; it was the original. I presume the game will reset the XML if it finds errors.

 

<append xpath="/spawning"/>

resets it and

<append xpath=""/>

has everything deleted.

 

Here is the file.

[ATTACH]27029[/ATTACH]

 

Who should I ask for help on this?

DimpySpawn.zip

Link to comment
Share on other sites

Thank you for the reply, but it seems the leading '/' is not mandatory, although I've now added it for completeness, it's made no difference.

 

Just had a deeper look and it seems to be fixed, I had to reference the Effect Group also...

 

<remove xpath="/items/item[@name=gunPistolAdmin]/effect_group[@name=Base Effects]/passive_effect[@name=EntityDamage]"/>

Edited by Karoti (see edit history)
Link to comment
Share on other sites

Thank you for the reply, but it seems the leading '/' is not mandatory, although I've now added it for completeness, it's made no difference.

 

Just had a deeper look and it seems to be fixed, I had to reference the Effect Group also...

 

<remove xpath="/items/item[@name=gunPistolAdmin]/effect_group[@name=Base Effects]/passive_effect[@name=EntityDamage]"/>

 

I am glad you got it working.

 

XPath can be tricky with its syntax. I'll always recommend fixing the inconsistencies I find first, as it may make some corner cases start working.

Link to comment
Share on other sites

I am glad you got it working.

 

XPath can be tricky with its syntax. I'll always recommend fixing the inconsistencies I find first, as it may make some corner cases start working.

 

Hey Sphereii, thanks for adding in detail to the xpath modding, this is really helpful work, thank you

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...