Jump to content

XPath Modding Explanation Thread


sphereii

Recommended Posts

<config>

<set xpath="/lootcontainers/lootcontainer[@id=25']/item[@name=resourceFeather]/@count">5,10</set>

</config>

 

gives me an error upon loading "XmlException: name cannot begin with the "]" character, hexadecimal value 0x5D. Line 2, position 53" which I believe is referring to the "]" after @id='25'"]?

 

Edit: Figured it out, it was the " after '25'. Thanks for the help!

 

Sorry for the typo.

Link to comment
Share on other sites

Hey guys,

 

I had a mod that added a skill book which was rewarded when completing quests. I tweaked it for A18 and it loads without any error, but the item is not listed in the creative menu and I can't figure out why.

 

Here's the mod code.

 

	<append xpath="/items">
	<item name="skillbook">
		<property name="CreativeMode" value="None"/>
		<property name="HoldType" value="21"/>
		<property name="Meshfile" value="Items/Misc/bookPrefab"/>
		<property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab"/>
		<property name="Material" value="Mpaper"/>
		<property name="EconomicValue" value="1600"/>
		<property name="SellableToTrader" value="false"/>
		<property class="Action0">
			<property name="Class" value="Quest"/>
			<property name="Delay" value="0"/>
			<property name="QuestGiven" value="quest_SkillPointReward"/>
		</property>
		<property name="FuelValue" value="2"/>
		<property name="Weight" value="2"/>
		<property name="Group" value="Special Items"/>
		<property name="CreativeMode" value="None"/>
		<property name="name_key" value="Skill Point Book" />
		<property name="desc_key" value="Awards 2 Skill Points for that quest you just completed. Good job!\n\n*Pats you on the head*" />
		<property name="CustomIcon" value="challengeQuestMaster"/>
		<property name="CustomIconTint" value="9f9fff"/>
		<property name="Stacknumber" value="200"/>
	</item>
</append>

 

EDIT: Fixed, I realised it was set to not show in creative mode.

Edited by Jegethy (see edit history)
Link to comment
Share on other sites

Hey guys,

 

I had a mod that added a skill book which was rewarded when completing quests. I tweaked it for A18 and it loads without any error, but the item is not listed in the creative menu and I can't figure out why.

 

Here's the mod code.

 

	<append xpath="/items">
	<item name="skillbook">
		<property name="CreativeMode" value="None"/>
		<property name="HoldType" value="21"/>
		<property name="Meshfile" value="Items/Misc/bookPrefab"/>
		<property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab"/>
		<property name="Material" value="Mpaper"/>
		<property name="EconomicValue" value="1600"/>
		<property name="SellableToTrader" value="false"/>
		<property class="Action0">
			<property name="Class" value="Quest"/>
			<property name="Delay" value="0"/>
			<property name="QuestGiven" value="quest_SkillPointReward"/>
		</property>
		<property name="FuelValue" value="2"/>
		<property name="Weight" value="2"/>
		<property name="Group" value="Special Items"/>
		<property name="CreativeMode" value="None"/>
		<property name="name_key" value="Skill Point Book" />
		<property name="desc_key" value="Awards 2 Skill Points for that quest you just completed. Good job!\n\n*Pats you on the head*" />
		<property name="CustomIcon" value="challengeQuestMaster"/>
		<property name="CustomIconTint" value="9f9fff"/>
		<property name="Stacknumber" value="200"/>
	</item>
</append>

 

EDIT: Fixed, I realised it was set to not show in creative mode.

 

Glad you got it resolved :)

Link to comment
Share on other sites

  • 2 weeks later...

Hey everyone, had a quick question.

Ive been making some modded configs (modlets) for my server, i've adjusted some Z using "set xpath" i've added some recipes and changed a few other bits. All works fine, the only thing i cant figure out is how to disable the food poisoning roll for some (specific) food items.

For instance "grilled meat"

 

https://pastebin.com/embed_js/phQEFZzt

This

 

https://pastebin.com/embed_js/hAhz8F0G

To This

 

i was trying to use the "set xpath" function, but its being a bit of a dog.

 

