Group group = ORK.Game.ActiveGroup;
List<CraftingRecipeShortcut> craftings = group.Leader.Inventory.Crafting.GetByCraftingType(0, false);
for(int i = 0; i < craftings.Count; i++){
CraftingRecipeShortcut cr = craftings[i];
ItemGain[] gains = cr.Setting.ingredient;
for(int j = 0; j < gains.Length; j++){
Debug.Log(" Ire Gains " + i + "-" + j + ":" + gains[j].GetName() + ", Q:" + gains[j].quantityValue.GetInfoText() + ":" + gains[j].quantityValue.GetValue(group.Leader, group.Leader) + ", Q2:" + gains[j].GetQuantity(group.Leader, group.Leader));
}
ItemGain[] outcomeGains = cr.Setting.outcome;
for (int j = 0; j < outcomeGains.Length; j++)
{
//bool isSuccess = outcomeGains[j].Add(group.Inventory, true, false, false);
}
if(cr.Setting.CanCreate(group.Leader)){
NotifyBool notifyBool = new NotifyBool(NotifyTest);
CraftingNotification notify = cr.Setting.finishedNotification;
cr.Setting.CreateItem(group.Leader, notifyBool);
}
}
can't find how to get the crafting result with outcomeGains.Add()
nor CreateItem()
. It looks like you're new here. If you want to get involved, click one of these buttons!
The quantity of the outcome (as well as what it actually is) is in the outcome settings of the recipe, which you already access in your code.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thanks for the reply but I can't get it work :(
Let's say I have ONE recipe which has two outcomes:
Outcome 0:
Quantity is set to Random 1~7.
Chance is set to 10.
Outcome 1:
Quantity is set to Random 3~9.
Chance is set to 50. The quantity number in Debug.Log didn't match the quantity of the items added to the Inventory bag.
What I want to do is after crafting, I can get the result and tell the users what and how many items they got.
You'd basically have to do the crafting manually using the settings if you want to get the items that where crafted. The CreateItem function to use a recipe handles all the crafting and putting the result into the inventory (and display notifications, etc.).
Alternatively, you could use a game event in your Outcomes settings, which will have access to all the items. You'd probably still have to write a custom node to get the information you want, though.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!