Jump to content

Help With Some Code. Am I Blind?


Recommended Posts

An exerpt from the logs and the code below

"2020-07-16T20:48:41 17.703 WRN XML patch for "blocks.xml" from mod "Apex's Survival Immersion" did not apply: <remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']" 
2020-07-16T20:48:41 17.737 ERR XML loader: Patching 'blocks.xml' from mod 'Apex's Survival Immersion' failed:
2020-07-16T20:48:41 17.738 EXC '/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']@name' has an invalid token.
XPathException: '/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']@name' has an invalid token."

<Apex>
	<remove xpath="/blocks/block[@name='treeMaster']/drop[@event='Destroy']"/>
	<remove xpath="/blocks/block[@name='treeStump']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']"/>

	<remove xpath="/blocks/block[@name='treePlainsTree']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeDeadPineLeaf']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeSnowyDeadBush']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeAzalea']/drop[@event='Harvest']"/>
    
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='30']/@count">6</set>
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='70']/@count">14</set>
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='110']/@count">22</set>
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='150']/@count">30</set>
	
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']@name">resourceSticks</set>
	
</Apex>

I can't seem to find any syntax issue with this code. Anybody have better eyes than me?

P.S. This is simply TEST code for making the getting of wood from trees more realistic and complicated, actually having a use for the table saw.

Link to comment
Share on other sites

On 7/16/2020 at 8:02 PM, ApexAlphaGaming said:

An exerpt from the logs and the code below

"2020-07-16T20:48:41 17.703 WRN XML patch for "blocks.xml" from mod "Apex's Survival Immersion" did not apply: <remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']" 
2020-07-16T20:48:41 17.737 ERR XML loader: Patching 'blocks.xml' from mod 'Apex's Survival Immersion' failed:
2020-07-16T20:48:41 17.738 EXC '/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']@name' has an invalid token.
XPathException: '/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']@name' has an invalid token."

<Apex>
	<remove xpath="/blocks/block[@name='treeMaster']/drop[@event='Destroy']"/>
	<remove xpath="/blocks/block[@name='treeStump']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']"/>

	<remove xpath="/blocks/block[@name='treePlainsTree']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeDeadPineLeaf']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeSnowyDeadBush']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeAzalea']/drop[@event='Harvest']"/>
    
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='30']/@count">6</set>
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='70']/@count">14</set>
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='110']/@count">22</set>
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood'][@count='150']/@count">30</set>
	
	<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']@name">resourceSticks</set>
	
</Apex>

I can't seem to find any syntax issue with this code. Anybody have better eyes than me?

P.S. This is simply TEST code for making the getting of wood from trees more realistic and complicated, actually having a use for the table saw.

I agree with Mr. Delusive. Missing that "/"   But I also have a question... I never knew you could do multiple conditions written out like that?! I was did this:

 

<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest' and @name='resourceWood']/@name">resourceSticks</set>
 

If you already got it working let us know! 🙂

Link to comment
Share on other sites

Unfortunately it did not work, I was busy adding more idea code, simpler code at least but it doesn't matter because the above code still doesn't work.

 

Edit: Now the game gives an error and omits the blocks.xml entirely, causing the game to crash on loadup into world. Weird thing is though, there are no more error codes specifying lines of code anymore.... I checked the entire log just now and nothing.

Link to comment
Share on other sites

the remove lines -

<remove xpath="/blocks/block[@name='treeMaster']/drop[@event='Destroy']"/>
	<remove xpath="/blocks/block[@name='treeStump']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']"/>

should be -

 

<remove xpath="/blocks/block[@name='treeMaster']/drop[@event='Destroy']"/></remove
	<remove xpath="/blocks/block[@name='treeStump']/drop[@event='Harvest']"/></remove
	<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']"/></remove

same here - add </remove> at the end of each of these -

<remove xpath="/blocks/block[@name='treePlainsTree']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeDeadPineLeaf']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeSnowyDeadBush']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeAzalea']/drop[@event='Harvest']"/>
Link to comment
Share on other sites

19 minutes ago, stallionsden said:

the remove lines -


<remove xpath="/blocks/block[@name='treeMaster']/drop[@event='Destroy']"/>
	<remove xpath="/blocks/block[@name='treeStump']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']"/>

should be -

 


<remove xpath="/blocks/block[@name='treeMaster']/drop[@event='Destroy']"/></remove
	<remove xpath="/blocks/block[@name='treeStump']/drop[@event='Harvest']"/></remove
	<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']"/></remove

