Announcement

Collapse
No announcement yet.

[Guide] [SDX] How to write your own configuration file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Guide] [SDX] How to write your own configuration file

    General

    This tutorial explains the possibilities of SDX to modify the 7DTD XML files.

    Basic setup

    A SDX Mod contains, depending on your needs, the following file structure:

    Code:
    YourModName
    |
    +-Configs
    | |
    | +-config.xml
    |
    +-Icons
    | |
    | +-icons.png
    |
    +-Resources
    | |
    | +-Models.unity3d
    |
    +-Scripts
    | |
    | +-scripts.cs
    |
    +-Text
    | |
    | +-English.txt
    |
    +-mod.xml
    For changing the game XML files, the mod.xml and the config.xml in the Configs folder are relevant to us.

    Let's start with mod.xml. This file should look like this:
    Code:
    <mod>
    	<info>
    		<author>your name</author>
    		<name>Name of your Mod</name>
    		<description>Short decription of your Mod</description>
    		<mod_version>1.0</mod_version>
    		<game_version>14.5</game_version>
    		<launcher_version>0.6.0</launcher_version>
    	</info>
    	
    	
    	<config_mods>
    		<import file="Configs\config.xml" />
    	</config_mods>
    </mod>
    What to change in this file
    At the very bottom of this XML you can import as many configuration files, as you need.
    This allows you to have all instructions in one file or split into many.

    Let me show you some other examples, on how to organize your files:
    • This structure is useful, if you want to keep track of the files you change:
      <import file="Configs\blocks.xml" />
      <import file="Configs\items.xml" />
      <import file="Configs\recipes.xml" />
    • Or if you prefer a themed organization:
      <import file="Configs\food.xml" />
      <import file="Configs\machines.xml" />
      <import file="Configs\weapons.xml" />

    How you organize is up to you. But especially in larger Mods I recommend you to use multiple config files.

    Config Files

    So now that you have a structure that fits your needs. We have to actually write some code.
    Each config file starts with a <configs> node.

    Within that node you can have one or more <config> nodes that point to the XML file that you want to change.

    Example:
    <config name="recipes">
    As you can see, no file extension is required. The above example would configure the recipes.xml file.

    In that <config> node we have several commands that would allow us to change XML files. But before I list them, let me tell you about xpath first.

    xpath

    You need to understand xpath, if you want to use any of the following commands.
    As you know, each XML is a representation of a tree structure. So to get to any information in that tree, we must have to follow a specific path.
    The most basic path is

    xpath="/"

    It points to the file itself. But most likely the files we want to change already have nodes and we want to change something within those.

    Now let's grab our blocks.xml. The root node here is <blocks>...</blocks>. If we want to refer to this in xpath, we can do it like this:

    xpath="/blocks"

    So far it was easy. But if we remember, in that <blocks> node, we had several <block> nodes. If we do a xpath="/blocks/block" it would only look for the first possible path. In our case it would always be the air block.
    If we want to change a different <block>, we need to narrow the block down.

    How to search for a specific node?
    We know that all our <block> nodes have an "id" and a "name". We can use that to search for our desired block, by adding a search parameter.
    Search parameters are in square brackets and have a "@" in front of the search parameter.
    So in our case it should look like that:

    xpath="/blocks/block[@id='1']"
    or
    xpath="/blocks/block[@name='stone']"

    Both variants are possible, but I recommend you to go with name. If you revisit your instructions later, you might not know anymore what ID 15 is, but you know what block 'asphalt' is.

    Also note that I use double quotes to wrap things in our xpath and single quotes to wrap my search value.

    Now let's continue with the options, to change your XMLs:

    1. append

    This command allows you to add information within an existing node. The information will always be added at the end (before the node closes).

    Example:
    Code:
    <append xpath="/blocks">
    	<block id="" name="modBlock">
    		<property name="Extends" value="WoodMaster" />
    		...
    	</block>
    </append>
    This would add a block modBlock after the last block node. If you don't have any other mods and apply this to vanilla A14.5, this would be after:
    <block id="1913" name="sandbag_5DMG1">
    ..
    </block>

    If the ID is empty like in our case, SDX assigns an ID automatically. SDX therefore looks for the highest ID used and counts from there upwards. Hence it will not fill any ID gaps that might exist. For A14.5 this means, SDX would start with block ID 1914, as ID 1913 was the highest ID used in vanilla.
    Keep this in mind, if you play a SDX modded world and want to add a Mod. The order of the Mods will be important or it will mess with your existing IDs!!!

    2. insertAfter

    This command allows you to add code after a specific node.
    Example: There is an ID gap between 1825 ('metalSignLetter_z') and 1901 ('conduit01Corner'). If we want to add a block with id 1826 and have it in the right position in the file, we can use the insertAfter command:
    Code:
    <insertAfter xpath="/blocks/block[@id='1825']">
    	<block id="1826" name="modBlock">
    		<property name="Extends" value="WoodMaster" />
    		...
    	</block>
    </insertAfter>
    3. insertBefore

    similar to insertAfter, but it adds code before a specific node.
    Example:
    Code:
    <insertBefore xpath="/blocks/block[@id='1901']">
    	<block id="1900" name="modBlock">
    		<property name="Extends" value="WoodMaster" />
    		...
    	</block>
    </insertAfter>
    4. remove

    And finally this command allows you to remove nodes.
    Example:
    Code:
    <remove xpath="/blocks/block[@name='forge']" />
    This would completely remove the forge block from the game.

    Example Config File
    Code:
    <configs>
    	<config name="recipes">
    		<remove xpath="/recipes/recipe[@name='forge']/ingredient[@name='bellows']" />
    		<append xpath="/recipes/recipe[@name='forge']">
    				<ingredient name="modBellows" count="1" />
    		</append>
    	</config>
    	<config name="items">
    		<remove xpath="/items/item[@name='bellows']" />
    		<insertAfter xpath="/items/item[@name='beaker']">
    			<item id="1444" name="modBellows">
    				<property name="Meshfile" value="Items/Misc/sackPrefab" />
    				<property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
    				<property name="Material" value="leather" />
    				<property name="HoldType" value="45" />
    				<property name="Stacknumber" value="1" />
    				<!-- STK resource -->
    				<property name="Weight" value="10" />
    				<property name="Group" value="Resources" />
    				<property name="CraftingSkillGroup" value="Tool Smithing" />
    			</item>
    		</insertAfter>
    	</config>
    </configs>
    The above code is just for demonstrational purpose.
    What it does is, it removes the bellows ingredient from the forge recipe and adds a new modBellows to the forge recipe.
    In the items.xml the bellows item gets removed and at the same place (after the beaker item) our modded item gets inserted.

    Final Words

    I hope this will help you write your own configuration files / rewriting XML only Mods into SDX compliant Mods.
    If I missed a command that SDX supports, please let me know and I'll add a section to it.
    Last edited by elitelex; 04-24-2016, 04:03 PM.

    #2
    Seems I need to spread my rep point! But thank again for a nice and useful guide!

    Comment


      #3
      I cant get my recipes to show up. Any reason u can see that I did wrong?

      <configs>
      <config name="blocks">
      <append xpath="/blocks">
      <!-- ShortWaveRadio -->
      <block id="" name="ShortWaveRadio">
      <property name="Material" value="metal" />
      <property name="CustomIcon" value="controlPanelBase04" />
      <property name="Shape" value="Ext3dModel" />
      <property name="Model" value="Industrial/control_panel_base_04" param1="main_mesh" />
      <property name="Mesh" value="models" />
      <property name="Class" value="Campfire" />
      <property class="Workstation,Building,Basics">
      <property name="Modules" value="output,input"/>
      </property>
      <drop event="Destroy" name="woodDebris" count="1" />
      <drop event="Fall" name="woodDebris" count="1" prob="1.0" stick_chance=".75" />
      </block>
      </append>
      </config>
      <config name="items">
      <append xpath="/items">
      <item id="" name="BroadcastFrequency1">
      <property name="Meshfile" value="Items/Misc/sackPrefab" />
      <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
      <property name="HoldType" value="45" />
      <property name="Material" value="paper" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="250" /> <!-- STK resource -->
      <property name="FuelValue" value="1" />
      <property name="Weight" value="1" />
      <property name="Group" value="Decor/Miscellaneous" />
      </item>
      <item id="" name="BroadcastFrequency2">
      <property name="Meshfile" value="Items/Misc/sackPrefab" />
      <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
      <property name="HoldType" value="45" />
      <property name="Material" value="paper" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="250" /> <!-- STK resource -->
      <property name="FuelValue" value="1" />
      <property name="Weight" value="1" />
      <property name="Group" value="Decor/Miscellaneous" />
      </item>
      <item id="" name="BroadcastFrequency3">
      <property name="Meshfile" value="Items/Misc/sackPrefab" />
      <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
      <property name="HoldType" value="45" />
      <property name="Material" value="paper" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="250" /> <!-- STK resource -->
      <property name="FuelValue" value="1" />
      <property name="Weight" value="1" />
      <property name="Group" value="Decor/Miscellaneous" />
      </item>
      <item id="" name="BroadcastFrequency4">
      <property name="Meshfile" value="Items/Misc/sackPrefab" />
      <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
      <property name="HoldType" value="45" />
      <property name="Material" value="paper" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="250" /> <!-- STK resource -->
      <property name="FuelValue" value="1" />
      <property name="Weight" value="1" />
      <property name="Group" value="Decor/Miscellaneous" />
      </item>
      <item id="" name="SOS_RescueMission">
      <!-- <property name="DescriptionKey" value="qt_desc"/> -->
      <property name="IsDeveloper" value="False" />
      <property name="Meshfile" value="Items/Misc/Book" />
      <property name="Material" value="paper" />
      <property name="HoldType" value="21" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="50" /> <!-- STK book -->
      <property class="Action1">
      <property name="Skills_to_gain" value="Miscellaneous Crafting" />
      <property name="Class" value="Quest" />
      <property name="QuestGiven" value="quest_SOS_RescueMission" />
      <property name="Delay" value="0" />
      </property>
      <property name="FuelValue" value="2" />
      <property name="Weight" value="2" />
      <property name="Group" value="Special Items" />
      </item>
      <item id="" name="Investigate_The_Lab0">
      <!-- <property name="DescriptionKey" value="qt_desc"/> -->
      <property name="IsDeveloper" value="False" />
      <property name="Meshfile" value="Items/Misc/Book" />
      <property name="Material" value="paper" />
      <property name="HoldType" value="21" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="50" /> <!-- STK book -->
      <property class="Action1">
      <property name="Skills_to_gain" value="Miscellaneous Crafting" />
      <property name="Class" value="Quest" />
      <property name="QuestGiven" value="quest_Investigate_The_Lab0" />
      <property name="Delay" value="0" />
      </property>
      <property name="FuelValue" value="2" />
      <property name="Weight" value="2" />
      <property name="Group" value="Special Items" />
      </item>
      <item id="" name="SOS_BadBoys">
      <!-- <property name="DescriptionKey" value="qt_desc"/> -->
      <property name="IsDeveloper" value="False" />
      <property name="Meshfile" value="Items/Misc/Book" />
      <property name="Material" value="paper" />
      <property name="HoldType" value="21" />
      <property name="CustomIcon" value="questMaster" />
      <property name="Stacknumber" value="50" /> <!-- STK book -->
      <property class="Action1">
      <property name="Skills_to_gain" value="Miscellaneous Crafting" />
      <property name="Class" value="Quest" />
      <property name="QuestGiven" value="quest_SOS_BadBoys" />
      <property name="Delay" value="0" />
      </property>
      <property name="FuelValue" value="2" />
      <property name="Weight" value="2" />
      <property name="Group" value="Special Items" />
      </item>
      <item id="" name="dBattery">
      <property name="CustomIcon" value="dBattery" />
      <property name="Meshfile" value="Items/Misc/car_battery" />
      <property name="Material" value="lead" />
      <property name="HoldType" value="21" />
      <property name="Stacknumber" value="50" />
      <property name="Weight" value="160" />
      <property name="Group" value="Resources" />
      </item>
      </append>
      </config>

      <config name="xui">
      <append xpath="/xui/ruleset">
      <window_group name="workstation_ShortWaveRadio" controller="XUiC_WorkstationWindowGroup">
      <window name="windowCraftingList"/>
      <window name="craftingInfoPanel"/>
      <window name="windowCraftingQueue"/>
      <window name="windowOutput" />
      <window name="windowNonPagingHeader" />
      </window_group>
      </append>
      </config>
      <config name="recipes">
      <append xpath="/recipes">
      <!--ShortWaveRadio -->
      <recipe name="SOS_NukePlant" count="1" scrapable="False" craft_area="ShortWaveRadio" >
      <ingredient name="BroadcastFrequency4" count="1" />
      </recipe>
      <recipe name="SOS_BadBoys" count="1" scrapable="False" craft_area="ShortWaveRadio" >
      <ingredient name="BroadcastFrequency3" count="1" />
      </recipe>
      <recipe name="SOS_RescueMission" count="1" scrapable="False" craft_area="ShortWaveRadio" >
      <ingredient name="BroadcastFrequency1" count="1" />
      </recipe>
      <recipe name="Investigate_The_Lab0" count="1" scrapable="False" craft_area="ShortWaveRadio" >
      <ingredient name="BroadcastFrequency2" count="1" />
      </recipe>
      <recipe name="ShortWaveRadio" count="1" scrapable="False">
      <ingredient name="forgedIron" count="10"/>
      </recipe>
      </append>
      </config>

      </configs>

      Comment


        #4
        Originally posted by Sorrowthief View Post
        I cant get my recipes to show up. Any reason u can see that I did wrong?

        <configs>
        <config name="blocks">
        <append xpath="/blocks">
        <!-- ShortWaveRadio -->
        <block id="" name="ShortWaveRadio">
        <property name="Material" value="metal" />
        <property name="CustomIcon" value="controlPanelBase04" />
        <property name="Shape" value="Ext3dModel" />
        <property name="Model" value="Industrial/control_panel_base_04" param1="main_mesh" />
        <property name="Mesh" value="models" />
        <property name="Class" value="Campfire" />
        <property class="Workstation,Building,Basics">
        <property name="Modules" value="output,input"/>
        </property>
        <drop event="Destroy" name="woodDebris" count="1" />
        <drop event="Fall" name="woodDebris" count="1" prob="1.0" stick_chance=".75" />
        </block>
        </append>
        </config>
        <config name="items">
        <append xpath="/items">
        <item id="" name="BroadcastFrequency1">
        <property name="Meshfile" value="Items/Misc/sackPrefab" />
        <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
        <property name="HoldType" value="45" />
        <property name="Material" value="paper" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="250" /> <!-- STK resource -->
        <property name="FuelValue" value="1" />
        <property name="Weight" value="1" />
        <property name="Group" value="Decor/Miscellaneous" />
        </item>
        <item id="" name="BroadcastFrequency2">
        <property name="Meshfile" value="Items/Misc/sackPrefab" />
        <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
        <property name="HoldType" value="45" />
        <property name="Material" value="paper" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="250" /> <!-- STK resource -->
        <property name="FuelValue" value="1" />
        <property name="Weight" value="1" />
        <property name="Group" value="Decor/Miscellaneous" />
        </item>
        <item id="" name="BroadcastFrequency3">
        <property name="Meshfile" value="Items/Misc/sackPrefab" />
        <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
        <property name="HoldType" value="45" />
        <property name="Material" value="paper" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="250" /> <!-- STK resource -->
        <property name="FuelValue" value="1" />
        <property name="Weight" value="1" />
        <property name="Group" value="Decor/Miscellaneous" />
        </item>
        <item id="" name="BroadcastFrequency4">
        <property name="Meshfile" value="Items/Misc/sackPrefab" />
        <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab" />
        <property name="HoldType" value="45" />
        <property name="Material" value="paper" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="250" /> <!-- STK resource -->
        <property name="FuelValue" value="1" />
        <property name="Weight" value="1" />
        <property name="Group" value="Decor/Miscellaneous" />
        </item>
        <item id="" name="SOS_RescueMission">
        <!-- <property name="DescriptionKey" value="qt_desc"/> -->
        <property name="IsDeveloper" value="False" />
        <property name="Meshfile" value="Items/Misc/Book" />
        <property name="Material" value="paper" />
        <property name="HoldType" value="21" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="50" /> <!-- STK book -->
        <property class="Action1">
        <property name="Skills_to_gain" value="Miscellaneous Crafting" />
        <property name="Class" value="Quest" />
        <property name="QuestGiven" value="quest_SOS_RescueMission" />
        <property name="Delay" value="0" />
        </property>
        <property name="FuelValue" value="2" />
        <property name="Weight" value="2" />
        <property name="Group" value="Special Items" />
        </item>
        <item id="" name="Investigate_The_Lab0">
        <!-- <property name="DescriptionKey" value="qt_desc"/> -->
        <property name="IsDeveloper" value="False" />
        <property name="Meshfile" value="Items/Misc/Book" />
        <property name="Material" value="paper" />
        <property name="HoldType" value="21" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="50" /> <!-- STK book -->
        <property class="Action1">
        <property name="Skills_to_gain" value="Miscellaneous Crafting" />
        <property name="Class" value="Quest" />
        <property name="QuestGiven" value="quest_Investigate_The_Lab0" />
        <property name="Delay" value="0" />
        </property>
        <property name="FuelValue" value="2" />
        <property name="Weight" value="2" />
        <property name="Group" value="Special Items" />
        </item>
        <item id="" name="SOS_BadBoys">
        <!-- <property name="DescriptionKey" value="qt_desc"/> -->
        <property name="IsDeveloper" value="False" />
        <property name="Meshfile" value="Items/Misc/Book" />
        <property name="Material" value="paper" />
        <property name="HoldType" value="21" />
        <property name="CustomIcon" value="questMaster" />
        <property name="Stacknumber" value="50" /> <!-- STK book -->
        <property class="Action1">
        <property name="Skills_to_gain" value="Miscellaneous Crafting" />
        <property name="Class" value="Quest" />
        <property name="QuestGiven" value="quest_SOS_BadBoys" />
        <property name="Delay" value="0" />
        </property>
        <property name="FuelValue" value="2" />
        <property name="Weight" value="2" />
        <property name="Group" value="Special Items" />
        </item>
        <item id="" name="dBattery">
        <property name="CustomIcon" value="dBattery" />
        <property name="Meshfile" value="Items/Misc/car_battery" />
        <property name="Material" value="lead" />
        <property name="HoldType" value="21" />
        <property name="Stacknumber" value="50" />
        <property name="Weight" value="160" />
        <property name="Group" value="Resources" />
        </item>
        </append>
        </config>

        <config name="xui">
        <append xpath="/xui/ruleset">
        <window_group name="workstation_ShortWaveRadio" controller="XUiC_WorkstationWindowGroup">
        <window name="windowCraftingList"/>
        <window name="craftingInfoPanel"/>
        <window name="windowCraftingQueue"/>
        <window name="windowOutput" />
        <window name="windowNonPagingHeader" />
        </window_group>
        </append>
        </config>
        <config name="recipes">
        <append xpath="/recipes">
        <!--ShortWaveRadio -->
        <recipe name="SOS_NukePlant" count="1" scrapable="False" craft_area="ShortWaveRadio" >
        <ingredient name="BroadcastFrequency4" count="1" />
        </recipe>
        <recipe name="SOS_BadBoys" count="1" scrapable="False" craft_area="ShortWaveRadio" >
        <ingredient name="BroadcastFrequency3" count="1" />
        </recipe>
        <recipe name="SOS_RescueMission" count="1" scrapable="False" craft_area="ShortWaveRadio" >
        <ingredient name="BroadcastFrequency1" count="1" />
        </recipe>
        <recipe name="Investigate_The_Lab0" count="1" scrapable="False" craft_area="ShortWaveRadio" >
        <ingredient name="BroadcastFrequency2" count="1" />
        </recipe>
        <recipe name="ShortWaveRadio" count="1" scrapable="False">
        <ingredient name="forgedIron" count="10"/>
        </recipe>
        </append>
        </config>

        </configs>
        Is there any red lines in the sdx after you have pressed built.

        try revert, then build wait for it to finish then scroll up depending on where it was built from by the sdx if last it should show up down the bottom if middle you will have to scroll up higher.

        Then if no red lines in sdx tool. play game then go to output.log and search error. here it should tell you if not in the sdx tool. if no errors then search null.

        Comment


          #5
          Well your code is fine... the problem is another one.
          The first recipe is for "SOS_NukePlant". Which is neither an item nor a block. When 7DTD loads the recipe list, it runs into an error here and stops loading any recipe after that faulty one.

          Comment


            #6
            ahh doh didnt see that. Thanks
            Does that mean that I also have to add the quest to as some of the items give a quest. The game wont recognize it the same way till I do my quest.xml?
            Last edited by Sorrowthief; 04-25-2016, 12:32 AM.

            Comment


              #7
              yes, items must be of the Quest class and the quest itself must be declared in the quests.xml

              Comment

              Working...
              X