ARENA · SPAWNING API

How to Use StructureSpawn.spawnCreep() in Screeps Arena

Verification statusArticle origin: Original English guide — no translated source article · Official Arena docs: Checked — StructureSpawn.spawnCreep(body), getObjectsByPrototype(), body limits, result shape, and documented errors · API boundary: Checked — Arena syntax and result shape kept separate from Screeps MMO spawnCreep()

VERIFICATION

Evidence and test status

Article origin
Original English guide — no translated source article
Official Arena docs
Checked — StructureSpawn.spawnCreep(body), getObjectsByPrototype(), body limits, result shape, and documented errors
API boundary
Checked — Arena syntax and result shape kept separate from Screeps MMO spawnCreep()
Code review
Passed — examples use Arena game/utils and game/prototypes imports
Screeps Arena runtime test
Pending — no Arena runtime execution is claimed
Last verified
September 11, 2026

Quick answer

In Screeps Arena, first find your owned StructureSpawn with getObjectsByPrototype(StructureSpawn). Then call spawn.spawnCreep(body). Arena documents a result object with either an object field for the newly spawning Creep or an error field for a numeric error code.

Do not copy the Screeps MMO signature into Arena: the Arena method is spawnCreep(body), not the MMO-style spawnCreep(body, name, opts).

import { getObjectsByPrototype } from 'game/utils';
import { StructureSpawn } from 'game/prototypes';
import { WORK, CARRY, MOVE } from 'game/constants';

const spawn = getObjectsByPrototype(StructureSpawn).find(s => s.my);

if (spawn) {
  const result = spawn.spawnCreep([WORK, CARRY, MOVE]);

  if (result.object) {
    console.log('Spawning creep:', result.object.id);
  } else {
    console.log('spawnCreep error:', result.error);
  }
}

Start with the minimal Arena example

The important Arena pieces are the imports, the owned-Spawn lookup, a body array, and the returned result object. Keep those visible before adding role logic or combat strategy.

The official Arena API documents a body array with 1 to 50 body-part constants. For a simple worker-shaped example, [WORK, CARRY, MOVE] keeps the spawning call easy to inspect.

Find your owned Spawn with getObjectsByPrototype()

Arena code does not start from the MMO Game.spawns pattern. Import getObjectsByPrototype from game/utils, import StructureSpawn from game/prototypes, then select the Spawn whose my property is true:

import { getObjectsByPrototype } from 'game/utils';
import { StructureSpawn } from 'game/prototypes';

const mySpawn = getObjectsByPrototype(StructureSpawn).find(spawn => spawn.my);

if (!mySpawn) {
  console.log('No owned StructureSpawn found');
}

Keeping the ownership check explicit prevents your spawning logic from silently operating on the wrong object when a prototype query returns more than one result.

Read the object-or-error result

The Arena contract is easiest to handle as two branches. A successful result exposes the newly spawning Creep through result.object. A failed call exposes a numeric code through result.error.

const result = mySpawn.spawnCreep([WORK, CARRY, MOVE]);

if (result.error !== undefined) {
  console.log('spawn failed:', result.error);
} else if (result.object) {
  console.log('spawn accepted for creep:', result.object.id);
}

This page does not claim a live Arena runtime test. The example follows the current documented API shape; verify behavior in your own Arena match when exact runtime state matters.

Read the documented Arena spawn errors

The current Arena documentation lists these StructureSpawn.spawnCreep() errors:

ErrorMeaning to check
ERR_NOT_OWNER (-1)The Spawn is not yours.
ERR_BUSY (-4)The Spawn is already spawning another Creep.
ERR_NOT_ENOUGH_ENERGY (-6)The Spawn and eligible nearby extensions cannot supply enough Energy for the body.
ERR_INVALID_ARGS (-10)The submitted body arguments are invalid.

Preserve the exact error code while debugging. Four distinct failures should not be collapsed into one generic “spawn failed” state.

Do not mix Arena and MMO spawnCreep() syntax

Screeps Arena and Screeps MMO both expose a StructureSpawn.spawnCreep() name, but the documented interfaces are not interchangeable.

ProductCall shape used by this siteResult handling
Screeps Arenaspawn.spawnCreep(body)Read result.object or result.error.
Screeps MMOspawn.spawnCreep(body, name, opts)Use the MMO return-code contract and later spawning state.

If you are writing persistent-world MMO code, use the dedicated Screeps MMO spawnCreep() guide instead. Keeping the product name in your search and in your own notes prevents examples from the two APIs from being mixed accidentally.

Debug an Arena spawn call in the right order

  1. Confirm the product. Make sure the example is for Screeps Arena, not MMO.
  2. Confirm the imports. Resolve getObjectsByPrototype, StructureSpawn, and the body constants from Arena modules.
  3. Confirm ownership. Ensure the selected Spawn has my === true.
  4. Inspect whether the Spawn is busy. A busy Spawn can return ERR_BUSY.
  5. Validate the body. Keep the body within the documented part-count boundary and use valid body-part constants.
  6. Check available Energy. An otherwise valid body can still return ERR_NOT_ENOUGH_ENERGY.
  7. Log the exact result branch. Record result.error or the identity from result.object.

FAQ

Why does an MMO spawnCreep() example fail in Arena?

The products document different method signatures and different result shapes. In Arena, start from the Arena modules and spawnCreep(body) rather than adding an MMO Creep name or options object.

Should I hard-code the first StructureSpawn returned?

Prefer an explicit ownership predicate such as .find(spawn => spawn.my). It makes the intent clear and avoids assuming the first prototype result is yours.

Does result.object prove the Creep has finished spawning?

No claim of completed spawning is needed here. Treat the returned object as the newly spawning Creep reference described by the Arena API and inspect current match state when later behavior matters.

Official documentation

This guide was checked against the official Screeps Arena API documentation, specifically StructureSpawn.spawnCreep(), getObjectsByPrototype(), Arena prototypes, and body constants.

SOURCE AND SCOPE

Review the evidence or continue the system

This is an original English guide. Its verification record separates documentation-reviewed claims from Console or live-shard observations that have not been performed.