Navigation

    forum

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

    JanLauGe

    @JanLauGe

    2
    Posts
    884
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    JanLauGe Follow

    Posts made by JanLauGe

    • RE: List creeps and filter

      It was pointed out to me that this would not work this way. Instead, I am now iterating over all my creeps to find the roles I want:

      function GetCreepsByRole(role){
      var CreepList = [];
      for (var creepname in Game.creeps){
      if (Game.creeps[creepname].memory.role == role){
      CreepList.push(Game.creeps[creepname]);
      }
      }
      return CreepList
      }
      posted in Help
      JanLauGe
    • List creeps and filter

      Hello everybody!
      I am new to the game and haven't done much JavaScript. But I am enjoying it a lot and am using the forum and StackExchange to slowly work my way forward. Today I encountered one problem that I think was worth asking abut here:

      I use two calls to list certain creeps, but I get very different behaviour of the resulting (arrays?)

      Game.spawns.Spawn1.room.find(FIND_CREEPS, {filter: function(object) {return object.memory.role == 'Harvester'}});
      //Returns all Harvesters in the room, as expected. Individual elements of the result can be passed to creeps as commands

      or

      _(Game.creeps).filter({ memory: { role: 'Harvester' }});
      //Returns all my Harvesters in the world, as expected. But individual elements are not recognized by commands to other creeps.
      Can anyone tell me what's going on here?
      Thanks a lot in advance!
      posted in Help
      JanLauGe