Underonesky
Underonesky

Reputation: 83

Screeps: Is there a way to set properties to a container?

I'm trying to set inventory filters for my container structures. I'm not sure how to write to a structures memory.

Upvotes: 1

Views: 186

Answers (1)

Alexej Haak
Alexej Haak

Reputation: 480

there only exists one Memory object "Memory"

if you have a room, for example, room.memory is just a shorthand for

Memory.rooms[roomName]

in the same way, you could create your own memory for containers like this:

let container = myContainer
if (!Memory.objects) Memory.objects = { }  // init memory
if !(container.id in Memory.objects) Memory.objects[container.id] = { }
let containerMemory = Memory.objects[container.id]

Upvotes: 4

Related Questions