pos.findClosest is undefined



  • Hey,

    I just saw that the findNearest() method is depreciated and was removed an hour ago but the findClosest() method seems to be gone too. Was this by mistake or intented?



  • I can totally reproduce this problem...



  • Sorry. The code I use is an altered version of the tutorial code:

    function doJob(creep,spawn) 
    {
         if (creep.energy < creep.energyCapacity)
    
        {
        var source = creep.pos.findClosest(FIND_SOURCES);
    
    creep.harvest(source);
        }
    }
    

    but you can also reprocude it by calling from the console:

    Game.creeps['<creepername>'].pos.findClosest(FIND_SOURCES);
    


  • Actually, this is the error I'm getting... its not really undefined

    TypeError: Cannot read property '-999' of undefined
    at c.getNodeAt:2:5347
    at c.findPath:2:9159
    at n.c.make.n.findPath:5:15578
    at c.makePos.c.findClosest:5:20103
    at _console1431534843431_0:1:5124
    at Object.c.runCode:4:36586
    

    Using

    Game.spawns.Spawn1.pos.findClosest(FIND_SOURCES);
    

  • Dev Team

    Thanks, this must be fixed now.