Allow insert multiple items for entity.insert(items)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Allow insert multiple items for entity.insert(items)

Post by darkfrei »

By the LuaControl.insert and LuaInventory.insert you can find this information:
2019-09-20T21_20_04-Window.png
2019-09-20T21_20_04-Window.png (5.75 KiB) Viewed 1316 times
But works as insert (item) only:


Works:

Code: Select all

/c game.player.insert(item_stack)

Code: Select all

/c game.player.insert{name="iron-ore", count = 20}
Doesn't work, but must be allowed:

Code: Select all

/c game.player.insert{item_stack_1, item_stack_2}

Code: Select all

/c game.player.insert{{name="iron-ore", count = 20}, {name="copper-ore", count = 20}}
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Allow insert multiple items for entity.insert(items)

Post by Optera »

I think the plural items in this context means you can add an arbitrary count of item, not multiple different items.

If it allowed adding multiple item stacks the return value would need to change to item_stack as well so we know what was actually inserted.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Allow insert multiple items for entity.insert(items)

Post by eradicator »

That's a trivial function and you know it.

Code: Select all

local function insert(x,...)
  local c = {}
  for _,s in pairs{...} do c[#c+1] = x.insert(s) end
  return unpack(c)
  end
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.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Allow insert multiple items for entity.insert(items)

Post by Optera »

I'm not arguing if its possible, only what OP actually wants since I cant quite figure out if he wants to change description to be clear insert only allows adding a single stack or if he wanted it to accept multiple stacks.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Allow insert multiple items for entity.insert(items)

Post by eradicator »

Optera wrote: Sat Sep 21, 2019 6:02 am I'm not arguing if its possible, only what OP actually wants since I cant quite figure out if he wants to change description to be clear insert only allows adding a single stack or if he wanted it to accept multiple stacks.
Above post was not addressed at you ;). I saw the "original thread" where this came up, so i know this is not about the description.
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.
Post Reply

Return to “Modding interface requests”