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.
[Solved] How to insert an ammo to specific slot?
-
Schallfalke
- Fast Inserter

- Posts: 162
- Joined: Sun Oct 28, 2018 7:57 am
- Contact:
[Solved] How to insert an ammo to specific slot?
Last edited by Schallfalke on Fri Mar 08, 2019 7:56 am, edited 1 time in total.
Re: How to insert an ammo to specific slot?
Code: Select all
local inventory = player.get_inventory(defines.inventory.player_ammo)
inventory[2].set_stack({name="piercing-rounds-magazine", count=200})-
Schallfalke
- Fast Inserter

- Posts: 162
- Joined: Sun Oct 28, 2018 7:57 am
- Contact:
Re: [Solved] How to insert an ammo to specific slot?
You have my big thanks again!
The solution works like charm.
The solution works like charm.
