luaItemStack.set_stack() clear stack option

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

luaItemStack.set_stack() clear stack option

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: luaItemStack.set_stack() clear stack option

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: luaItemStack.set_stack() clear stack option

Post 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. :roll:
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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: luaItemStack.set_stack() clear stack option

Post 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. :roll:
That's how it works. The target is the LuaItemStack.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”