I am attempting to save the source ID and the ID of which spawn is currently mining the source to memory under the current spawn in the room. Once I have that saved I can easily assign miners to each source without having to do FIND_SOURCES. Doing it this way will lower my CPU usage.
My current issue is that it only saves the source ID and not the custom object I am attempting to create. Any help with correcting this issue would be greatly appreciated.
Here is the current code I am using:
if(!spawn.memory.sources){
//spawn.memory.sources = {}; //Add it
var roomSources = spawn.room.find(FIND_SOURCES);
console.log("loading memory");
for(var i in roomSources){
var source = {id:roomSources[i].id, currentMinerId: null};
spawn.memory.sources[i] = source;
}
}