Module raw_memory

Source
Expand description

Interface for Screeps RawMemory global object.

This is available as an alternative to the Memory object in the js heap, which itself is just a light wrapper around serializing into and deserializing JSON into RawMemory. String data stored can be retrieved after the running bot code is restarted (either by the server or by a new version of the code being uploaded) and decoded using serde or another option.

Also contains functions for accessing memory segments and other players’ active foreign segments.

Structs§

ForeignSegment
The data from another user’s foreign memory segment, which can be retrieved by foreign_segment, after being requested on the previous tick by set_active_foreign_segment.

Functions§

foreign_segment
Get the foreign memory segment belonging to another player requested last tick.
get
Get the stored serialized memory as a JsString.
segments
Get a JsHashMap<u8, String> with all of the segments requested on the previous tick, with segment numbers as keys and segment data in String form as values.
segments_jsstring
Get a JsHashMap<u8, JsString> with all of the segments requested on the previous tick, with segment numbers as keys and segment data in JsString form as values.
set
Overwrite the stored memory with a new JsString. Maximum allowed size MEMORY_SIZE_LIMIT UTF-16 units.
set_active_foreign_segment
Sets available foreign memory segment for the next tick to a memory segment marked as public by another user. If no id is passed, the user’s default public segment is retrieved.
set_active_segments
Sets available memory segments for the next tick, as an array of numbers from 0 to 99 (max of 10 segments allowed).
set_default_public_segment
Sets your default foreign memory segment for other players to read, or remove your public segment with None.
set_public_segments
Sets which of your memory segments are readable to other players as foreign segments, overriding previous settings.