Page 1 of 1
[0.11.22] inventory.insert command ignores filters
Posted: Fri May 22, 2015 11:00 am
by SigmatroN
1. Select any recipe for an assembling machine
2. Insert item directly into it's inventory: /c game.players[1].selected.getinventory(2).insert({name = "iron-plate",count = 1})
3. The item inserted into the first slot, regardless of the recipe filters
Re: [0.11.22] inventory.insert command ignores filters
Posted: Fri May 22, 2015 10:57 pm
by Rseding91
The inventory slots of a crafting machine aren't restricted to what can be put in them. - nevermind that - You can manually put items in the wrong slots as well.
Not really sure if that's a bug or not. If you call entity.insert() it will put it in the correct slots for the recipe.
Re: [0.11.22] inventory.insert command ignores filters
Posted: Fri May 22, 2015 11:17 pm
by SigmatroN
I just have tried to manually put item into this exact slot, and it said: Only electronic circuit can be inserted here, not Iron Plate.
As about entity.insert(), I'm aware of it.
Re: [0.11.22] inventory.insert command ignores filters
Posted: Fri May 22, 2015 11:33 pm
by Rseding91
SigmatroN wrote:I just have tried to manually put item into this exact slot, and it said: Only electronic circuit can be inserted here, not Iron Plate.
As about entity.insert(), I'm aware of it.
You're correct. I was thinking of filtered inventory slots (the hotbar and train inventory).
Re: [0.11.22] inventory.insert command ignores filters
Posted: Thu Jun 04, 2015 1:59 pm
by slpwnd
Assembling machine contains regular inventory. The inventory itself doesn't know about filters. The filtering logic is done by assembling machine code.
Code: Select all
2. Insert item directly into it's inventory: /c game.players[1].selected.getinventory(2).insert({name = "iron-plate",count = 1})
This way you are manipulating the inventory directly. Hence the filters are not applied.
Safer and generally recommended solution is to work with the entity directly:
Code: Select all
/c game.players[1].insert({name = "iron-plate",count = 1})
This works as expected putting the item to the correct place. This uses the same mechanism the inserter would use when inserting into assembling machine.