Would like to make a new recipe. Done some research. Pls ELI5

Started by togfox, November 24, 2018, 07:39:37 PM

Previous topic - Next topic

togfox

I would like to use existing in-game art (slightly modified) to create new art using existing workbenches. I'm very comfortable with xml and inheritance etc and I've seen the examples on wiki and the step-by-step guide by Jecrell. Amazing resources all over the place but they all miss the high level workflow/approach needed to mod something in Rimworld and I think I just need some basic high-level guidance.

Context: making a new piece of art using a new ingredient (recipe) and the existing crafting table (in multiple stages)

Workflow from a players perspective:


  • Take existing vanilla game item
  • 'Butcher' it into a new recipe at the butcher table
  • Take new item to crafting table to turn new item into new artsy item

I assume I need

  • 2 new recipes
  • 1 new "bill" item for the butchers table
  • 1 new "bill" item for the craft table

This new art item will be rotatable (so there are four images/assets). Is that handled by xml as well or will that require coding?

Thx.







RDMJoker

Hello there,

the answer to your question is pretty quick.

You need 2 recipes that link to the existing crafting benches.
If you create a completely new item, you will have to define it in a ThingDef.

To make a recipe show up as a possible task in an existing crafting bench, add the following to the recipe:
Quote<recipeUsers>
  <li>[DefName of the bench you wanna use]</li>
</recipeUsers>

So the task in xml would basically be like:

  • Transforming existing vanilla art into new item. - This is a recipe
  • Having the new item - This needs to be a ThingDef
  • Transforming new item into new art item - This is a recipe
  • Having the new art item - This needs to be a ThingDef

If you have any more questions ask whatever you want.
I'm glad to help you, and would even create some examples for you :)

P.S: To answer the second quedstion: Yes, it is configured within the ThingDef of the item, whever it is rotatable or not. So it is .xml

Greetings
RDMJoker
For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.

togfox

This is great - thanks. I'll give this a shot with the workflow you suggest and I'll reach out for some quick pointers if I hit a roadblock.  :)

togfox

So my noob approach is to look at how the butcher spot does bills and added a new bill to that. Tick: successful.

I then looked at how kibble is 'done' in the xml. There is a recipe so I copied and adjusted that. Tick: successful.

The recipe results in a PRODUCT called 'kibble' so I made a new one of those. Tick: successful.

I'm now going to repeat that approach for the crafting table so my prawns can turn an animal carcass into an art item.

Question: I spent about an hour trying to work out how butchering a carcass results in x meat and y leather. I got stopped at the recipe where it produces a SPECIALPRODUCT called 'butchery'. Is this some arcane black magic because I really couldn't work that out.

Cheers.

RDMJoker

The thing with leather and meat is that it is produced dynamically when it is needed. Means: It is not defined in .xml but rather in the C# components and functions of the game. Therefore changing it requires you to go beyond .xml coding.

From what I've read in your first post I do not think you'll need to change how the leather and meat work, unless there is something special you want to achieve.

Just cause I like modding, Im going to sit down tomorrow and work together some basic stuff like you'r going to do, and post my workflow aswell, maybe it helps a bit.

Greetings
RDMJoker

For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.

togfox

I think a great resource would be an article/wiki/page/forum post that describes how the files link together.  I know this commmunity thinks in terms of thingdef's etc and that is technically correct, but for a first timer, my challenge was to work out

- which file defines the butchers spot
- where in that file defines the list of available bills
- how to define the recipe for that new bill
- how to define the result of that new recipe

For example, it took me a while to work out that 'make_kibble' bill in the butchers spot aligned with the recipe 'make_kibble' that defined the ingredients and something called PRODUCT and that the product 'kibble' aligned with the item called 'kibble' and then I realised that I had a texture called 'kibble' and that had to be in the right place.

I've yet to find a resource that shows how all these things interact and are linked up. A public resource that can make in-roads around this would be fantastic.  :)


togfox

So I've managed to butcher an animal and make a new animal item with it's own custom icon. Win!

I can add a new bill to the crafting table to turn my new animal item into my new art item.

The pawn will take my new animal item to the crafting table and start crafting but then I get a debug message:

