Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. Non
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    Non

    @Non

    1
    Posts
    823
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Non Follow

    Posts made by Non

    • Picking Up Dropped Energy

      I've written this code for my creep to pick up dropped energy but when it finds the dropped energy it just becomes paralyzed. Have I written anything wrong?

      Code:

      var roleHarvester = require('role.harvester');

      var roleLabourer = {
          run: function(creep){
              var dropenergy = creep.pos.findClosestByPath(FIND_DROPPED_ENERGY)
              if(dropenergy.length != 0){
                  if(creep.pickup(dropenergy[0]) == ERR_NOT_IN_RANGE){
                      creep.moveTo(dropenergy[0].pos)
                  }
                  if(creep.pickup(dropenergy[0]) == ERR_FULL){
                      var storages = Game.spawns.Spawn1.room.find(FIND_MY_STRUCTURES, { filter: { structureType: STRUCTURE_STORAGE }});
                      for (i = 0; i < storages.length; i++) {
                          if(storages[i].store[RESOURCE_ENERGY] < storages[i].storeCapacity){
                              if(creep.transfer(storages[i],RESOURCE_ENERGY,creep.carry.energy) == ERR_NOT_IN_RANGE){
                                  creep.moveTo(storages[i])
                              }
                          }
                      }
                  }
              }
              else{
                  roleHarvester.run(creep)
              }
          }
      }

      module.exports = roleLabourer

      posted in Help
      Non