• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Modding with wildcard xpath csv statements?

seven

Active member
So if you have a zombie expansion mod and wish to remove a specific zombie from the spawn groups, I can write a remove for each group. But if there are many, many groups, will this work?

<csv xpath="/entitygroups/entitygroup/text()" delim="\n" op="remove" >
CustomZombie1
</csv

Further, say there are two zombies you wish to remove, will this work?

<csv xpath="/entitygroups/entitygroup/text()" delim="\n" op="remove" >
CustomZombie1

CustomZombie2
</csv

I have tested both, and both seem to work. At least there are no errors thrown starting the game and the configs dump looks ok. But am I missing something? I haven't found a lot of information on csv edits in my googling.

 
You are correct, both will work.

The "remove" op also accepts wildcards, so the second example could just be this (assuming those are the only two custom zombies):
 

<csv xpath="/entitygroups/entitygroup/text()" delim="\n" op="remove" >CustomZombie*</csv>




The reason you can't find much information through Google, is because "csv" is not standard XPath. It's something TFP created to modify lists, especially comma-separated values (hence the name).

SphereII has a good explanation of it, here: 




 
Thank you for the reply. That thread is one of the few bits I found. It's good to know about the wildcard in the zombie name, kind of missed that, but those were poor example names, any they actually differ a lot.

Maybe wildcard wasn't the proper term. I wasn't sure if by not selecting specific groups with an @name= or starts with if it would select all groups (what I meant by 'wildcard') and then apply the remove only where appropriate. You're right, it's been working fine. Thank you for the confirmation.

 
I wasn't sure if by not selecting specific groups with an @name= or starts with if it would select all groups (what I meant by 'wildcard') and then apply the remove only where appropriate.


That is actually an XPath feature. Every XPath expression always selects a collection of XML nodes. It could contain one node, many nodes, or no nodes (but in this case 7D2D will issue a warning in the console).

A lot of times, people want that collection to only have one member, and that's why they include predicates like [@name="whatever"]. But you don't have to use a predicate, and if you're trying to remove a type of zombie from the game, what you did is exactly what I would do.

 
Yeah, I've used that feature often, but csv is unlike any other xpath statement I've used, and this is the first time doing anything with it. Seems powerful, TFP did a good job with it.

 
Back
Top