Navigation

    forum

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

    Posts made by greece57

    • for of loop [SOLVED]

      Sry if its a silly question, I'm not soo good in JavaScript 😕 Why can't I use:

      for (let room of Game.rooms) {
        room.lookAt(1,1);
      }

      If i use "room IN Game.rooms" then I can't access the lookAt function again because I get the error:
      "TypeError: room.lookAt is not a function"

       

      Solution:
      for (let room in Game.rooms) {
        Game.rooms[room].lookAt(1,1);
      }

      Thx Atavus for the answer! 🙂

      posted in Help
      greece57
    • RE: TypeError in PathFinder: a.getRangeTo is not a function

      var sources = creep.room.find(FIND_SOURCES);
      var target = creep.room.find(FIND_MY_SPAWNS)[0];
      var nearestSource = {source: sources[0], pathLength: 100000};
      for(var i = 0; i < sources.length; i++) {
        var source = sources[i];
        var pathLength = creep.room.findPath(target.pos, source.pos).length;
        //var pathLength = PathFinder.search({pos: target.pos, range: 1}, {pos: source.pos, range: 1}).path;
        if (pathLength < nearestSource.pathLength)
          nearestSource = {source: source, pathLength: pathLength};
      }

       

      The outcommented code is the code that didn't work and produced the above error.
      Thanks for your help!

      posted in Help
      greece57
    • TypeError in PathFinder: a.getRangeTo is not a function

      TypeError: a.getRangeTo is not a function
      at h:5:6733
      at Object.c.search:5:11195
      at Object.e.PathFinder.search:7:9249
      at Object.helperMethods.findSource:39:41
      at Object.roleHarvester.run:9:31
      at Object.module.exports.loop:22:40
      at __mainLoop:1:14194
      at eval:2:4

      posted in Help
      greece57