same here - add </remove> at the end of each of these -


<remove xpath="/blocks/block[@name='treePlainsTree']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeDeadPineLeaf']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeSnowyDeadBush']/drop[@event='Harvest']"/>
	<remove xpath="/blocks/block[@name='treeAzalea']/drop[@event='Harvest']"/>

 

This doesn't work, the log file states that the </remove> is the issue, I originally used that because the code was copy pasted from another of my mods where I used <set> </set> but it doesn't work for <remove> unfortunately

Link to comment
Share on other sites

18 minutes ago, ApexAlphaGaming said:

 

This doesn't work, the log file states that the </remove> is the issue, I originally used that because the code was copy pasted from another of my mods where I used <set> </set> but it doesn't work for <remove> unfortunately

 

Hi ApexAlphaGaming

 

you can try this, it works for all wooden blocks.

 

<set xpath="/blocks/block/drop[@event='Harvest' and @name='resourceWood']/@count">8</set>

Link to comment
Share on other sites

43 minutes ago, ApexAlphaGaming said:

 

This doesn't work, the log file states that the </remove> is the issue, I originally used that because the code was copy pasted from another of my mods where I used <set> </set> but it doesn't work for <remove> unfortunately

Hmmm its how i have mine and it works. Weird.

 

But by your logs the error is here -

 

<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']" 

 

Or before

Is there a woodlogpillar 🤔🤔 cant check on phone lol.

 

Spelt correctly. Etc

Link to comment
Share on other sites

8 minutes ago, stallionsden said:

Hmmm its how i have mine and it works. Weird.

 

But by your logs the error is here -

 


<remove xpath="/blocks/block[@name='woodLogPillar']/drop[@event='Harvest']" 

 

Or before

Is there a woodlogpillar 🤔🤔 cant check on phone lol.

 

Spelt correctly. Etc

 

Would be woodLogPillar100,it's just the one that exists.

Link to comment
Share on other sites

Just letting you know, you can test your XPathing by opening the xml file in Chrome and Inspecting and Ctrl+F the inspect code you can enter your XPath there to see if there are issues. I tried entering your XPath into the blocks XML to find the element, however there is no element named "woodLogPillar", there is woodLogPillar100 however.

 

Also I had issues getting the blocks element for some reason, but it is cleaner to just do //block[@name='woodLogPillar100']/drop[@event='Harvest']

With this XPath I was able to detect the element.

On 7/20/2020 at 4:13 PM, Riles said:

I agree with Mr. Delusive. Missing that "/"   But I also have a question... I never knew you could do multiple conditions written out like that?! I was did this:

 

<set xpath="/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest' and @name='resourceWood']/@name">resourceSticks</set>
 

If you already got it working let us know! 🙂

This as well, if the XPath Returns Multiple results, I believe it will only apply the change to the first element it finds.
so the line

/blocks/block[starts-with(@name, 'tree')]/drop[@event='Harvest'][@name='resourceWood']/@name

It's returning 43 results, I am not 100% but I do believe it is only going to apply it to the first result, or perhaps the fact that it is returning so many results is causing an issue in game.

Link to comment
Share on other sites

Sorry for the lack of update, been working on it, I did discover the "woodLogPillar100" issue and fixed it, but unfortunately it doesn't resolve the issue entirely. Blocks.xml is still giving errors, but now the errors no longer point to any particular line of code in the logs, leaving me entirely bewildered.

 

I have scrapped the idea entirely at this point.

 

For anybody wondering, you can just have my idea altogether, and if you can get it to work, go for it, I may even download your mod.

 

I planned on removing trees and stumps from giving you wood, to giving you logs, (but only once felled), using the table saw or a fire axe to get split wood, and the table saw again to get planks like normal. Any other blocks containing wood in game can give you planks, just like IRL, if you broke apart a couch you could recover some of it's planks, or a dresser, etc... The two bushes would give you sticks and you would need a bundle of sticks and plant fibers to make a wooden handle for any tool crafting. Or a table saw and a plank to craft a wooden handle for tools.

 

All trees downgrade to tree stumps after being chopped down. Logs can be placed a chopped into split wood.

 

Anyways thanks for all the support but the issue must be something I'm too deeply invested to be able to see, so enjoy, if you can get it to work. Includes a scythe for getting grass in a large area of affect too.

loot.xml recipes.xml blocks.xml items.xml Localization.txt ToDo List.txt

Link to comment
Share on other sites

7 minutes ago, ApexAlphaGaming said:

