Flag - Incorrect memory path



  • After creating a flag I cannot access it through memory, it shows as empty object:

    0_1539731100598_8e7f2b77-c2bd-402c-b5e1-eeb0c4e1e688-image.png

    Flag can be seen in game object but not in memory:

    0_1539730971138_4409d61f-910d-4989-af18-df893500e637-image.png

    After inspecting Memory object there are no flags are empty:

    0_1539731067549_886b8101-5cc0-41ba-b55b-cccbf8ab1fad-image.png

    How is it supposed to work? It seems as a bug



  • Its working as intended. Spawns and rooms act the same. The game doesnt automatically store information in memory that are already stored in game objects however it does create a space for it so that you can still use the memory.flags shorthand. It would just waste your allocated memory. That memory is for adding your own information to use in your own code



  • Unless you explicitly saved something in memory, of course it's empty 😉 Creeps are the exception to this (with the _move attribute), but all other default memory types are empty unless explicitly changed.

    Memory.flags.Flag1 exists because you created the flag, but the pos attribute you're trying to access doesn't exist unless you save it (which isn't useful, because you can always access a flag's pos regardless of vision).

    If you store something in your flag memory, you'll be able to access it.

    Flags don't have any purpose other than what you decide to use them for. For example people use them to place a "blueprint" of buildings in a room. The flag memory can then contain blueprintType: "extensions" or blueprintType: "bunker".

    Some other people use them to manage remote harvesting. The flag can have memory storing a threat level, if remote mining should be active or suspended, and possibly store paths from the associated spawn to the sources.

    They're very versatile, but usage completely depends on your own implementation! There's no real right or wrong, though certain things make more sense than others.



  • This is working as intended.

    Memory.flags.Flag1 is equivalent to Game.flags.Flag1.memory, not Game.flags.Flag1. You're accessing the flag's memory directly, instead of the object. If you want to save flag's pos in memory, you have to do it yourself, and then, it'll be stringified and to get the actual RoomPos object you'll need to re-create it from the string representation on your own.