Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - TeflonJim

#2
Mine is a continuation of the old module with very few changes.

It's entirely XML-based with a bunch of patches that aim to add compatibility with a few other mods that I either use or have considered using.

Essentially it's almost no work for me to maintain; I have no intention of actively developing it beyond fixing or a patch here and there.
#3
Unfinished / Re: [1.0][WIP] Real Ruins
November 01, 2018, 06:27:21 PM
*Edit* Tempted to disregard this. I don't have the best internet connection in the world. It worked this morning and downloaded 5MB of stuff.

I can't seem to get past the timeout when starting this unfortunately. Is the initial download large?

Exception during loading object: System.Exception: timed out
  at HugsLib.Utils.HugsLibUtility+<>c__DisplayClass22_0.<AwaitUnityWebResponse>b__0 () [0x00000] in <filename unknown>:0
Verse.Log:Message(String, Boolean)
RealRuins.<>c:<AmazonS3DownloadSnapshot>g__failureHandler|10_1(Exception)
HugsLib.Utils.<>c__DisplayClass22_0:<AwaitUnityWebResponse>b__0()
HugsLib.Utils.DoLaterScheduler:InvokeCallbacks(Queue`1)
HugsLib.Utils.DoLaterScheduler:OnUpdate()
HugsLib.HugsLibController:OnUpdate()
HugsLib.Patches.Root_Patch:UpdateHook()
Verse.Root:Update_Patch1(Object)


*Edit* Tempted to disregard this. I don't have the best internet connection in the world. It worked this morning and downloaded 5MB of stuff.
#4
Quote from: tcjaime on July 23, 2018, 09:17:32 AM
Help!  I'm new to patching and I'm stuck. Can someone tell me why this is changing all the power consumptions (ex wind gen) to 5 instead of just the lamp? Thank you!
You need to make a comparison inside your expression or it'll always evaluate to true.
<xpath>/Defs/ThingDef[defName="StandingLampBase"]/comps/li["CompProperties_Power"]/basePowerConsumption</xpath>
You'll need something similar for CompProperties_Power, but I don't have rimworld on this computer to check exactly what that should be.
#5
The file path is completely irrelevant to the expression you're writing. XPath is used to search XML content, not files themselves. Defs is the root node (inside the XML document), and ThingDef is often the node you're most interested in editing in this case.

There was a twist with the previous versions, the game would patch a file at a time. At that point you might attempt to optimize a little, pushing more complex expressions behind simpler ones which targetted the right file first. In version 1.0 this changes. Everything is loaded into memory first, then patches are applied to the composite in memory.

In short, completely ignore the file name, and the directories it resides in. Concentrate only on the content within the files.
#6
Quote from: Boartato on July 20, 2018, 10:30:45 AM
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationReplace">
<xpath>*/RangedIndustrial[defName="Gun_Revolver"]/description</xpath>
<value>
<description>Why doesn't anything work?</description>
</value>
</Operation>
</Patch>


I've been struggling with Xpath for a solid 8 hours. Finally decided to stop trying to do anything meaningful and really see if I could get a basic Xpath down. This code above fails. Every tutorial I've read, if I'm understanding things correctly, says this should work. This tutorial in particular would be the one closest to what I'm trying to do: https://gist.github.com/Zhentar/4a1b71cea45b9337f70b30a21d868782
I assume you're trying to edit Gun_Revolver in Core\Defs\ThingDefs_Misc\Weapons\RangedIndustrial.xml?

If so, RangedIndustrial is the file name, not the name of the second element. I recommend you try:

<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName="Gun_Revolver"]/description</xpath>
<value>
<description>Why doesn't anything work?</description>
</value>
</Operation>
</Patch>

For anyone else visiting, I pulled the def from core, here it is for reference:

<ThingDef ParentName="BaseHumanMakeableGun">
  <defName>Gun_Revolver</defName>
  <label>revolver</label>
  <description>An ancient pattern double-action revolver. It's not very powerful, but has a decent range for a pistol and is quick on the draw.</description>
  <graphicData>
    <texPath>Things/Item/Equipment/WeaponRanged/Revolver</texPath>
    <graphicClass>Graphic_Single</graphicClass>
  </graphicData>
  <soundInteract>Interact_Revolver</soundInteract>
  <statBases>
    <WorkToMake>4000</WorkToMake>
    <Mass>1.4</Mass>
    <AccuracyTouch>0.80</AccuracyTouch>
    <AccuracyShort>0.75</AccuracyShort>
    <AccuracyMedium>0.45</AccuracyMedium>
    <AccuracyLong>0.35</AccuracyLong>
    <RangedWeapon_Cooldown>1.6</RangedWeapon_Cooldown>
  </statBases>
  <weaponTags>
    <li>SimpleGun</li>
  </weaponTags>
  <costList>
    <Steel>30</Steel>
    <ComponentIndustrial>2</ComponentIndustrial>
  </costList>
  <recipeMaker>
    <skillRequirements>
      <Crafting>3</Crafting>
    </skillRequirements>
  </recipeMaker>
  <verbs>
    <li>
      <verbClass>Verb_Shoot</verbClass>
      <hasStandardCommand>true</hasStandardCommand>
      <defaultProjectile>Bullet_Revolver</defaultProjectile>
      <warmupTime>0.3</warmupTime>
      <minRange>1.5</minRange>
      <range>25.9</range>
      <soundCast>Shot_Revolver</soundCast>
      <soundCastTail>GunTail_Light</soundCastTail>
      <muzzleFlashScale>9</muzzleFlashScale>
    </li>
  </verbs>
  <tools>
    <li>
      <label>grip</label>
      <capacities>
        <li>Blunt</li>
      </capacities>
      <power>9</power>
      <cooldownTime>2</cooldownTime>
    </li>
    <li>
      <label>barrel</label>
      <capacities>
        <li>Blunt</li>
        <li>Poke</li>
      </capacities>
      <power>9</power>
      <cooldownTime>2</cooldownTime>
    </li>
  </tools>
</ThingDef>
#7
Quote from: kaptain_kavern on December 13, 2017, 03:31:11 AM
Here the patch I currently using. Noticed the "li[3]" in the xpath.

You ideally want something that uniquely identifies the last item in the list. Is dessicatedBodyGraphicData absent from the remaining items in the list?

If so, you might use this, which find li based on the presence of the dessicatedBodyGraphicData element:


Defs/PawnKindDef[defName = "Gazelle"]/lifeStages/li[dessicatedBodyGraphicData]


Otherwise I'll pull the def out from core tonight and have a better look.
#8
This expression is a very simple one and I would recommend it over nested function calls. I doubt you'll notice a speed difference, but there's certainly a complexity difference.


[.="Outlander"]


In theory all it needs you to know is that "." is the current XML node (be that an element as it is here, or an attribute), and that we can test a simple value using "=".

It's perhaps worth mentioning you can drop the "text()" function entirely, making the other expression into this:


*/ThingDef[defName = "Apparel_VestPlate"]/apparel/tags/li[contains(.,"Outlander")]


About text()

text() gets text elements (as opposed to node elements) from a given path. In the example below, "item" is a text element, "child" is a node element.


<document>
  <item>ItemValue</item>
  <child>
    <otherItem>ItemValue</otherItem>
  </child>
</document>


The expression below will nodes of text type only, therefore you would only find "item", and not "child".


document/*[text()]


About contains(this, containsthat)

The xpath expression below uses contains:


document/stuff/li[contains(., "Wood")]


When used to search the following document it will find both Wood_Green and Wood_Orange. Both contain the specified value.


<document>
  <stuff>
    <li>Wood_Green</li>
    <li>Wood_Orange</li>
    <li>Metal</li>
    <li>Plastic</li>
  </stuff>
</document>


Contains is most useful where you might have wanted a wildcard, a partial match. In the case where you want an exact value equality (using "=") is much more appropriate.

In all cases, XML (and xpath expressions) are case-sensitive. The changes in B18 should make it easier to develop patches as documents will be more predictable in the future.
#9
You can use . to refer to the current node and therefore filter to a single instance in the list. For example:


<xpath>Defs/ThingDef[defName = "Apparel_VestPlate"]/apparel/tags/li[.="Outlander"]</xpath>


This will let you target it for patch operations.
#10
Outdated / Re: [B18] Extended Woodworking [ModSync]
December 09, 2017, 08:36:36 AM
Yes, you can make things out of the different wood types.

No, they have different strengths. I didn't have much of a basis for that other than a few of the woodworking / lumber web sites, and then it's just a relative adjustment to those from the original mod (or at least when I picked it up).

If you're particularly interested you'll find the values in the json file here:

https://github.com/indented-automation/ExtendedWoodworking/blob/master/woodStats.json

This thread only really exists so I could make it work with ModSync :)
#11
Outdated / [B18] Extended Woodworking [ModSync]
December 09, 2017, 05:22:53 AM
Extended Woodworking

Description

This mod extends trees so that they drop different types of wood based on the tree they are. This mod also allows you to paint wood into 6 different colours (Red, Green, Blue, Yellow, White, Black) which you can use to build various things.

A woodworking table has been added to allow you to convert the different wood types into normal wood so you can still build the various buildings that require normal wood to be built. You can also paint wood at that table.

Mod Team

    TeflonJim - Updates from A13 to current
    ItchyFlea - Code (A13)
    Silvermane - Fence & FenceGate Textures

Download

https://github.com/indented-automation/ExtendedWoodworking/releases

Changelog

v5.0.3

  • Redesigned to use XML patching
  • Integrated VGP add-on as a patch using ModCheck
  • Added support for a number of other mods
  • Added ModSync.Ninja support

#12
B18 version:

https://github.com/indented-automation/ExtendedWoodworking/releases/tag/v5.0.3

The core of the mod has XML defs updated to current version. Added support for vanilla defs which consume wood with a series of XML patches.

Added explicit support for defs created by:


  • [RF] Basic Bridges - Fishing Add-On
  • [RF] Fertile Fields
  • [T] ExpandedCloth
  • A Dog Said...
  • Area Rugs
  • Misc. Training
  • Nature's Pretty Sweet
  • VGP Xtra Trees and Flowers
Should be fast to load and should be error free now.
#13
The comp property you're attempting to filter on is the value of a class attribute.

If you make your expression this, it should work:



/Defs/ThingDef[defName="HiTechResearchBench"]/comps/li[@Class="CompProperties_AffectedByFacilities"]/linkableFacilities



Where @ (in @Class) is used to indicate the expression should evaluate an attribute rather than an element name.
#14
Thank you kindly, I'll follow the same scheme.

Chris
#15
Trying to figure out if what I'm trying to do is even possible or not. I'm attempting to merge my fork of Extended Woodworking with its Vegetable Garden patch. To achieve that I (think I) either need to:

1. Only create a set of ThingDefs if a particular mod is present (and loaded)

Or:

2. Remove a small set of ThingDefs if a particular mod is not present

The second approach is working for a bunch of floors the mod injects, it appears to strip out the TerrainDefs well enough. The linked sequence attempts to do this:

https://github.com/indented-automation/ExtendedWoodworking/blob/master/generated/ExtendedWoodworking/Patches/EW-Cleanup-NoVGP.xml

The link uses PathOperationFindMod which has since been substituted for a PatchOperationConditional based on a Def exposed by the dependent mod. I'm going to replace that with ModCheck because it's just really, really disgusting and I've been starring at PatchOperation classes in ilspy for too long now.

Doing this in C# is likely easier, but my fork was only ever intended to maintain the life of a mod I've always used (and certainly didn't originally create). I'm reluctant to move it out of just-a-bit-of-xml at the moment.

If I can figure this bit out I can do (at least) one more "is this sane" pass on the XML / XPath before making it live.

Otherwise, is there a better way of doing this that I don't know about yet?

Thanks for any / all comments in advance :)

All the best!

Chris

Edit: "May" be related to the way PatchOperationSquence works, where all steps in a sequence are applied to a single XmlDocument (first failure aborts patch).