Page 1 of 1

[2.0.27] Surface.create_entitty / InventoryFilter API documentation

Posted: Thu Dec 19, 2024 4:24 pm
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 = "="
  }
}

Re: 2.0.27 surface.create_entitty / InventoryFilter API documentation

Posted: Thu Dec 19, 2024 5:55 pm
by robot256
Good catch. FYI there is a separate subforum for documentation issues: viewforum.php?f=233

Re: 2.0.27 surface.create_entitty / InventoryFilter API documentation

Posted: Thu Dec 19, 2024 6:10 pm
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: