Is xpathing extremely important?

Started by Piratax10, April 20, 2019, 07:08:25 PM

Previous topic - Next topic

Piratax10

I am new to modding and programming in general (and the forums e.e), and i am trying to make my first mod (it actually is going pretty well).

but then i heard about xpathing, and that it is used to make patches and such stuff...
(warning, i may be asking pretty dumb questions.)
yet i don't know why should i use it, isn't it easier to just change a part of the code manually?

should i redo my mod because i didn't use it to change some values, such as damage?

or am i just outdated and it was just required on past versions like A17?

Thanks!
The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089

Napoleonite

I am new myself but from what I understand:

1. Overwritten stuff with XML = bad because it can conflict with other mods. Adding new stuff with XML however is not a problem.
2. Using XPath, if done properly, will virtually never (or never at all) conflict with other mods.

So yes XPath is very important if you use more mods or intent on sharing it with other players.

LWM

RimWorld has a built-in mod system that uses xpath technology to let you specify part of the XML tree to replace/add to/delete/etc.  It makes it fairly easy to make changes to the XML and then share them with other people.

If you are making a mod for only yourself, you can do whatever, but if you want to share it...if you change the XML, how can you do that?  The system is set up so you can publish a series of xpath patches and then anyone can use them.

I don't even know how else you would do it?  If two people want to change two parts of a weapon's definition (one how much damage it does, one the graphic), they are both affecting the same XML file.  So a 3rd person can't just use their XML, because one will wipe out the other's changes - the graphic change would specify the original damage, etc.

But again, if you don't want to share your modding with others...you can do whatever you want ;)

--LWM

PS - it's still quite easy for xml patching to step on others' toes: one mod may make a change to one part of a weapon...and another mod may remove that weapon entirely.  If they happen in the wrong order, the mod that changes the definition will be very unhappy because it cannot find the weapon.

It just means they can both touch the same file/definition in general.

Canute

QuoteI don't even know how else you would do it?  If two people want to change two parts of a weapon's definition (one how much damage it does, one the graphic), they are both affecting the same XML file.  So a 3rd person can't just use their XML, because one will wipe out the other's changes - the graphic change would specify the original damage, etc.
That was the common pratice at the past before ludeon implement the xpath system.
At these time, the modload order was very important. Today the modload order is negligible.


Piratax10

#4
well, i want to share my mod with other people, so i have a question:

do you think this tutorial is still functional? https://ludeon.com/forums/index.php?topic=32785.0

also i have edited the damage and such stats on my mod before, do you think copy-pasting or even doing a patch would save it from conflicts?


The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089

Shinzy

Quote from: Piratax10 on April 21, 2019, 11:18:38 AM
well, i want to share my mod with other people, so i have a question:

do you think this tutorial is still functional? https://ludeon.com/forums/index.php?topic=32785.0

also i have edited the damage and such stats on my mod before, do you think copy-pasting or even doing a patch would save it from conflicts?

The tutorial is still very functional
changing stats won't cause any conflicts unless you're changing any vanilla stuff or things from other mods, in which case you will need to make a patch

Piratax10

Quote from: Shinzy on April 21, 2019, 04:29:53 PM
Quote from: Piratax10 on April 21, 2019, 11:18:38 AM
well, i want to share my mod with other people, so i have a question:

do you think this tutorial is still functional? https://ludeon.com/forums/index.php?topic=32785.0

also i have edited the damage and such stats on my mod before, do you think copy-pasting or even doing a patch would save it from conflicts?

The tutorial is still very functional
changing stats won't cause any conflicts unless you're changing any vanilla stuff or things from other mods, in which case you will need to make a patch

So, i should only use xpath when i am modifying vanilla and other people's mod? That's it?
The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089

LWM

Quote from: Piratax10 on April 21, 2019, 06:02:22 PM
So, i should only use xpath when i am modifying vanilla and other people's mod? That's it?

I would say rather:

You *should* use xpath when
  • There is some XML already loaded in the game (either vanilla or some mod)
  • You want to change the value of that XML

    So maybe you have a mod that adds XML for Zebras, with a really scary graphic.  You don't need any xpath for that.

    But suppose you want to make sniper rifles super long range so you can hunt them from across the map.  Sniper rifles have a def in the XML, so using xpath is a good idea.

    Now suppose that if someone is also playing with the SuperPoweredWeapon mod, you want the graphic of your Zebra to be small and really cute instead, so no one shoots it.  Then you would use xpath (and the proper patch operations) to change the graphic of the Zebra def (of your own mod).

    Does that make sense?

    You could also describe what you're trying to do with your mod ^.^

    --LWM

Piratax10

#8
Quote from: Piratax10 on April 22, 2019, 04:23:13 PM
Quote from: LWM on April 22, 2019, 03:19:23 AM
Quote from: Piratax10 on April 21, 2019, 06:02:22 PM
So, i should only use xpath when i am modifying vanilla and other people's mod? That's it?

