Page 1 of 1

Allow insert multiple items for entity.insert(items)

Posted: Fri Sep 20, 2019 7:27 pm
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 1320 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}}

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

Posted: Fri Sep 20, 2019 8:05 pm
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.

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

Posted: Fri Sep 20, 2019 8:43 pm
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

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

Posted: Sat Sep 21, 2019 6:02 am
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.

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

Posted: Sat Sep 21, 2019 6:46 am
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.