Screeps Wiki
Advertisement

The Memory object is a global where data can be stored over multiple game ticks. Between ticks, the data is stored as a JSON object.

For example:

Memory.hi = 'Hello world';

This will store 'Hello world' as Memory.hi and will still be available on game ticks later on.

Indirect access to the Memory object[]

Creep and Spawn objects have a memory property that have direct access to the Memory object.

`Memory.creeps.Creep1` is an alias of `Game.creeps.Creep1.memory`.

`Memory.spawn.Spawn1` is an alias of `Game.spawns.Spawn1.memory`.

Caveats to avoid when using the Memory object[]

Limited storage[]

Only json compatible data can be assigned to the memory object. Although the memory object itself can be modified as wish, it would cause errors when storing functions or objects with circular references.

JSON objects can store Objects (known for being used with the {} syntax), Arrays (which uses the [] syntax), Numbers (floats), Strings, Booleans (true or false) and `null`.

Advertisement