[0.11.22] inventory.insert command ignores filters

Bugs that are actually features.
Post Reply
SigmatroN
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Sat Apr 26, 2014 8:31 am
Contact:

[0.11.22] inventory.insert command ignores filters

Post 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
Image

Rseding91
Factorio Staff
Factorio Staff
Posts: 13225
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.11.22] inventory.insert command ignores filters

Post 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.
Last edited by Rseding91 on Fri May 22, 2015 11:34 pm, edited 1 time in total.
If you want to get ahold of me I'm almost always on Discord.

SigmatroN
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Sat Apr 26, 2014 8:31 am
Contact:

Re: [0.11.22] inventory.insert command ignores filters

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13225
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.11.22] inventory.insert command ignores filters

Post 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).
If you want to get ahold of me I'm almost always on Discord.

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: [0.11.22] inventory.insert command ignores filters

Post 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.

Post Reply

Return to “Not a bug”