[2.0.27] Surface.create_entitty / InventoryFilter API documentation

kryojenik
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Fri Jun 26, 2020 8:18 pm
Contact:

[2.0.27] Surface.create_entitty / InventoryFilter API documentation

Post by kryojenik »

The surface.create_entity documentation indicates that the 'filters | request_filters' keys take a parameter of type 'array[InventoryFilter](?)' when the type is inserter, loader, or logistics-container.

logistics-container:
request_filters :: array[InventoryFilter]?

loaders:
filters :: array[InventoryFilter]?

Inserter:
filters :: array[InventoyrFilter] -- Should this also be optional? No error is thrown if it is omitted.

The documentation shows InventoryFilter effectively as:

Code: Select all

---@class InventoryFilter
---@field index uint
---@field name string
It appears to be closer to (at least):

Code: Select all

---@class InventoryFilter
---@field index uint
---@field name string(maybe ItemID)
---@field quality string(maybe QualityID)?
---@field comparator ComparatorString?
Or the create_entity{filters?=...} detail isn't correct?

This creates an inserter with a filter of iron-ore, any-quality:

Code: Select all

game.player.surface.create_entity{
  name = "inserter",
  position = {10,10},
  direction = 0,
  force = "player",
  filters = {
    index = 3,
    name = "iron-ore"
  }
}
You need the following for an inserter that does the default "normal" (none) quality:

Code: Select all

game.player.surface.create_entity{
  name = "inserter",
  position = {10,10},
  direction = 0,
  force = "player",
  filters = {
    index = 3,
    name = "iron-ore",
    quality = "normal",
    comparator = "="
  }
}
Last edited by kryojenik on Thu Dec 19, 2024 9:45 pm, edited 1 time in total.
robot256
Smart Inserter
Smart Inserter
Posts: 1336
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: 2.0.27 surface.create_entitty / InventoryFilter API documentation

Post by robot256 »

Good catch. FYI there is a separate subforum for documentation issues: viewforum.php?f=233
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
kryojenik
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Fri Jun 26, 2020 8:18 pm
Contact:

Re: 2.0.27 surface.create_entitty / InventoryFilter API documentation

Post by kryojenik »

robot256 wrote: Thu Dec 19, 2024 5:55 pm Good catch. FYI there is a separate subforum for documentation issues: viewforum.php?f=233
Bah, yeah, this should go there then. I figured there had to be. I was looking in the wrong parent. :oops:
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 336
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: [2.0.27] Surface.create_entitty / InventoryFilter API documentation

Post by Therenas »

Thanks for the report, this is fixed for the next release.
Post Reply

Return to “Resolved Requests”