*edit* apparently i forgot how to insert things properly too :(

Link to comment
Share on other sites

Hey everyone, had a quick question.

Ive been making some modded configs (modlets) for my server, i've adjusted some Z using "set xpath" i've added some recipes and changed a few other bits. All works fine, the only thing i cant figure out is how to disable the food poisoning roll for some (specific) food items.

For instance "grilled meat"

 

https://pastebin.com/embed_js/phQEFZzt

This

 

https://pastebin.com/embed_js/hAhz8F0G

To This

 

i was trying to use the "set xpath" function, but its being a bit of a dog.

 

*edit* apparently i forgot how to insert things properly too :(

 

Did you want to remove the risk completely?

 

Here's a few examples that will get you close. You can add more to the xpath for more accuracy.

 

<set xpath="//triggered_effect[@cvar='.DiseaseRoll']/@value>0</>

<remove xpath="//triggered_effect[@cvar='.DiseaseRoll']" />

<remove xpath="//triggered_effect[@cvar='.DiseaseRoll' and @operation='set']" />

Link to comment
Share on other sites

Did you want to remove the risk completely?

 

Here's a few examples that will get you close. You can add more to the xpath for more accuracy.

 

<set xpath="//triggered_effect[@cvar='.DiseaseRoll']/@value>0</>

<remove xpath="//triggered_effect[@cvar='.DiseaseRoll']" />

<remove xpath="//triggered_effect[@cvar='.DiseaseRoll' and @operation='set']" />

 

Thanks! will give that a try!

And yeah, was trying to remove it entirely for some food, and change some others. The Everything gives you food poisoning was a bit much for the people i usually play with, just a casual evening kind of crew lol :)

Thanks again!

Link to comment
Share on other sites

Wouldnt ask if I havent tried & im proper stuck haha... Not even sure how to write this down so its understood but here goes....

 

The original Blocks.xml has the line <block name="steelMaster"> which has all the code needed to upgrade the Rconcrete block to steel... I need that block to be upgradable... so I tried using the following code...

 

<block name="steelMaster">

<property name="Group" value="Building,advBuilding"/>

<property name="DescriptionKey" value="steelBlockGroupDesc"/>

<property name="Material" value="Msteel"/>

<property name="DisplayType" value="blockHardened"/>

<property name="PassThroughDamage" value="true"/>

<property name="Texture" value="355,355,356,356,356,356"/>

<property name="CreativeMode" value="None"/>

<property class="RepairItems">

<property name="resourceForgedSteel" value="10"/>

</property>

<property class="UpgradeBlock">

<property name="ToBlock" value="Titanium Block"/>

<property name="Item" value="Forged Titanium"/>

<property name="ItemCount" value="10"/>

<property name="UpgradeHitCount" value="1"/>

</property>

<property name="CustomUpgradeSound" value="place_block_metal"/>

<drop event="Harvest" name="resourceRockSmall" count="25" tag="allHarvest"/>

<drop event="Destroy" count="0"/>

<drop event="Fall" name="terrDestroyedStone" count="1" prob="0.75" stick_chance="1"/>

<property name="EconomicValue" value="7"/>

<property name="FilterTags" value="fbuilding,fconcrete"/>

<property name="SortOrder1" value="40l0"/>

<property name="SortOrder2" value="0002"/>

</block>

 

Problem is when it loads its says 2 blocks with the same ID falling back to original block which obviously means my code is ignored & I get a red error... I know there must be a few ways of doing this but ive no idea how ,

 

What im trying to do is allow the Rconcrete blocks to be upgradable to a new Material (Titanium) which I already have working as a seperate block as that has a different name.. :(

 

any help would be greatfull...

Link to comment
Share on other sites

Wouldnt ask if I havent tried & im proper stuck haha... Not even sure how to write this down so its understood but here goes....

 

The original Blocks.xml has the line <block name="steelMaster"> which has all the code needed to upgrade the Rconcrete block to steel... I need that block to be upgradable... so I tried using the following code...

 

<block name="steelMaster">

<property name="Group" value="Building,advBuilding"/>

<property name="DescriptionKey" value="steelBlockGroupDesc"/>

<property name="Material" value="Msteel"/>

<property name="DisplayType" value="blockHardened"/>

<property name="PassThroughDamage" value="true"/>

<property name="Texture" value="355,355,356,356,356,356"/>

<property name="CreativeMode" value="None"/>

<property class="RepairItems">

<property name="resourceForgedSteel" value="10"/>

</property>

<property class="UpgradeBlock">

<property name="ToBlock" value="Titanium Block"/>

<property name="Item" value="Forged Titanium"/>

<property name="ItemCount" value="10"/>

<property name="UpgradeHitCount" value="1"/>

</property>

<property name="CustomUpgradeSound" value="place_block_metal"/>

<drop event="Harvest" name="resourceRockSmall" count="25" tag="allHarvest"/>

<drop event="Destroy" count="0"/>

<drop event="Fall" name="terrDestroyedStone" count="1" prob="0.75" stick_chance="1"/>

<property name="EconomicValue" value="7"/>

<property name="FilterTags" value="fbuilding,fconcrete"/>

<property name="SortOrder1" value="40l0"/>

<property name="SortOrder2" value="0002"/>

</block>

 

Problem is when it loads its says 2 blocks with the same ID falling back to original block which obviously means my code is ignored & I get a red error... I know there must be a few ways of doing this but ive no idea how ,

 

What im trying to do is allow the Rconcrete blocks to be upgradable to a new Material (Titanium) which I already have working as a seperate block as that has a different name.. :(

 

any help would be greatfull...

 

What about something like..

 

<append xpath="/blocks/block[@name='steelMaster']" > 
   <property class="UpgradeBlock">
        <property name="ToBlock" value="Titanium Block"/>
        <property name="Item" value="Forged Titanium"/>
        <property name="ItemCount" value="10"/>
        <property name="UpgradeHitCount" value="1"/>
    </property>
</append>

Link to comment
Share on other sites

Genius lol... I had ideas in my head but had NO idea how to actually code it... Thank You kind Sir :)

 

Must be doing something wrong cos when I go to upgrade the block (steelmaster) my Titanium icon shows up but nothing happens, like its asking me for the resource which I have but its not using it..

Edited by Tallon (see edit history)
Link to comment
Share on other sites

Couldnt get it to work with that Code so something else must be wrong ?

 

This is the original code for the steelblock...

 

<block name="steelMaster">

<property name="Group" value="Building,advBuilding"/>

<property name="DescriptionKey" value="steelBlockGroupDesc"/>

<property name="Material" value="Msteel"/>

<!-- <property name="FallDamage" value="1.2"/> Nah, that would be evil, right? -->

<property name="DisplayType" value="blockHardened"/>

<property name="PassThroughDamage" value="true"/>

<property name="Texture" value="355,355,356,356,356,356"/>

<!-- <property name="ImposterExchange" value="imposterBlock" param1="112"/> -->

<property name="CreativeMode" value="None"/>

<property class="RepairItems"> <property name="resourceForgedSteel" value="8"/> </property>

<property name="CustomUpgradeSound" value="place_block_metal"/>

<drop event="Harvest" name="resourceScrapIron" count="15" prob="1" tag="allHarvest"/>

<drop event="Destroy" count="0"/>

<drop event="Fall" name="scrapMetalPile" count="1" prob="0.75" stick_chance="1"/>

<property name="EconomicValue" value="160"/>

<property name="DescriptionKey" value="steelBlockGroupDesc"/>

<property name="FilterTags" value="fbuilding,fsteel"/>

<property name="SortOrder1" value="40p0"/>

<property name="SortOrder2" value="0002"/>

</block>

Edited by Tallon (see edit history)
Link to comment
Share on other sites

Couldnt get it to work with that Code so something else must be wrong ?

 

This is the original code for the steelblock...

 

<block name="steelMaster">

<property name="Group" value="Building,advBuilding"/>

<property name="DescriptionKey" value="steelBlockGroupDesc"/>

<property name="Material" value="Msteel"/>

<!-- <property name="FallDamage" value="1.2"/> Nah, that would be evil, right? -->

<property name="DisplayType" value="blockHardened"/>

<property name="PassThroughDamage" value="true"/>

<property name="Texture" value="355,355,356,356,356,356"/>

<!-- <property name="ImposterExchange" value="imposterBlock" param1="112"/> -->

<property name="CreativeMode" value="None"/>

<property class="RepairItems"> <property name="resourceForgedSteel" value="8"/> </property>

<property name="CustomUpgradeSound" value="place_block_metal"/>

<drop event="Harvest" name="resourceScrapIron" count="15" prob="1" tag="allHarvest"/>

<drop event="Destroy" count="0"/>

<drop event="Fall" name="scrapMetalPile" count="1" prob="0.75" stick_chance="1"/>

<property name="EconomicValue" value="160"/>

<property name="DescriptionKey" value="steelBlockGroupDesc"/>

<property name="FilterTags" value="fbuilding,fsteel"/>

<property name="SortOrder1" value="40p0"/>

<property name="SortOrder2" value="0002"/>

</block>

 

Sorry for the delay. The snippet works, in that its inserted in the right spot.

 

Does the ToBlock value point to an actual block? Does the Item point to an item that you use to upgrade it with?

Link to comment
Share on other sites

Passing a variable to Animator error

 

Edit: I just checked the game code and saw that "AnimatotSet" functions don't accept CVars. :upset:

 

Hi

I am trying to pass an Int variable to the AnimationController but for some reason I get an error.

 

If I do:

   <triggered_effect trigger="onSelfPrimaryActionStart" action="ModifyCVar" target="self" cvar="TestCVar" operation="set" value="1"/>
   <triggered_effect trigger="onSelfPrimaryActionStart" action="AnimatorSetInt" target="self" property="TempProp" value="@TestCVar"/>

 

I get:

ERR XML loader: Loading and parsing 'items.xml' failed
FormatException: Input string was not in the correct format.

 

and if I do:

   <triggered_effect trigger="onSelfPrimaryActionStart" action="ModifyCVar" target="self" cvar="TestCVar" operation="set" value="1"/>
   <triggered_effect trigger="onSelfPrimaryActionStart" action="AnimatorSetFloat" target="self" property="TempProp" value="@TestCVar"/>

I get:

ERR XML loader: Loading and parsing 'items.xml' failed
FormatException: Unknown char: @ (input: '@TempCVar')

Basically these are the 2 lines that are causing it (actually the last line is causing it). For sake of testing I just created a new CVar and tried to pass it to the AnimationController.

 

 

If I pass a value like "3" it works fine. In this post from last year is noted that you can use a CVar for value with '@' in front of the name of the CVar and you can use it with Animator actions.

What am I doing wrong?

Edited by ivailogeimara
Including more info (see edit history)
Link to comment
Share on other sites

<config>

<set xpath="/lootcontainers/lootcontainer[@id=25']/item[@name=resourceFeather]/@count">5,10</set>

</config>.

 

 

id=numbers or not in use anymore, or are they?

 

cant see them anywhere

if yes, where do i find the ids?

if no, the id is now the item/block name?

Link to comment
Share on other sites

id=numbers or not in use anymore, or are they?

 

cant see them anywhere

if yes, where do i find the ids?

if no, the id is now the item/block name?

 

What do you mean by ids are not used anymore?

Loot containers have ids. Not everything is using ids. id is just a property as name is just a property. Some things in the XMLs have ids and some have names.

 

Here is example loot container from loot.xml:

<lootcontainer id="9" count="0,2" size="6,2" sound_open="UseActions/open_backpack" sound_close="UseActions/close_backpack" open_time="1.5" loot_quality_template="qualBaseTemplate">
<item group="backpacks"/>
</lootcontainer>

(this is from A18 BTW.)

Edited by ivailogeimara (see edit history)
Link to comment
Share on other sites

It was to an actual Block :)

 

Do you have the full error?

 

- - - Updated - - -

 

id=numbers or not in use anymore, or are they?

 

cant see them anywhere

if yes, where do i find the ids?

if no, the id is now the item/block name?

 

Loot containers, as far as I know, still use hard coded numbers, rather than names. Hopefully that'll see a similar update as the blocks.xml and items.xml in the future. You would have to manually look through the loot.xml to find a 'free' sequential number.

 

- - - Updated - - -

 

Edit: I just checked the game code and saw that "AnimatotSet" functions don't accept CVars. :upset:

 

Hi

I am trying to pass an Int variable to the AnimationController but for some reason I get an error.

 

If I do:

   <triggered_effect trigger="onSelfPrimaryActionStart" action="ModifyCVar" target="self" cvar="TestCVar" operation="set" value="1"/>
   <triggered_effect trigger="onSelfPrimaryActionStart" action="AnimatorSetInt" target="self" property="TempProp" value="@TestCVar"/>

 

I get:

ERR XML loader: Loading and parsing 'items.xml' failed
FormatException: Input string was not in the correct format.

 

and if I do:

   <triggered_effect trigger="onSelfPrimaryActionStart" action="ModifyCVar" target="self" cvar="TestCVar" operation="set" value="1"/>
   <triggered_effect trigger="onSelfPrimaryActionStart" action="AnimatorSetFloat" target="self" property="TempProp" value="@TestCVar"/>

I get:

ERR XML loader: Loading and parsing 'items.xml' failed
FormatException: Unknown char: @ (input: '@TempCVar')

Basically these are the 2 lines that are causing it (actually the last line is causing it). For sake of testing I just created a new CVar and tried to pass it to the AnimationController.

 

 

If I pass a value like "3" it works fine. In this post from last year is noted that you can use a CVar for value with '@' in front of the name of the CVar and you can use it with Animator actions.

What am I doing wrong?

 

That's unfortunate it doesn't use cvars. That could have been used in a few interesting ways.

Link to comment
Share on other sites

hi there, i followed your guide and attempted to add in a stainless steel mod but make it so that instead of it being craftable that it would be obtainable from the trader, i created a traders.xml file, added in the following code: <trader_item_group name="generalResources"> <!-- bundle size -->

<item name="steelPolish" count="50,1000"/> <!-- 50 -->

 

i know i went somewhere wrong, i had to open and close the code so to speak? so i put <append=xpath> or something, i tried different variations, i am very noob at this stuff sorry, i was just wondering if someone can help me figure this out, thanks.

 

Link to the mod and my issue here: https://7daystodie.com/forums/showthread.php?130484-MODLET-A18-Stainless-Steel-Again/page2

Link to comment
Share on other sites

I don't think I read anything about setting the position of elements.

 

I'd like to move the UI elements out towards the edges more.

 

Only the things you see when no windows are open, like health, stamina, compass, toolbelt etc. All the static elements.

 

I've downloaded an addon that's a windows.xml to kinda dissect, if you will, but I can't make heads or tails of 'pos" attribute. I don't know where these values would be on screen.

Link to comment
Share on other sites

Is it something wrong with my game or <property name="Sound_reload"> does not work? I tried to change the reload sound of my imported gun and nothing happened (it plays default pistol reload sound). Then I tested with simple mod:

items.xml

<config>
   <set xpath="/items/item[@name='gunPistol']/property[@class='Action0']/property[@name='Sound_reload']/@value">44magnum_reload</set>
</config>

and again the pistol_reload (not 44magnum_reload) sound plays.

Edited by ivailogeimara (see edit history)
Link to comment
Share on other sites

This may sound silly, but is xpath limited to changes to xml files within only the config folder? I am trying to write a modlet for changes to an xml file contained within the Worlds directory instead.

 

For example, adding the following prefab location line to a World Map prefabs.xml file.

 

   <decoration type="model" name="LazManPrison" position="5755,28,3164" rotation="0" />

Link to comment
Share on other sites

This may sound silly, but is xpath limited to changes to xml files within only the config folder? I am trying to write a modlet for changes to an xml file contained within the Worlds directory instead.

 

For example, adding the following prefab location line to a World Map prefabs.xml file.

 

   <decoration type="model" name="LazManPrison" position="5755,28,3164" rotation="0" />

 

I think only the Data/Config files are read for xpath insertion. I'm assuming this is to add something to Navezgane?

Link to comment
Share on other sites

I think only the Data/Config files are read for xpath insertion. I'm assuming this is to add something to Navezgane?

 

A custom world. No big deal though. Will just ask creator to include the xml edits and/or provide copy/paste instructions with the files. Thanks sphereii!

Link to comment
Share on other sites

A custom world. No big deal though. Will just ask creator to include the xml edits and/or provide copy/paste instructions with the files. Thanks sphereii!

 

Add a mods/modname/worlds/yourworldname folder and put the fully edited prefabs.xml in there.

 

No Xpath, but it should "install" the worlds folder when run.

Link to comment
Share on other sites

Add a mods/modname/worlds/yourworldname folder and put the fully edited prefabs.xml in there.

 

No Xpath, but it should "install" the worlds folder when run.

 

I think he was trying to add the prison to someone else' generated world. Kind of like a mod to an existing worl.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...