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

Easy new item

NAS4Killer

Refugee
Hello together,

I will start with a easy item. I have experience with programming old languages C++, Pascal, Sharp ans wo on. I Understand the xml files with change the values. That realy easy. But Now I will create a new item. I not know xpath. So I do not understand what is wrong.

I create a folder

Mods - Test_1

//Modinfo.xml

Config//

//Localization.txt

//items.xml

UIAtlases - ItemIconAtlas

//foodCornBread_V.png

Here the Code from items.xml:

<?xml version="1.0" encoding="UTF-8"?>

<append xpath="/items">

<item name="foodCornBread_V">
<property name="Tags" value="food"/>
<property name="HoldType" value="31"/>
<!-- <property name="DisplayType" value="food"/> -->
<property name="DisplayType" value="foodWaterNegative"/>
<property name="Meshfile" value="#Other/Items?Misc/parcelPrefab.prefab"/>
<property name="CustomIcon" value="foodCornBread_V"/>
<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
<property name="Material" value="Morganic"/>
<property name="Stacknumber" value="10"/> <!-- STK food -->
<property name="EconomicValue" value="16"/>
<property name="UnlockedBy" value="perkMasterChef,foodCornBreadSchematic"/>
<property class="Action0">
<property name="Class" value="Eat"/>
<property name="Delay" value="1.0"/>
<property name="Use_time" value="..."/>
<property name="Sound_start" value="player_eating"/>
<!-- jar from cooking food <property name="Create_item" value="drinkJarEmpty"/> -->
</property>
<property name="Group" value="Food/Cooking,CFFood/Cooking"/>

<effect_group tiered="false" name="Food Tier 1">
<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="$foodAmountAdd" operation="add" value="10"/>
<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="foodHealthAmount" operation="add" value="5"/>
<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyStats" stat="water" operation="add" value="-5"/>
<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar=".foodStaminaBonusAdd" operation="add" value="10"/>
<triggered_effect trigger="onSelfPrimaryActionEnd" action="AddBuff" buff="buffProcessConsumables"/>
<display_value name="$waterAmountAdd" value="-5"/>
</effect_group>
</item>

</append>




But I get a xpath error: I cannot find a solution in this forum or in the internet. Can you help?
660 ERR XML loader: Patching 'items.xml" from mod 'Test_1' failed:
661 EXC XML.Patch (/append/item, line 5 at pos 2): Patch element does not have an 'xpath' attribute


Thanks for your help or ideas.

best regeards Pascal

 
I’m not super sure but you might want to remove (maybe) the top xml line (with the XML version declaration) and then put an xml tag at the top and a closed version of that same tag bottom of the file (you can name it whatever you want). Basically wrapping your entire items.xml in another layer of tag. If adding the tags at the top and bottom

work, then see if you can put back the XML declaration. I know it’s likely “correct” to have that declaration, but not sure for mods in this game

Like:
 

top of file:

<sometag>
 

bottom of file:

</sometag>
 

Usually people put their forum name in these tags or use <config> and </config>

 
example (from what doughphunghus mentioned)

<config>

    <insertAfter xpath="/items/item[@name='meleeWpnSpearT1IronSpear']/property[@name='Extends']">
        <property name="Tags" value="T1Spear,T1Crafting,melee,grunting,medium,weapon,meleeWeapon,longShaft,attPerception,perkJavelinMaster,canHaveCosmetic,thrownWeapon"/>
    </insertAfter>    



</config>




I use config because I thought we had to.  Once I found out you can add whatever you want, I became lazy at that point and just continue to use config  😉

 
Hi doughphunghus  and BFT2020,

thanks for you help. It is so easy 😄 Now is work. Only change the
XML test versus <config> and add </config> the work it directly incl. the icon.

Thanks.

 
Back
Top