Find Methods

From Screeps Wiki
Revision as of 22:33, 11 December 2016 by SemperRabbit (talk | contribs) (Created page with "Find methods, along with look methods are the primary way to get in-game objects. They are split up into two types. One type is using the find methods available in the Roo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Find methods, along with look methods are the primary way to get in-game objects. They are split up into two types. One type is using the find methods available in the Room object, and the other type is by using RoomPosition methods.

Find methods in the Room object

Find methods of the Room object will return an array of values or an integer error value, depending on the specific method. It is recommended to check the API prior to using them. Links to the method in the API are provided by clicking on the appropriate method below.

room.find()

[|Room.find()] find method will return an array of objects that meet the specifications passed in the arguments. It can be passed a FIND_* constant, and has and optional filter argument.

room.findExitTo()

[| room.findExitTo()] will return an array of directional exit constants (e.g. FIND_EXIT_TOP) or an integer erro value if there is no path or you pass an invalid argument. This is typically used in conjunction with another find method to get specific RoomPositions matching the returned exit constants.

room.findPathTo()