You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In set and get methods, "memory.sources" is different from "memory.sourceIds"
Object.defineProperty(Room.prototype,'sources',{get: function(){// If we dont have the value stored locallyif(!this._sources){// If we dont have the value stored in memoryif(!this.memory.sourceIds){// Find the sources and store their id's in memory, // NOT the full objectsthis.memory.sourceIds=this.find(FIND_SOURCES).map(source=>source.id);}// Get the source objects from the id's in memory and store them locallythis._sources=this.memory.sourceIds.map(id=>Game.getObjectById(id));//this}// return the locally stored valuereturnthis._sources;},set: function(newValue){// when storing in memory you will want to change the setter// to set the memory value as well as the local valuethis.memory.sources=newValue.map(source=>source.id);//thisthis._sources=newValue;},enumerable: false,configurable: true});
The text was updated successfully, but these errors were encountered:
https://docs.screeps.com/contributed/modifying-prototypes.html
In set and get methods, "memory.sources" is different from "memory.sourceIds"
The text was updated successfully, but these errors were encountered: