Navigation

    forum

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

    Xypla

    @Xypla

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

    Xypla Follow

    Posts made by Xypla

    • Code to repair don´t work

      Hey I start programing but i don´t understand the consol crash output. I wrote this code:

       

       

      var roleRep = {

      /** @param {Creep} creep **/
      run: function(creep) {

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

      if(creep.memory.fullcheck) {
      var targets = creep.room.find(FIND_STRUCTURES, {
      filter: object => object.hits < object.hitsMax
      });

      targets.sort((a,b) => a.hits - b.hits);

      if(targets.length > 0) {
      if(creep.repair(targets[0]) == ERR_NOT_IN_RANGE) {
      creep.moveTo(targets[0]);
      }
      }
      }
      else {
      var spwn = creep.pos.findClosest(FIND_MY_SPAWNS);
      creep.moveTo(spwn);
      if((spwn) > [199]) {
      spwn.transferEnergy(creep);
      }}

      }
      };

      module.exports = roleRep;

       

      I think i miss somethink but i cant finde the mistake any help?

       

      posted in Help
      Xypla