edited March 4 in ORK Scripting
Hi,
I'm making a crafting menu in script.
some crafting recipes have multiple outcomes, and some of the outcomes have random quantity and use chance, how can I get the crafting result/notification(success or failed, quantity,etc)?
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().
Post edited by bitmore on
  • The settings for the notifications are found in the inventory settings, i.e. you can access them via ORK.InventorySettings.notifications - e.g. ORK.InventorySettings.notifications.recipeFinished is for finishing crafting.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hi GiL,
    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.
    CraftingRecipeShortcut recipeShortcut = Here we get the recipeshortcut;
    ItemGain[] outcomeGains = recipeShortcut.Setting.outcome;
    for (int j = 0; j < outcomeGains.Length; j++)
    {
    Debug.Log(" Outcome Gains: " + outcomeGains[j].GetName() +
    ", Quantity:" + outcomeGains[j].GetQuantity(group.Leader, group.Leader) ;
    }
    recipeShortcut.Setting.CreateItem(group.Leader, notifyBool);
    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.
  • A Random value will be random for each calculation.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.