Allow assigning to memory on all creation functions



  • I was unable to assign any memory to flags I've created in my code because they are created in a following tick. Creation functions:

    createFlag()
    createConstructionSite()

    should mimic the optional memory assignment found in

    createCreep()

    Also createFlag() returns the flag name instead of 0 on a success which differs from what is in the docs, not to mention is just plain weird.


  • Dev Team

    The documentation is fixed, thank you for reporting.

    You can assign memory in the same tick using the returned name value like this:

    var flagName = room.createFlag(10, 10, undefined, COLOR_RED);
    Memory.flags[flagName] = {type: 'attack'};
    

    flag.memory.type will be available in the following tick when the flag is created.