Page 1 of 1

MoveItemToContainer() and stacking

Posted: Sun Oct 27, 2013 7:05 am
by xeon
I was thinking that in POL099 the MoveItemToContainer() was able to stack items automatically, but it seems I was wrong. Posting this to get some feedback if I am wrong or it's POL wrong :D

Suppose you have two bags. In the first you put 5000 goldcoins, and 100 goldcoins in the second.
Next you do a script like this:

Code: Select all

  
  var bag1 := target(who);
  var bag2 := target(who);
  
  foreach oItem in (EnumerateItemsInContainer(bag1, ENUMERATE_ROOT_ONLY))
    MoveItemToContainer(oItem, bag2);
  endforeach

If I put some print() inside the canInsert and onInsert scripts, I see that:
can_insert(): container=bag movetype=1 inserttype=1 adding_item=<appobj:ItemRef> existing_stack=<uninitialized object> amt_to_add=<uninitialized object>
can_insert(): returns 1

on_insert(): container=bag movetype=1 inserttype=1 adding_item=<appobj:ItemRef> existing_stack=<appobj:ItemRef> amt_to_add=5000
Shouldn't POL recognize an existing stack of the same objtype in the target container and try a MOVETYPE_COREMOVE (value 1) but with INSERT_INCREASE_STACK (value 2)? Instead it does a simple MOVETYPE_COREMOVE with INSERT_ADD_ITEM, so simply moving the item.

The net result is that the coins doesn't get stacked :)

If this is the correct behavior please tell me.