memory problem,plz help me!



  • it seems the memory errors,spawns and rooms just disappear in the memory list. 0_1697849833161_EE33D555-3F30-4561-8FF1-5D4A25F79AE3.png I tried to insert RawMemory.set('{}') into console,but is seems does't work. can't find the creep,spawn,even the room,same codes shows diffierent results,plz help me!!0_1697850849210_C4DF40FD-311C-41d8-A577-168441D68D69.png



  • @chencreep incorret memory path,or can I just reset the memory?



  • I don't exactly understand your intention and what you are trying to achieve but here are some hints:

    You need to differentiate between the memory stored in the DB and your instance.
    What you see in the UI is whats stored in the DB, and only the snapshot when you loaded it into the UI.
    This should be at best viewed as a reference since it gets out of sync easily.
    Manipulating stuff in the UI is a good way to loose data.

    If you type RawMemory.set({}) you essentially wipe the DB memory every tick.

    RawMemory.set(function->string) governs how you safe stuff in the DB,
    it gets called every tick automatically after your main loop is done.

    On the flip side the Memory Object boils down to Memory = JSON.parse(RawMemory.get())
    when you access it for the first time in a tick.

    https://docs.screeps.com/global-objects.html#Memory-object

    So yeah you are wiping the DB which in turn wipes the Memory in your instance, hence chaos.

    But fear not, simply leave RawMemory alone in your code, refresh your code and everything should be recreated.
    Only fields that are set can be mirrored and refreshing your code is a good way to force that.



  • @chencreep you can recreate the missing properties with Memory.creeps={} and Memory.rooms={} and Memory.spawns={} In your main.js you can write if (!_.isPlainObject(Memory.rooms)) Memory.rooms = {}; for rooms, creeps, spawns to automatically fix issues like this.