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);
    }
    }


  • Looks like it is jumbling the array, output of console.log(conSite[0]). Maybe I'm not understanding how the mechanic works or maybe it works diffrently on the private servers compared to the main one. Note that all the construction sites are still unfinished.
     
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:50 PM]
    [construction site (extension) #8dc6ec0ef9e91b0]
    [12:55:51 PM]
    <-- Home room stuff W8N3 -->
    [12:55:51 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:51 PM]
    [construction site (extension) #8dc6ec0ef9e91b0]
    [12:55:52 PM]
    <-- Home room stuff W8N3 -->
    [12:55:52 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:52 PM]
    [construction site (extension) #8dc6ec0ef9e91b0]
    [12:55:53 PM]
    <-- Home room stuff W8N3 -->
    [12:55:53 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:53 PM]
    [construction site (extension) #8dc6ec0ef9e91b0]
    [12:55:54 PM]
    <-- Home room stuff W8N3 -->
    [12:55:54 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:54 PM]
    [construction site (extension) #c297ec12142a286]
    [12:55:55 PM]
    <-- Home room stuff W8N3 -->
    [12:55:55 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:55 PM]
    [construction site (extension) #c297ec12142a286]
    [12:55:56 PM]
    <-- Home room stuff W8N3 -->
    [12:55:56 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:56 PM]
    [construction site (extension) #c297ec12142a286]
    [12:55:57 PM]
    <-- Home room stuff W8N3 -->
    [12:55:57 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:57 PM]
    [construction site (extension) #c297ec12142a286]
    [12:55:58 PM]
    <-- Home room stuff W8N3 -->
    [12:55:58 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:58 PM]
    [construction site (extension) #c297ec12142a286]
    [12:55:59 PM]
    <-- Home room stuff W8N3 -->
    [12:55:59 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:55:59 PM]
    [construction site (extension) #c297ec12142a286]
    [12:56:00 PM]
    <-- Home room stuff W8N3 -->
    [12:56:00 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:00 PM]
    [construction site (extension) #c297ec12142a286]
    [12:56:01 PM]
    <-- Home room stuff W8N3 -->
    [12:56:01 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:01 PM]
    [construction site (extension) #c297ec12142a286]
    [12:56:03 PM]
    <-- Home room stuff W8N3 -->
    [12:56:03 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:03 PM]
    [construction site (extension) #c297ec12142a286]
    [12:56:03 PM]
    <-- Home room stuff W8N3 -->
    [12:56:03 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:03 PM]
    [construction site (extension) #f14fec0f527da35]
    [12:56:04 PM]
    <-- Home room stuff W8N3 -->
    [12:56:04 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:04 PM]
    [construction site (extension) #f14fec0f527da35]
    [12:56:06 PM]
    <-- Home room stuff W8N3 -->
    [12:56:06 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:06 PM]
    [construction site (extension) #f14fec0f527da35]
    [12:56:06 PM]
    <-- Home room stuff W8N3 -->
    [12:56:06 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:06 PM]
    [construction site (extension) #f14fec0f527da35]
    [12:56:07 PM]
    <-- Home room stuff W8N3 -->
    [12:56:07 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:07 PM]
    [construction site (extension) #c297ec12142a286]
    [12:56:09 PM]
    <-- Home room stuff W8N3 -->
    [12:56:09 PM]
    Harv: 2/2 Haul: 2/2 Upgrader: 3/3 Builder: 1/1
    [12:56:09 PM]
    [construction site (extension) #2cb4ec11beec9ef]


  • 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.