[2.0.27] Surface.create_entitty / InventoryFilter API documentation

Place to report issues and suggest improvements to the API documentation.
kryojenik
Inserter
Inserter
Posts: 45
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: 1122
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
kryojenik
Inserter
Inserter
Posts: 45
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:
Post Reply

Return to “Documentation Improvement Requests”