Sorry for the lack of update, been working on it, I did discover the "woodLogPillar100" issue and fixed it, but unfortunately it doesn't resolve the issue entirely. Blocks.xml is still giving errors, but now the errors no longer point to any particular line of code in the logs, leaving me entirely bewildered.

 

I have scrapped the idea entirely at this point.

 

For anybody wondering, you can just have my idea altogether, and if you can get it to work, go for it, I may even download your mod.

 

I planned on removing trees and stumps from giving you wood, to giving you logs, (but only once felled), using the table saw or a fire axe to get split wood, and the table saw again to get planks like normal. Any other blocks containing wood in game can give you planks, just like IRL, if you broke apart a couch you could recover some of it's planks, or a dresser, etc... The two bushes would give you sticks and you would need a bundle of sticks and plant fibers to make a wooden handle for any tool crafting. Or a table saw and a plank to craft a wooden handle for tools.

 

All trees downgrade to tree stumps after being chopped down. Logs can be placed a chopped into split wood.

 

Anyways thanks for all the support but the issue must be something I'm too deeply invested to be able to see, so enjoy, if you can get it to work. Includes a scythe for getting grass in a large area of affect too.

loot.xml 323 B · 0 downloads recipes.xml 1.8 kB · 0 downloads blocks.xml 5.92 kB · 0 downloads items.xml 7.52 kB · 0 downloads Localization.txt 425 B · 0 downloads ToDo List.txt 4.38 kB · 0 downloads

 

Hi ApexAlphaGaming

 

There is this even in blocks.xml:

 

<block name = "woodLogPillar">
<drop event = "Destroy" name = "resourceSplitWood" count = "2" />
<property name = "CanPickup" value = "true" />
</block>

 

It could be the mistake that does not mark you.

Link to comment
Share on other sites

You are creating Duplicate Block names in the blocks.XML code there.

For example here's what the code for juniper4m would look like after running your modlet:


<block name="treeJuniper4m">
    <property name="Extends" value="treeMaster"/>
    <property name="Model" value="#Entities/Trees?Hollywood_Juniper15mPrefab.prefab"/>
    <property name="ModelOffset" value="0,-0.3,0"/>
    <property name="MultiBlockDim" value="1,4,1"/>
    <property name="BigDecorationRadius" value="3"/>
    <property name="CanPlayersSpawnOn" value="false"/>
    <property name="ParticleOnDeath" value="treeGib_small_dust"/>
    <drop event="Harvest" name="resourceWood" count="30" tag="oreWoodHarvest"/>
    <drop event="Destroy" name="treePlantedMountainPine1m" count="1"/>
    <property name="SortOrder2" value="0120"/> <!-- SortTree -->
</block>

 

<block name="treeJuniper4m">
    <drop event="Destroy" name="woodLogPillar100" count="4"/>
</block>

 

Having 2 blocks with the same name is probably throwing all sorts of NullReference exceptions

 

What you are going for say with removing the Harvest Event and I assume you just want to override the Destroy event correct?

The append section needs to be removed entirely and you need to have:

<remove xpath="//block[@name='treeJuniper4m']/drop[@event='Harvest']"/>

<set xpath="//block[@name='treeJuniper4m']/drop[@event='Destroy']/@name">woodLogPillar100</set>

 

The first line which is what you already have for some to remove the Harvest code, and you need to add the second line to switch the Destroy event. Doing this will have the resulting code:

 

<block name="treeJuniper4m">
    <property name="Extends" value="treeMaster"/>
    <property name="Model" value="#Entities/Trees?Hollywood_Juniper15mPrefab.prefab"/>
    <property name="ModelOffset" value="0,-0.3,0"/>
    <property name="MultiBlockDim" value="1,4,1"/>
    <property name="BigDecorationRadius" value="3"/>
    <property name="CanPlayersSpawnOn" value="false"/>
    <property name="ParticleOnDeath" value="treeGib_small_dust"/>
    <drop event="Destroy" name="woodLogPillar100" count="1"/>
    <property name="SortOrder2" value="0120"/> <!-- SortTree -->
</block>

Link to comment
Share on other sites

2 hours ago, MrDelusive said:

You are creating Duplicate Block names in the blocks.XML code there.

For example here's what the code for juniper4m would look like after running your modlet:


