Page 1 of 1

SplitStackInto

Posted: Mon Feb 11, 2013 4:17 am
by RusseL
Hello,

I've tried to use item.SplitStackInto (container, amnt), but it doesn't work at all for me.
I get everytime the same message "Could not add new stack to container", and "amnt" of this item disappear.
What is wrong?
I need this function for scripted merchant handlers... for example I don't know how can i subtract 10 reagents from a merchants sell list and move them to characters backpack:)

rev 605 from svn.

Re: SplitStackInto

Posted: Mon Feb 11, 2013 10:11 am
by RusseL
Second bug:
if i have a stack of more than 10 items, and use s_tack.SplitStackInto(me.backpack, 10, 0) on it - i get "Could not add new stack to container", and 10 items from this stack disappear
If i have a stack of 10 items, and use s_tack.SplitStackInto(me.backpack, 10, 0) on it - i get "Could not add new stack to container", but stack remains.

Third bug:
item must be updated after SplitStackInto was used.
1.jpg

Re: SplitStackInto

Posted: Tue Feb 12, 2013 6:57 am
by Terciob
tested on last rev 621, bugs confirmed.

Re: SplitStackInto

Posted: Wed Feb 13, 2013 12:52 am
by xeon
Container is locked?
Are you holding the item in your "hands" (drag)?
Try to do a ReserveItem() on both container and item, checking also its return code to be sure to have reserved the objects to the script.

Re: SplitStackInto

Posted: Wed Feb 13, 2013 2:40 am
by RusseL
xeon wrote:Container is locked?
Are you holding the item in your "hands" (drag)?
Try to do a ReserveItem() on both container and item, checking also its return code to be sure to have reserved the objects to the script.
No.
No.
No.
;)

Re: SplitStackInto

Posted: Tue Feb 26, 2013 5:43 pm
by kevin
all three of those bugs should be fixed with rev 625 using this script to test:

Code: Select all

use uo;

program test(who)
    var item, res;

    item := CreateItemAtLocation(who.x,who.y,who.z, 0xeed, 1000);
    res := item.SplitStackInto(who.backpack,1000,1);
    print("Result 1: "+res);

    item := CreateItemAtLocation(who.x,who.y,who.z, 0xeed, 1000);
    res := item.SplitStackInto(who.backpack,500,1);
    print("Result 2: "+res);

    item := CreateItemAtLocation(who.x,who.y,who.z, 0xeed, 1000);
    res := item.SplitStackInto(who.backpack,1000);
    print("Result 3: "+res);

    item := CreateItemAtLocation(who.x,who.y,who.z, 0xeed, 60000);
    res := item.SplitStackInto(who.backpack,59000);
    res := item.SplitStackInto(who.backpack,1000);
    print("Result 4: "+res);
endprogram
Results:
one stack of 3.5k in backpack from SplitStackInto() calls #1,2,3,5 ; one stack of 59k in backpack from call #4, one stack of 500 on ground from call #2

Re: SplitStackInto

Posted: Tue Mar 05, 2013 9:18 am
by RusseL
another bug - try to use SplitStackInto(me.backpack, 1)); at non-stackable item ;)

Re: SplitStackInto

Posted: Sun Apr 14, 2013 2:22 pm
by RusseL
up! fix it please!

Re: SplitStackInto

Posted: Tue Sep 17, 2013 12:15 pm
by Tomi
Fixed in the last revision

Re: SplitStackInto One more bug

Posted: Mon May 05, 2014 2:00 pm
by RusseL
Here we go again.
Same story with SplitStackAt
SplitStackAt(x,y,z,realm,amount) bug demo
SplitStackAt(x,y,z,realm,amount) bug demo

Re: SplitStackInto

Posted: Tue May 06, 2014 5:38 am
by Tomi
I added some missing updaters to SplitStackAt method in the last revision
I tested this with a simple cmd

Code: Select all

var stack_i := CreateItemInInventory( character.backpack, 0x1f14, 100 );

stack_i.SplitStackAt( character.x, character.y, character.z, character.realm, 10 );
Working correctly for me ( did not give a try before the changes I made, but if it still doesnt work for you, check that you tiledata and tiles.cfg are correct because its looking from there if the item is stackable

Re: SplitStackInto

Posted: Fri May 09, 2014 3:06 am
by RusseL
Thanks Tomi, looks like it works properly now