1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Implemented CanStackItem hook (Rust)

Discussion in 'Feature Suggestions' started by Nimant, Oct 19, 2016.

  1. Nimant

    Nimant Plugin Developer

    Would it be possible to add hook CanStackItem ? I need to control stacking items. For example stack items with same skins and prevent stack with different skins. Also i want to stack items with same conditions.
  2. Norn

    Norn Plugin Developer

  3. Nimant

    Nimant Plugin Developer

    It is static param, but i need to control stack behaviour
  4. Norn

    Norn Plugin Developer

    So surely "OnItemStack" would be a much more useful hook
  5. Nimant

    Nimant Plugin Developer

    Name "OnItemStack" suppose control stacking items which already can stack. But items which have condition cannot stack anyway. Look at the screenshot:
  6. Fujikura

    Fujikura Plugin Developer

    Your request would'nt work properly, because the game itself would break what you want to achieve.
    Only there a hook would break more then it would bring a benefit.

    You did forget to have a look over the Split function.
    Split does'nt take care of skins or conditions, Thats why the game naturally blocks to stack skinned or canditioned items.
    Code (C#):
    // Item
    public Item SplitItem(int split_Amount)
        Assert.Test(split_Amount > 0, "split_Amount <= 0", null);
        if (split_Amount <= 0)
            return null;
        if (split_Amount >= this.amount)
            return null;
        object obj = Interface.CallHook("OnItemSplit", new object[]
        if (obj is Item)
            return (Item)obj;
        this.amount -= split_Amount;
        Item item = ItemManager.CreateByItemID(this.info.itemid, 1, 0);
        item.amount = split_Amount;
        item.AddOwners(this.owners, 1f);
        if (this.IsBlueprint())
            item.blueprintTarget = this.blueprintTarget;
        return item;
    It would in conclusion mean to always call 2 hooks for container actions, to maybe fullfil those needs.
    It is doubtful that this could be reached without game laggs.
    Norn likes this.
  7. Nimant

    Nimant Plugin Developer

    If puts hook in this place, game can't always break stack items with conditions. By the hook it will possible to allow stacks items with conditions:
    I intend to use OnItemSplit for smart split items which have conditons or skins. Look at my fragment of code:
  8. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Added CanStackItem(Item item, Item item) locally.
    Norn and Nimant like this.