• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

How to change a recipe to yield two different items?

Yamamoto80

Refugee
Greetings. Hopefully this is the most appropriate place to drop this question....

What I would like to have happen (as the title implies) is to receive multiple different items back from a recipe. Using the example script below, I would like the game's output for this recipe to be "foodCornBread" as well as "drinkJarEmpty", so that I am effectively using the jar of water and getting the empty jar back.

<recipe name="foodCornBread" count="1" craft_area="campfire" craft_tool="toolCookingPot" tags="perkMasterChef,learnable">
    <ingredient name="foodCornMeal" count="1"/>
    <ingredient name="drinkJarBoiledWater" count="1"/>
</recipe>


Any ideas?

 
You're working with recipes. You have to visualize what happens in game when you're crafting anything that was defined by a recipe. You find it in the list of craftable items, select it and if you have enough ingredients, you can craft that item. You can also craft more than 1 item of the same type if you have enough materials in your inventory, but the game will never let you select more than one different items to craft at the same time using the same recipe. That should give you a hint of how exactly the recipes work and why and so there is also your answer - you can't do that, because the game doesn't work that way.

 
Last edited by a moderator:
From what i have read on the forums every crafting recipe can only have one output item.

"ingredient" btw is the oppsite of output. It is what you REQUIRE to craft something, not the output!

 
Hi Yamamoto80

If you only want to recover the drinkJarEmpty, better enable the option in items.xml in the foodCornBread item on this line and it should look like this:

<property name = "Create_item" value = "drinkJarEmpty" />

The jar will give it to you when you eat the foodCornBread, I hope that helps you.
Regards

 
Hi Yamamoto80

If you only want to recover the drinkJarEmpty, better enable the option in items.xml in the foodCornBread item on this line and it should look like this:

<property name = "Create_item" value = "drinkJarEmpty" />

The jar will give it to you when you eat the foodCornBread, I hope that helps you.
Regards
I was just going to suggest that. Any idea what happens if you then use foodCornBread as an ingredient for another recipe?

 
I was just going to suggest that. Any idea what happens if you then use foodCornBread as an ingredient for another recipe?
foodCornBread would be lost / used. If you're wondering whether it would give you the empty jar or not, the answer is no, it wouldn't.

 
Search items.xml for "openbundle" and you will find an item class that can be opened in your inventory. You could extend this to your own bundle so that a single recipe yields any number of items. This is how the "starter pack" mods work.

Not sure if it solves your problem but it offers some interesting possibilities 🤔 

 
Search items.xml for "openbundle" and you will find an item class that can be opened in your inventory. You could extend this to your own bundle so that a single recipe yields any number of items. This is how the "starter pack" mods work.

Not sure if it solves your problem but it offers some interesting possibilities 🤔 
An excellent suggestion with just one minor drawback. Bundle itself cannot be eaten. ;)

 
Search items.xml for "openbundle" and you will find an item class that can be opened in your inventory. You could extend this to your own bundle so that a single recipe yields any number of items. This is how the "starter pack" mods work.

Not sure if it solves your problem but it offers some interesting possibilities 🤔 


This is genius. You'd basically create a corn bread bundle item that, when opened, drops a cornbread and an empty jar. Relevant code below to save some searching:
 

<item name="ammoBundleMaster">
<property name="CreativeMode" value="None"/>
<property name="CustomIcon" value="ammo9mmBulletBall"/><property name="ItemTypeIcon" value="bundle"/>
<property name="DescriptionKey" value="ammoBundleGroupDesc"/>
<property name="HoldType" value="45"/>
<property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
<property name="Material" value="Mmetal"/>
<property name="Stacknumber" value="5"/> <!-- STK ammobundle -->
<property name="Weight" value="0"/>
<property name="EconomicValue" value="900"/>
<property name="Group" value="Ammo/Weapons"/>
<property name="UnlockedBy" value="perkPistolPeteComplete"/>
<property class="Action0">
<property name="Class" value="OpenBundle"/>
<property name="Delay" value="0"/>
<property name="Use_time" value="0"/>
<property name="Sound_start" value="close_garbage"/>
<property name="Create_item" value="ammo9mmBulletBall"/>
<property name="Create_item_count" value="100"/>
<!--
This can spawn multiple item types and quantities. No randomness.
<property name="Create_item" value="ammo9mmBulletBall,drinkCanRiverWater"/>
<property name="Create_item_count" value="50,5"/>
-->
</property>
</item>

<item name="foodBundlefoodCornBread">
<property name="Extends" value="ammoBundleMaster"/>
<property name="CustomIcon" value="foodCornBread"/>
<property name="Stacknumber" value="10"/> <!-- STK ammobundle high -->
<property name="EconomicValue" value="30"/>
<property class="Action0">
<property name="Create_item" value="foodCornBread,drinkJarEmpty"/>
</property>
</item>



Then just change the recipe for cornbread to the bundle.

I wonder if there's a way to globally do this for every recipe that takes a jar of water, because stews and such should also return the jar.

 

 
There are ways to use wildcards in XPath, but they are convoluted and i never use them.

I typically just remove the item in question and append it back in, unless other items extend from it.

 
Back
Top