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

xpath changing values by a set percentage..how?

pipermac

Refugee
Is it possible to change a property value by a certain percentage?

Eg.  Food items have a CraftingIngredientTime, If I want to Increase or decrease all of those times by x%  how can I do this?

Thanks

 
Erm? Just calculate it?

If CraftingIngredientTime is 13 and you want to make it faster with 10% just lower it to 11.7 (or 12, if not rounded)?

 
Erm? Just calculate it?

If CraftingIngredientTime is 13 and you want to make it faster with 10% just lower it to 11.7 (or 12, if not rounded)?
Trying to change it for all food items without having to do it for each one individually. Since they have different values your suggestion won't work.

 
Not actually trying to do a %, that was just an example what I specifically need to do  multiply the current value by 100.  So essentially  set value=value*100

 
The modifier perc_add adds a certain percentage to a value if I remember correctly. If you search the vanilla xml you will see it used often.

Generally any value that is set in xml can be modified by XPath, but there is very limited ability to change multiple things at a time.

Using your example- all food items are defined individually so xml mods would have to define the changes individually. 

Some things like trees or other things "extend" from a master item so you can modify the master, with the children inheriting the changes. That is used infrequently in vanilla xml though. We modders tend to use it a lot though.

TLDR: yes, but not easily if your plan is for a lot of items

 
As I recall, this is how some of the MasterChef perks work. One of them reduces meat usage by 20% (meaning 4 pieces instead of 5 for most recipes), another shortens the cooking time. Here's an excerpt from the code for the latter, from the progression.xml

<passive_effect name="CraftingTime" operation="perc_add" level="1,5" value="-.1,-.5" tags="perkMasterChef"/>

For each rank of Master Chef, you get 10% off the cooking time, starting at 10% off and going as high as 50% off.

That could act as a sort of guide for you. If you wanted to increase the crafting time, you could make those numbers positive instead of negative. The only problem is that in this case, it only affects things tagged with "perkMasterChef". 

xpath modding isn't as daunting as it seems, and I'd recommend just jumping in and taking a stab at it. Mod something small first and you'll be used to it before you know it.

 
Back
Top