[Solved] How to insert an ammo to specific slot?

Place to get help with not working mods / modding interface.
Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

[Solved] How to insert an ammo to specific slot?

Post by Schallfalke »

How to insert an ammo to specific slot?
For example, I want something like if I put the submachine gun at gun slot 2, a stack of piercing bullets will be inserted to ammo slot 2. How can I do that?

Using LuaInventory::insert() does not work as desired, because it will always try to insert to slot 1 first.
Last edited by Schallfalke on Fri Mar 08, 2019 7:56 am, edited 1 time in total.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to insert an ammo to specific slot?

Post by DaveMcW »

Code: Select all

local inventory = player.get_inventory(defines.inventory.player_ammo)
inventory[2].set_stack({name="piercing-rounds-magazine", count=200})
Post Reply

Return to “Modding help”