[2.0.27] Surface.create_entitty / InventoryFilter API documentation
Posted: Thu Dec 19, 2024 4:24 pm
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:
It appears to be closer to (at least):
Or the create_entity{filters?=...} detail isn't correct?
This creates an inserter with a filter of iron-ore, any-quality:
You need the following for an inserter that does the default "normal" (none) quality:
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
Code: Select all
---@class InventoryFilter
---@field index uint
---@field name string(maybe ItemID)
---@field quality string(maybe QualityID)?
---@field comparator ComparatorString?
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"
}
}
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 = "="
}
}