Ludeon Forums

Ludeon Forums

  • June 04, 2020, 01:18:15 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Craftable Bedrolls - new to modding, feedback wanted!  (Read 107 times)

lobz

  • Muffalo
  • *
  • Posts: 11
  • Refugee
    • View Profile
    • my github
Craftable Bedrolls - new to modding, feedback wanted!
« on: May 23, 2020, 09:02:39 PM »

Hey there, this is my first mod ever in anything, so I'd love to hear some feedback, know if I'm doing some bad practice or something.

What the mod does: makes bedrolls and double bedrolls a craftable item, made in crafting spots or tailor benches.

Why: I want to make a bunch of bedrolls to use in caravans, so using the crafting interface is way more confortable than building-and-then-uninstalling. Also it makes a lot more sense, immersion-wise, to sew a bedroll the same way you sew a shirt.

How: a xml file replacing the bedrolls thingdefs, adding a recipe. I set their category to Root as a way to make it not appear in the furniture tab and remove the "build copy" button. Can that have any unintended consequences?

Source: https://github.com/Lobz/CraftableBedrolls

A harmless doubt: how does it know what the bedroll can be made of? I couldn't find any xml tags saying what resources are valid or not, and yet it only allows fabric-like materials in the recipe.
Logged

LWM

  • Colonist
  • ***
  • Posts: 923
  • Little White Mouse
    • View Profile
Re: Craftable Bedrolls - new to modding, feedback wanted!
« Reply #1 on: May 23, 2020, 11:13:08 PM »

So....you're defining a 2nd copy of Bedroll (etc) with the idea of replacing the original bedroll.  But that has the problem that it doesn't play well with other modders.

The game is set up to allow XML modding via several operations involving xpath - a good reference is https://rimworldwiki.com/wiki/Modding_Tutorials/Modifying_defs

The thing you probably want to be doing is some patch operations - https://rimworldwiki.com/wiki/Modding_Tutorials/PatchOperations

The idea is you leave the original mod around and change only what you want to change.  In your case that would be...what, adding a recipe maker section to each?
Logged

lobz

  • Muffalo
  • *
  • Posts: 11
  • Refugee
    • View Profile
    • my github
Re: Craftable Bedrolls - new to modding, feedback wanted!
« Reply #2 on: May 25, 2020, 01:17:59 PM »

Thank-you so much! I was worried abt that but I had no idea how to do any different. Specially since I was making this mod as a way to test my skills before amking more complicated mods that definetly could create conflicts. I'll read the links you sent and come back here if I have trouble, ok?

In your case that would be...what, adding a recipe maker section to each?

Well, I also had to add "workToMake" (instead of "workToBuild") and "<designationCategory>Root</designationCategory>" so the game would stop adding the bedroll in the furniture tab and making it a buildable item (which I think it's probably bad practice but I have no idea how to do that differently). Either way it's just adding a bunch of lines to the thingDef so it should be simple once I learn how to do it
« Last Edit: May 25, 2020, 01:23:37 PM by lobz »
Logged

lobz

  • Muffalo
  • *
  • Posts: 11
  • Refugee
    • View Profile
    • my github
Re: Craftable Bedrolls - new to modding, feedback wanted!
« Reply #3 on: May 25, 2020, 02:43:16 PM »

ok read the links and tried to do the thing. Adding the recipe works fine, and I think the WorkToMake node is working? It's a bit weird because the value is 600 but when I check the work left to amke in the game it says 10. But at least this change seems to be in the base game as well.

I wish I could just replace the node with the value of WorkToBuild that's already there, that would be helpful since currently I have to patch the value for each thingdef like this:
Code: [Select]

<Operation Class="PatchOperationReplace">
    <xpath>Defs/ThingDef[defName="Bedroll"]/statBases/WorkToBuild</xpath>
    <value>
        <WorkToMake>600</WorkToMake>
    </value>
  </Operation>

Also, now I can't add the category for some reason? With a new def it was working fine but now it doesn't work at all. I wonder if it's because I'm superceding an inherited node? Is there a way to see what the final xml object is turning into? Should I go in the Help forum for this?

Edit: changed to a null category and it works just fine now:

Code: [Select]
  <Operation Class="PatchOperationAdd">
    <xpath>Defs/ThingDef[defName="Bedroll" or defName="BedrollDouble"]</xpath>
    <value>
      <designationCategory></designationCategory>
    </value>
  </Operation>

Also updated to 1.1 and publiched to steam.
« Last Edit: May 25, 2020, 06:30:03 PM by lobz »
Logged

LWM

  • Colonist
  • ***
  • Posts: 923
  • Little White Mouse
    • View Profile
Re: Craftable Bedrolls - new to modding, feedback wanted!
« Reply #4 on: May 26, 2020, 11:51:37 AM »

There's also
Code: [Select]
<designationCategory Inherit=false></designationCategory>
or
<designationCategory Inherit=false />
to keep it from being inherited from the parent Abstract def.  (capital "Inherit")

Remember to make sure your minified item can be installed and uninstalled with the changes you've made ;)

as far as being able to keep that 600 value...yeah...you can write custom C# patch operations to do that....but that's it.

Good work!
Logged

lobz

  • Muffalo
  • *
  • Posts: 11
  • Refugee
    • View Profile
    • my github
Re: Craftable Bedrolls - new to modding, feedback wanted!
« Reply #5 on: May 26, 2020, 02:48:03 PM »

There's also
Code: [Select]
<designationCategory Inherit=false></designationCategory>
or
<designationCategory Inherit=false />
to keep it from being inherited from the parent Abstract def.  (capital "Inherit")
Thanks for the tip! I'm trying this out, but it seems adding either of those makes the game crash on startup. Maybe it doesn't work with patches?

Quote
Remember to make sure your minified item can be installed and uninstalled with the changes you've made ;)
Sure thing! It's working fine.

Quote
as far as being able to keep that 600 value...yeah...you can write custom C# patch operations to do that....but that's it.
I feared as much... It seems kind of overkill for such a simple mod, doesn't it

Quote
Good work!
Thanks :)
Logged