<block name="treeJuniper4m">
    <property name="Extends" value="treeMaster"/>
    <property name="Model" value="#Entities/Trees?Hollywood_Juniper15mPrefab.prefab"/>
    <property name="ModelOffset" value="0,-0.3,0"/>
    <property name="MultiBlockDim" value="1,4,1"/>
    <property name="BigDecorationRadius" value="3"/>
    <property name="CanPlayersSpawnOn" value="false"/>
    <property name="ParticleOnDeath" value="treeGib_small_dust"/>
    <drop event="Harvest" name="resourceWood" count="30" tag="oreWoodHarvest"/>
    <drop event="Destroy" name="treePlantedMountainPine1m" count="1"/>
    <property name="SortOrder2" value="0120"/> <!-- SortTree -->
</block>

 

<block name="treeJuniper4m">
    <drop event="Destroy" name="woodLogPillar100" count="4"/>
</block>

 

Having 2 blocks with the same name is probably throwing all sorts of NullReference exceptions

 

What you are going for say with removing the Harvest Event and I assume you just want to override the Destroy event correct?

The append section needs to be removed entirely and you need to have:

<remove xpath="//block[@name='treeJuniper4m']/drop[@event='Harvest']"/>

<set xpath="//block[@name='treeJuniper4m']/drop[@event='Destroy']/@name">woodLogPillar100</set>

 

The first line which is what you already have for some to remove the Harvest code, and you need to add the second line to switch the Destroy event. Doing this will have the resulting code:

 

<block name="treeJuniper4m">
    <property name="Extends" value="treeMaster"/>
    <property name="Model" value="#Entities/Trees?Hollywood_Juniper15mPrefab.prefab"/>
    <property name="ModelOffset" value="0,-0.3,0"/>
    <property name="MultiBlockDim" value="1,4,1"/>
    <property name="BigDecorationRadius" value="3"/>
    <property name="CanPlayersSpawnOn" value="false"/>
    <property name="ParticleOnDeath" value="treeGib_small_dust"/>
    <drop event="Destroy" name="woodLogPillar100" count="1"/>
    <property name="SortOrder2" value="0120"/> <!-- SortTree -->
</block>

No, not really, that's where "<append xpath" comes in. Look again at Blocks.xml and you'll see "<append xpath='/blocks">" before any actual block editing happens, meaning no "duplicates" being created at all, only appended. The "<remove>" command happens beforehand because it is extremely specific about the "xpath".

 

I am removing the harvest in order to force a drop instead, don't want you getting logs as you hit the tree.

 

If I'm being honest though, I'm too tired of looking at this code at this point to even understand much more feedback, I feel like I have code dyslexia from the amount of time I've spent on it. I am taking an indefinite break from modding this game, until either the inspiration comes back or the confusion wears off.

 

Edit: One more thing, you're edit would not work, as the "treeMaster" block that every single tree extends from overwrites any "Destroy" property written to any tree, Hence why I use <remove> in the beginning to take away the "Destroy" event from the "treeMaster". Okay, too much code talk already, it's 5am here, I need sleep.

Link to comment
Share on other sites

I think you are misunderstanding how append works here which might be the cause of your problem. In the way you are using append, it is adding all the code in the append block after all code within the blocks node, which means it is creating duplicates.

I already understand what you are doing in your code and I very clearly saw the append xpath.

You either need to use the Set command as in my example above, or use append in the exact same way (IF the node doesn't exist). Because the node already exists, you aren't deleting it, you can use the set command also. The append should be used like this:
<append xpath="//block[@name='treeJuniper4m']/drop[@event='Destroy']/@name">woodLogPillar100</append>


I understand though about the burnout and hope you will eventually come back to the code as it sounds like a good idea.

 

EDIT: As well the "treeMaster" inheritance mentioned works the opposite way. Any child nodes that extend treeMaster overwrites whatever in treeMaster not the other way around. If treeMaster has no destroy event and treeJuniper4m does, this means that treeJuniper4m WILL have a Destroy event.

If you don't believe me about you are using append incorrectly, have just this in your blocks.XML and see how it fails:

<Apex>
    <append xpath="/blocks">     
        <block name="treeJuniper4m">
            <drop event="Destroy" name="woodLogPillar100" count="4"/>
        </block>
    </append>
</Apex>

 

now after that, try it the way i suggested:

<Apex>

    <remove xpath="//block[@name='treeJuniper4m']/drop[@event='Harvest']"/>

    <set xpath="//block[@name='treeJuniper4m']/drop[@event='Destroy']/@name">woodLogPillar100</set>

</Apex>
Also Run just that code. So you aren't removing the Destroy event from treeMaster so you can see what I mean.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...