Makething error: Tried to make UnfinishedNewAnimalItem from NewAnimalItem which is not a stuff. Assigning default.

I think the problem is I've taken a food item (which I copied from Kibble and changed) and tried to craft something from it and the crafting table goes "hey - that's not real stuff!".

Yes?

Is it possible to either:
a) enable the butchers spot/table to produce non-food items or
b) enable the crafting table to accept food items and turn into art?

I'm sure my new animal item needs this bit changed:
<ThingDef ParentName="OrganicProductBase">

This was copied from KIBBLE, which is organic food. My new animal item is not edible. It's not food. It's not to be treated like food. What thing should I inherit from?




RDMJoker

So I am now going to do this whole thing aswell and get back to you. I dont know why but it seems like you are doing it much more complicated then it needs to be.

Gonna get back to you soon. Still today evening tho.

Greetings
RDMJoker
For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.

RDMJoker

So im done. And it perfectly works, well my textures are terrible cause I just used paint to recolor beer but that doesn't affect the coding  ;D

So here is what I did basically it is pretty simple:

  • Created the mod directory with all the sub folders needed these are:

    • About
    • Defs

      • Misc
      • RecipeDefs
      • ThingDefs_Buildings
      • ThingDefs_Items
    • Textures and all it subfolders
  • I created the recipe for "Red Beer". You get it by "butchering" beer. Together with this i created the ThingDef Item "RedBeer" which we come back to next step
  • So the error you got is a result of the item used to create art not being under the "Stuff" categorie. So i added the Stuff categorie and all relevant stats to the ThingDef "RedBeer"
  • Then, for simplicity sake, i created a new Categorie Def called "SpecialArtBeer". Usually a art piece is created by one of the categories already in the game: "Metallic, Woody or Stoney"
  • Then I added the "RedBeer" to that categorie with one simple code line.  I got it from the Items_Recource_Stuff.xml from the core game.
  • Then i created the Art recipe with a slightly changed ParentDef to make it so only the red beer can be used to craft the blue beer, my new art piece. I basically took the Building_Art.xml as a guideline and changed the values. Removed everything that had to do with a recipe, cause I defined my own under RecipeDefs. You can include it in the ThingDef tho, just use RecipeMaker. You can see how that works in the original Buildings_Art.xml and alot of other .xml's in the core game.
I hope this is somewhat clear. If you have any questions, please ask.
I added my coding as a full mod in the attachments. You can check out all the files to see what I did and see the result ingame aswell.
Again, please ask if you have any questions. I'm more than happy to help! :)

Greetings
RDMJoker


[attachment deleted due to age]
For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.

togfox

This is great and the attachment will go a long way. I have made some in-roads bumbling about on my own but I'll see if I can unpack this and perhaps find my own way to give back to the next 'fresh' modder.  :)

Just by reading your post, I think I got to the same point but in a very round about fashion.

togfox

I've followed your example and I got a function mod. Pretty stoked about that.  :)

It's very basic, very poorly done, not production ready - but it's functional and works exactly as desired.

If you wouldn't mind taking a look (in a new save-game), there are some easy things and hard things I'd like to work out:

1) how to change the butcher table ingredient from a log to an animal corpse? Specifically a deer/doe/buck corpse?

2) when crafting a product at the crafting table, is it possible to disable the random "artys" description that comes with art items?

Thanks for this example. It should be preserved and documented somewhere!

rar file attached.

[attachment deleted due to age]

RDMJoker

Just settled down from work. Looking into your mod. Gonna change what you want to have changed, and what I can change for now, since im pretty exhausted. Gonna reply when Im done and explain what I did.

Greetings
RDMJoker
For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.

RDMJoker

So, didn't do a lot, since im so tired.

You can check the To-Do list, i added what I did in ####.

Gonna look into more stuff the coming days.

Greetings
RDMJoker

[attachment deleted due to age]
For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.

togfox

Not forgotten - been really busy doing 12 hour days etc.

RDMJoker

Same - not forgotten aswell.

But im too tired and exhausted to mod atm. Doing other stuff in the free time I have. Will look into it for sure once I feel comfortable with it.

For glory and mankind!
Check out my Mod Update Megathread if you have request for mod updates, patches, translations or mods.