Problem with lab code (role.scientist)



  • Hey guys, I'm trying to write a transport creep that fills the labs with minerals, but after a lot of changing my code around, it's still not working. I changed it around a lot, but this is my current code:

     

    ```javascript

    } else if (creep.memory.order == 'Sc') {
    var labL = Game.getObjectById('57af7bca736eb18b5f3b76e2');
    var labH = Game.getObjectById('57b02ee949ae38c432e9d225');
    var total = _.sum(creep.carry);
    if (labL.mineralAmount == 0) {
    //GET LEMERGIUM FROM STORAGE
    if (creep.carry[RESOURCE_LEMERGIUM] == 0) {
    if(creep.withdraw(creep.room.storage, RESOURCE_LEMERGIUM) == ERR_NOT_IN_RANGE) {
    creep.moveTo(creep.room.storage);
    }
    } else {
    if (creep.transfer(labL) == ERR_NOT_IN_RANGE) {
    creep.moveTo(labL);
    }
    }
    } else if (labH.mineralAmount == 0) {
    //GET HYDROGEN FROM TERMINAL
    if (creep.carry[RESOURCE_HYDROGEN] == 0) {
    if(creep.withdraw(creep.room.terminal, RESOURCE_HYDROGEN) == ERR_NOT_IN_RANGE) {
    creep.moveTo(creep.room.terminal);
    }
    } else {
    if (creep.transfer(labH) == ERR_NOT_IN_RANGE) {
    creep.moveTo(labH);
    }
    }
    } else {

    ```

     

    The creep is just standing around after spawning and does nothing. I got it to pick up some L at some point, but it didn't transport it but now it doesn't move at all again. PLEASE help 😮 I need my labs working^^

     

    Thanks guys!


  • Culture

    You have to specify resourceType when you call creep.transfer.



  • oh, wow. Thank you ;X