javascript - Screeps Issue with saving custom object under spawn to memory -


i attempting save source id , id of spawn mining source memory under current spawn in room. once have saved can assign miners each source without having find_sources. doing way lower cpu usage.

my current issue saves source id , not custom object attempting create. correcting issue appreciated.

here current code using:

    if(!spawn.memory.sources){         //spawn.memory.sources = {}; //add         var roomsources = spawn.room.find(find_sources);         console.log("loading memory");         for(var in roomsources){             var source = {id:roomsources[i].id, currentminerid: null};            spawn.memory.sources[i] = source;          }     } 

i able correct issue following code. hope helpful else.

    if(!spawns.memory.roomsources){         spawns.memory.roomsources=[];         var energysources = spawns.room.find(find_sources);         for(var in energysources){             spawns.memory.roomsources[i] = {sourceid: energysources[i].id, currentminerid: null};          }     } 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -