Flag - Incorrect memory path
-
After creating a flag I cannot access it through memory, it shows as empty object:
Flag can be seen in game object but not in memory:
After inspecting
Memory
object there are no flags are empty: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 thepos
attribute you're trying to access doesn't exist unless you save it (which isn't useful, because you can always access a flag'spos
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"
orblueprintType: "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 toGame.flags.Flag1.memory
, notGame.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 actualRoomPos
object you'll need to re-create it from the string representation on your own.