Page 1 of 1
luaItemStack.set_stack() clear stack option
Posted: Fri Apr 28, 2017 5:12 am
by Nexela
Can it be made so luaItemStack.set_stack() can take a bool paramater that will clear the passed stack if was it successfully set to the new stack and the passed stack was an luaItemStack?
stack.set_stack(found_stack, true)
Would return true if set successfully and call .clear on the passed stack
Re: luaItemStack.set_stack() clear stack option
Posted: Sat Oct 07, 2017 1:29 am
by Rseding91
I added a new function for 0.16 called transfer_stack that will take a LuaItemStack or SimpleItemStack and attempt to transfer it into the destination (instead of copy like set_stack does).
I think that better handles what you're trying to do here? Let me know if not.
Re: luaItemStack.set_stack() clear stack option
Posted: Sat Oct 07, 2017 5:22 am
by eradicator
Does transfer_stack also handle partial transfers? I.e. when i try to transfer 50 items into an inventory that can only hold 30? That would be pretty neat. The expected result for me would be that the old stack is now 20 and the transferred-to-inventory is full. Hm...wait, what is the target type of transfer_stack, inventories, stacks or both? Both would be maximum neat.
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
Re: luaItemStack.set_stack() clear stack option
Posted: Sat Oct 07, 2017 5:57 am
by Rseding91
eradicator wrote:Does transfer_stack also handle partial transfers? I.e. when i try to transfer 50 items into an inventory that can only hold 30? That would be pretty neat. The expected result for me would be that the old stack is now 20 and the transferred-to-inventory is full. Hm...wait, what is the target type of transfer_stack, inventories, stacks or both? Both would be maximum neat.
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
That's how it works. The target is the LuaItemStack.