As Arguments to API Methods

In addition to accepting standard optional arguments that modify some specific aspect of an API call, methods that return an array of objects (most notably find*() methods) accept a Lodash filter as an optional argument. While the example syntax provided by the game will not work in your Python code, only minor changes are needed to produce a similar result.

Examples

Finding all extensions in a room:

extensions = creep.room.find(FIND_STRUCTURES, {
    "filter": lambda s: 
        s.structureType == STRUCTURE_ROAD
})

Finding the closest dropped resource that meets a multiple criteria:

dropped_energy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {
    "filter": lambda r: 
        r.resourceType == RESOURCE_ENERGY and r.amount >= 100
    })

Last updated