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

XML help please

bloodlust67

New member
I'm wanting to remove the entire Biomes section of biomes.xml

Inside of biomes.xml, I typed:

<remove xpath="/biomes/biomes"/>

then

<append xpath="/biomes">

    <biomes>
        <biomemap id="01" name="snow"/>
etc, etc, etc

I am making a lot of changes to biomes, like restricting potassium only to snow; coal only burnt forest; cites, towns, vehicles only to wasteland. I don't want to add a million append or set commands. Just remove all of biomes.xml/biomes and append the entire biomes section with all of my changes.

Thanks in advance!

 
It's worldgeneration/biomes/biome, not biomes/biomes

 
Last edited by a moderator:
If you want, you can also use "//" in the XPath, which means "a child of any depth from the current node." If there is nothing before it, the "current node" is the root node. So e.g. "//biome" would target "worldgeneration/biomes/biome" or "biomes/biome" (if there were such a thing).

But, from experience, I can tell you that it is not a good idea to wipe out an entire section of XML and replace it. It's always better to target only the specific changes you want to make, even if your mod's XML ends up being dozens of lines longer.

There are basically two reasons:

  1. Forward compatibility. If TFP make a change in the vanilla XML, then your changes will probably still be valid if you only target what you want to change. If you replace the whole thing, you won't get TFP's updates to it, and your changes might not even be compatible any more. (This happened to me with quests, when they added the section to go back and forth between quest tiers.)
  2. Compatibility with other mods. Wiping out entire sections of XML will also mean you wipe out whatever changes other mods have made to that section of the XML. If everyone only targets what they want to change, then the likelihood of a mod being compatible with your changes increases dramatically.

HTH.

 
If you want, you can also use "//" in the XPath, which means "a child of any depth from the current node." If there is nothing before it, the "current node" is the root node. So e.g. "//biome" would target "worldgeneration/biomes/biome" or "biomes/biome" (if there were such a thing).

But, from experience, I can tell you that it is not a good idea to wipe out an entire section of XML and replace it. It's always better to target only the specific changes you want to make, even if your mod's XML ends up being dozens of lines longer.

There are basically two reasons:

  1. Forward compatibility. If TFP make a change in the vanilla XML, then your changes will probably still be valid if you only target what you want to change. If you replace the whole thing, you won't get TFP's updates to it, and your changes might not even be compatible any more. (This happened to me with quests, when they added the section to go back and forth between quest tiers.)
  2. Compatibility with other mods. Wiping out entire sections of XML will also mean you wipe out whatever changes other mods have made to that section of the XML. If everyone only targets what they want to change, then the likelihood of a mod being compatible with your changes increases dramatically.

HTH.


thanks guys!

I have another question:

I want to remove coal and potassium from the Pine Forest biome. I know I could set their /prob to 0 to remove them, but I want to replace them with lead and iron. How do I change the name of them? I tried the following but it wouldn't apply during world generation.

    <set xpath="/worldgeneration/biomes/biome[@name='pine_forest']/subbiome[@prob='0.392']/layers/layer[@name='*']/resource[@blockname='terrOreCoal']">terrOreIron</set>
    <set xpath="/worldgeneration/biomes/biome[@name='pine_forest']/subbiome[@prob='0.392']/decorations/decoration[@blockname='deco_coal_vein']">deco_iron_vein</set>
    <set xpath="/worldgeneration/biomes/biome[@name='pine_forest']/subbiome[@prob='0.412']/layers/layer[@name='*']/resource[@blockname='terrOrePotassiumNitrate']">terrOreLead</set>
    <set xpath="/worldgeneration/biomes/biome[@name='pine_forest']/subbiome[@prob='0.412']/decorations/decoration[@blockname='deco_nitrate_vein']">deco_lead_vein</set>

any tips would be much appreciated! :)

 
You have two problems with your XML.

First, you are targeting a layer with a "name" attribute, but no layers have a "name" attribute. I think you are probably trying to target the "depth" attribute.

Second, to replace a value of an attribute, you need to tell XPath that it is a value of an attribute. That is done using the "@" character.

So for your first "set" tag, it should be this:

<set xpath="/worldgeneration/biomes/biome[@name='pine_forest']/subbiome[@prob='0.392']/layers/layer[@depth='*']/resource[@blockname='terrOreCoal']/@blockname">terrOreIron</set>




Also - this is just FYI - you can eliminate a lot of the path using "//", which just means "any child of the current XML node," and if those are the first characters in the XPath string, then they refer to the root node of the XML file.

Meaning, you could do this:

Code:
<set xpath="//biome[@name='pine_forest']/subbiome[@prob='0.392']//layer[@depth='*']/resource[@blockname='terrOreCoal']/@blockname">terrOreIron</set>
 
Last edited by a moderator:
Back
Top