Adding functions to memory object prototypes seems to cause memory loading error.
-
See this forum post for full details: https://screeps.com/forum/topic/2428/add-functionality-to-memory-objects
Basically when I try to use the following line of reasoning:
class basicClass{ function test(){ return 'test'; } } Game.rooms['sim'].memory.test = new basicClass();
I know I will have to re add the class method to the memory object prototype.
var obj = Game.rooms['sim'].memory.test; //As expected obj.test is undefined console.log(obj.test); //This works but for a couple ticks in a row i will get a memory error before my script begins. Object.getPrototypeOf(obj).test = basicClass.prototype.test;
The error I get is: "Error: "test" is not a valid memory segment ID at self.onmessage (blob:https://screeps.com/83fe0913-2d1b-43e0-83a7-d3490fc5868b:2:100470)"
-
This is not an issue, Memory is intended for storing plain data only.