Does [defName=*] work, or how do wildcards work exactly?

Started by Moogie, March 31, 2020, 06:37:39 PM

Previous topic - Next topic

Moogie

Here's a thing I wanted to do:

<li Class="PatchOperationAdd">
<xpath>/Defs/TraderKindDef[defName=*]/stockGenerators</xpath>
<value>
<li Class="StockGenerator_BuyTradeTag">
<tag>FoodMeals</tag>
</li>
</value>
</li>


The game seems to accept it just fine, but I'm not sure if it's actually working or not. I haven't had many traders visit to test it with. I'm also worried that it may be a laggy operation, and if there isn't some better way to do it.

I'm using a wildcard because I want it to affect all traders, even modded ones. This is just for personal use, so I don't mind if it makes sense or not. :)

The only information I can find about using wildcards only talks about the tree structure, and not how to use them for actual defnames. So this was a complete punt on my part. Should I may have the * between quotation marks, or is it fine like that?

Thanks for any help. :)

LWM

Why not just "/Defs/TraderKindDef/stockGenerators"?

Just sayin'.

There's a lot of really good xpath information out there - it's a widely used standard, so to most questions, you can find answers from people who really know this stuff (vs us, most of whom "merely" use it)

That said, feel free to ask questions  ;D  I think wildcards work just fine.  I think you're specifying every TraderKindDef that has a defName - which might miss some abstract ones (that might not have a defName), so perhaps it could fail in very weird cases.

Moogie

Oh believe me, I've done a lot of Googling about xpaths before even considering posting threads about it. But when you're new to the syntax, looking up examples from wildly different contexts (such as websites or databases) just gets exponentially more confusing. Most guides of that nature also seem to be geared much more towards the experienced coder and not the lay idiot attempting to make game mods. :P

I wasn't aware that I could do /TraderKindDef/stockGenerators and it would not get confused that I didn't specify exactly where to go. I'm slowly understanding more about how it acts as a filter rather than a rigid pathing system. You saying that has definitely pushed my learning another step forwards. :)

Thanks!

LWM

Oh good :)

It sounds like asking questions here is a very sensible thing to do!