Search code examples
propertiescontainersstructurescreeps

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.


Solution

  • 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]