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
luaItemStack.set_stack() clear stack option
Re: luaItemStack.set_stack() clear stack option
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.
I think that better handles what you're trying to do here? Let me know if not.
If you want to get ahold of me I'm almost always on Discord.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: luaItemStack.set_stack() clear stack option
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)
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: luaItemStack.set_stack() clear stack option
That's how it works. The target is the LuaItemStack.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.
If you want to get ahold of me I'm almost always on Discord.