screeps-starter-python
1.0.0
1.0.0
  • Introduction
  • Logistics
    • Setup
    • Upgrading Transcrypt
  • Screeps API Usage
    • Constants
    • Optional Arguments
    • Objects - Basic Interaction
    • Objects - Creation and the Keyword "new"
  • Features
    • Console Commands
  • Lodash
    • Introduction
    • As Arguments to API Methods
  • Syntax Changes
    • Summary
    • in Opperator
    • List Behavior
    • del Operator
    • dict Iteration
Powered by GitBook
On this page

Was this helpful?

  1. Screeps API Usage

Constants

PreviousUpgrading TranscryptNextOptional Arguments

Last updated 4 years ago

Was this helpful?

Screeps provides a number of that hold references to everything from error codes to in-game resources. The constants themselves either store some kind of value (like a string or integer) or are a reference to data structures like arrays and objects. Some constants are provided for conveince while others are required for some API calls.

Unlike optional named arguments, constants should be provided as is; constants are always uppercase with individual words seperated by underscores.

Examples

Defining a creep's part list:

harvester_parts = [WORK, MOVE, CARRY]

Referencing a resource and checking for an error code:

if creep.withdraw(creep.room.storage, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE:
    creep.moveTo(creep.room.storage)
constants