Navigation

    forum

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

    Posts made by Chowster

    • Spawn.TransferEnergy to creep

      I'm sorry if this was posted but I really tried to use search and all that and I could not find the answer.

       

      So I am trying to get creeps to pick up energy from the spawn and use it. My creeps seem to move to the spawn, but the transfer will not go through. Here is my code currently. It's the last part where it says else { if Game.spawns.Spawn1.TransferEnergy.

       

      var roleBuilder = {

      run: function(creep) {

      if(creep.memory.building && creep.carry.energy == 0) {
      creep.memory.building = false;
      }
      if(!creep.memory.building && creep.carry.energy == creep.carryCapacity) {
      creep.memory.building = true;
      }

      if(creep.memory.building) {
      var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
      if(targets.length) {
      if(creep.build(targets[0]) == ERR_NOT_IN_RANGE) {
      creep.moveTo(targets[0]);
      }
      }
      }
      else {
      if(Game.spawns.Spawn1.transferEnergy(creep, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
      creep.moveTo(Game.spawns.Spawn1);
      }
      }
      };

      module.exports = roleBuilder;

       

      Thank you for your help in advance!

      posted in Help
      Chowster