I would say rather:

You *should* use xpath when
  • There is some XML already loaded in the game (either vanilla or some mod)
  • You want to change the value of that XML

    So maybe you have a mod that adds XML for Zebras, with a really scary graphic.  You don't need any xpath for that.

    But suppose you want to make sniper rifles super long range so you can hunt them from across the map.  Sniper rifles have a def in the XML, so using xpath is a good idea.

    Now suppose that if someone is also playing with the SuperPoweredWeapon mod, you want the graphic of your Zebra to be small and really cute instead, so no one shoots it.  Then you would use xpath (and the proper patch operations) to change the graphic of the Zebra def (of your own mod).

    Does that make sense?

    You could also describe what you're trying to do with your mod ^.^

    --LWM
Well, i am trying to do a weapons pack that may evolve into a series of mods.

so... there is no issue with changing the stats as Shinzy stated, but i didn't mention this: i did change the graphics of my gun and bullet because their sizes were wrong, plus i have changed the format of the sound (it wasn't working before), and i didn't use any xpath at all, and you told me that using xml would be a good idea when changing the graphics.

without the xml, is it going to cause any issues? (remember, i am going to share this mod) again (if you did answer yes), should i copy the code and re-make the mod? or patching should fix it?

i think those are my last questions for now (i hope).
The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089

LWM

Quote from: Piratax10 on April 22, 2019, 04:23:13 PM
without the xml, is it going to cause any issues? again (if you did answer yes), should i copy the code and re-make the mod? or patching should fix it?

As a friend of mine is wont to say: "aaaaaaaaaaahhhh....."  You may have lost me.

What... Um...  How are you structuring this mod?  Have you seen https://rimworldwiki.com/wiki/Modding#Mod_file_structure ?  (It's not the clearest explanation available, but gives a good idea of what works well)  Are you matching that sort of mod structure?

--LWM

Piratax10

#10
i didn't read the wiki tutorials, i did watch a video tutorial and looked inside other mods.

well, this is how my mod is structured, i will mark a X on extra folders/files i didn't put and may need later, and i will delete the ones that look useless.

┌About
├─About.xml
├─Preview.png (X) [going to make one later]

├Defs
├┬ThingDefs (X) [the files below are inside of the defs folder though]
│├─ThingsDef.xml
│└─SoundDef.xml

├Sounds
├┬Guns
│└─C-01rShot.ogg

├Patches (X)
├─MyPatch.xml (X)

├Languages (X) [going to do later]

├Textures
├┬Things
│├─Projectile
│ └─C-01rBullet.png
│└─Weapons
│ └─AssaultRifleC-01r.png
The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089

LWM

So what part of the base game does your mod change?

Piratax10

#12
None, as i said previously, i am making a weapons pack.

So, as long as it doesn't edit anything from vanilla or another person's mod, i don't need to use any xpath at all, right?

Quote
without the xml, is it going to cause any issues? again (if you did answer yes), should i copy the code and re-make the mod? or patching should fix it?

*xpath, not xml, *facepalms* lol
The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089

LWM

Quote from: Piratax10 on April 24, 2019, 11:43:31 AM
None, as i said previously, i am making a weapons pack.

So, as long as it doesn't edit anything from vanilla or another person's mod, i don't need to use any xpath at all, right?

I'm not even sure how you CAN?  But yeah, if your mod is only adding content, it shouldn't have any xml files in the Patch directory, because you (that is, the mod) isn't changing anything.  If you realize you need to change something in your mod, you just change the files and RimWorld picks up the changes the next time it starts.  If you're sharing on Steam, you will need to go to the Mods page and Update your mod (it's one of the buttons :p) to push the changes out to other users.

Xpath patching is a modding practice for modifying an aspect of the game, as opposed to workflow for changing a mod.  I guess we say "change" for both cases :p

--LWM

Piratax10

Quote from: LWM on April 24, 2019, 10:41:45 PM
Quote from: Piratax10 on April 24, 2019, 11:43:31 AM
None, as i said previously, i am making a weapons pack.

So, as long as it doesn't edit anything from vanilla or another person's mod, i don't need to use any xpath at all, right?

I'm not even sure how you CAN?  But yeah, if your mod is only adding content, it shouldn't have any xml files in the Patch directory, because you (that is, the mod) isn't changing anything.  If you realize you need to change something in your mod, you just change the files and RimWorld picks up the changes the next time it starts.  If you're sharing on Steam, you will need to go to the Mods page and Update your mod (it's one of the buttons :p) to push the changes out to other users.

Xpath patching is a modding practice for modifying an aspect of the game, as opposed to workflow for changing a mod.  I guess we say "change" for both cases :p

--LWM

Many thanks for the help!  ;D
The first and only.

My Mods:
Plazma Burst 2 Weapons Pack: https://ludeon.com/forums/index.php?topic=48663.msg458089#msg458089