Builders being derpy
-
I'm trying to use the same code as i use on the main server but my builders seem to jumble up the array when building.
var conSite = creep.room.find(FIND_CONSTRUCTION_SITES);
if(creep.build(conSite [0]) == ERR_NOT_IN_RANGE) {
if(!creep.fatigue){
creep.moveTo(conSite [0]);
}
}So shouldn't it complete site[0] before going to the next site[0]
-
with my beginners experience: Shouldnt your code have no spaces? -> conSite [0] -> conSite[0] ?
Edit: Ah excuse me
-
The code it self in the post is not formatted but it is fine in the script.
-
Hmm my script runs fine, but uses a different way to build:
var target = creep.pos.findClosestByRange(FIND_CONSTRUCTION_SITES);
if(target != null) {
if(creep.build(target) == ERR_NOT_IN_RANGE) {
creep.moveTo(target);
}
}
-
-
shuffled my code around seems to be ok now
nope just went screwy again
-
Why do you think creep.room.find(FIND_CONSTRUCTION_SITES) will always produce the sites in the same order?
If you want to keep working on the same site until it's done, then your creep needs to remember which site it was working on.
-
The reason why i use pos.findClosestByRange, but saving is better.
-
It seems like the order in which find() returns things is really entirely an implementation detail of the server's storage. I guess since the private server uses a custom JSON storage instead of MongoDB, it doesn't retain the order the same way.