I had similar problems with RawMemory - looks like it's not supported as well as Memory object which is very easy to use:
http://screeps.com/forum/topic/944/Working-with-raw-memory-changing-memory-via-console-UI
I had similar problems with RawMemory - looks like it's not supported as well as Memory object which is very easy to use:
http://screeps.com/forum/topic/944/Working-with-raw-memory-changing-memory-via-console-UI
Is it possible to execute custom memory parsing in the same moment it happens for default one?
Right now, I can only call it in main(), but there are things that access/change memory before/after main (such as console commands).
Context:
I want to use slightly different parsing for objects in memory. It boils down to calling JSON.parse(serialized, reviver), but there is no way I can provide those functions to default serializer.
So instead, I changed main to look like this:
module.exports.loop = function () {
var result = JSON.parse(RawMemory.get(), reviver);
Object.assign(Memory, result); // this will overwrite values from Memory
// do actual work...
RawMemory.set(JSON.stringify(Memory, replacer)); // write changes to memory
}
However, when I run commands in console/change memory via UI, it doesn't work. It's because those commands are appended after the loop and there isn't another RawMemory.set() call afterwards. And I need to always call RawMemory.set at the end