<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Creep not following moveTo() pathing]]></title><description><![CDATA[<p>Having a problem using the moveTo() function in that when giving a creep a position to move to, it'll just go between the same two points that aren't related to its target and sometimes will fix it pathing after making a minute change to the script and saving even though the script was already saved and the change was insignificant (I.E making a comment.) It doesn't even adhere to the pathing it planned when I visualized it.</p>
<p>Here is a video demonstrating that: <a href="https://streamable.com/7qoqkb" rel="nofollow">https://streamable.com/7qoqkb</a></p>
<p>My code is very simple and I don't understand what particularly is wrong with it. Code being:</p>
<p><strong>Main</strong></p>
<pre><code>var roleWorker = require(&quot;role.worker&quot;);

var gameSpawns = Game.spawns;
var gameCreeps = Game.creeps;

module.exports.loop = function () {
    if(Object.keys(Game.creeps).length &lt; 1){
        gameSpawns[&quot;Spawn1&quot;].spawnCreep([WORK,MOVE,CARRY], &quot;worker&quot; + Object.keys(Game.creeps).length);
    }
    
    for(var creep in gameCreeps){
        roleWorker.run(gameCreeps[creep]);
    }
}
</code></pre>
<p><strong>Worker role</strong></p>
<pre><code>var roleWorker = {
    
    run: function(creep){
        var sources = creep.room.find(FIND_SOURCES);
        
        creep.moveTo(sources[0], {visualizePathStyle:{
    fill: 'transparent',
    stroke: '#fff',
    lineStyle: 'dashed',
    strokeWidth: .15,
    opacity: .1
}});
    }
    
}

module.exports = roleWorker;
</code></pre>
]]></description><link>http://screeps.com/forum/topic/3121/creep-not-following-moveto-pathing</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 23:45:57 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/3121.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Dec 2020 21:36:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Wed, 16 Dec 2020 21:40:02 GMT]]></title><description><![CDATA[<p>Having a problem using the moveTo() function in that when giving a creep a position to move to, it'll just go between the same two points that aren't related to its target and sometimes will fix it pathing after making a minute change to the script and saving even though the script was already saved and the change was insignificant (I.E making a comment.) It doesn't even adhere to the pathing it planned when I visualized it.</p>
<p>Here is a video demonstrating that: <a href="https://streamable.com/7qoqkb" rel="nofollow">https://streamable.com/7qoqkb</a></p>
<p>My code is very simple and I don't understand what particularly is wrong with it. Code being:</p>
<p><strong>Main</strong></p>
<pre><code>var roleWorker = require(&quot;role.worker&quot;);

var gameSpawns = Game.spawns;
var gameCreeps = Game.creeps;

module.exports.loop = function () {
    if(Object.keys(Game.creeps).length &lt; 1){
        gameSpawns[&quot;Spawn1&quot;].spawnCreep([WORK,MOVE,CARRY], &quot;worker&quot; + Object.keys(Game.creeps).length);
    }
    
    for(var creep in gameCreeps){
        roleWorker.run(gameCreeps[creep]);
    }
}
</code></pre>
<p><strong>Worker role</strong></p>
<pre><code>var roleWorker = {
    
    run: function(creep){
        var sources = creep.room.find(FIND_SOURCES);
        
        creep.moveTo(sources[0], {visualizePathStyle:{
    fill: 'transparent',
    stroke: '#fff',
    lineStyle: 'dashed',
    strokeWidth: .15,
    opacity: .1
}});
    }
    
}

module.exports = roleWorker;
</code></pre>
]]></description><link>http://screeps.com/forum/post/15986</link><guid isPermaLink="true">http://screeps.com/forum/post/15986</guid><dc:creator><![CDATA[HotdogMan]]></dc:creator><pubDate>Wed, 16 Dec 2020 21:40:02 GMT</pubDate></item><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Invalid Date]]></title><description><![CDATA[<p>forgive the sloppy indentation on the visualizepathstyle option, im in a rush and didn't have time to make it look neat</p>
]]></description><link>http://screeps.com/forum/post/15987</link><guid isPermaLink="true">http://screeps.com/forum/post/15987</guid><dc:creator><![CDATA[HotdogMan]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Invalid Date]]></title><description><![CDATA[<p>Try passing <code>range: 1</code> as an option - you don't actually want to move to the source - you want to move within 1 tile of it. Your current code will try to find a path into a wall, which causes issues.</p>
]]></description><link>http://screeps.com/forum/post/15988</link><guid isPermaLink="true">http://screeps.com/forum/post/15988</guid><dc:creator><![CDATA[Tigga]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/138">@tigga</a> tried <code>range: 1</code> but still no results. Even tried range 2 but it's still the same.</p>
<p>Here's a video with <code>range: 1</code> and pathing visualised: <a href="https://streamable.com/iqk38x" rel="nofollow">https://streamable.com/iqk38x</a></p>
<p>Same as before, updated code looks like:</p>
<pre><code>var roleWorker = {
    
    run: function(creep){
        var sources = creep.room.find(FIND_SOURCES);
        var creepPath = creep.pos.findPathTo(sources[0]);
        
        creep.moveTo(sources[0], {visualizePathStyle:{
            fill: 'transparent',
            stroke: '#fff',
            lineStyle: 'dashed',
            strokeWidth: .15,
            opacity: .1
        }, range: 1});
    }
    
}

module.exports = roleWorker;
</code></pre>
]]></description><link>http://screeps.com/forum/post/15989</link><guid isPermaLink="true">http://screeps.com/forum/post/15989</guid><dc:creator><![CDATA[HotdogMan]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Invalid Date]]></title><description><![CDATA[<p>move this into the main loop.</p>
<pre><code>var gameSpawns = Game.spawns;
var gameCreeps = Game.creeps;
</code></pre>
]]></description><link>http://screeps.com/forum/post/15990</link><guid isPermaLink="true">http://screeps.com/forum/post/15990</guid><dc:creator><![CDATA[explicit]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Thu, 17 Dec 2020 02:36:27 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3094">@explicit</a> said in <a href="/forum/post/15990">Creep not following moveTo() pathing</a>:</p>
<blockquote>
<p>move this into the main loop.</p>
<pre><code>var gameSpawns = Game.spawns;
var gameCreeps = Game.creeps;
</code></pre>
</blockquote>
<p>this will be it, yes. since you have it outside the loop, spawns and creeps only get initialized on global resets and not get updated until the next one. this means that the position data on your creeps is the same as on the global reset tick and they end up thinking they havent moved yet. for spawns this could also have side effects like it throwing not enough energy when it's full or spawning when it's not. since it looks like you're playing in sim, you'll have those resets every 10 seconds, fixing the problem and beginning the ordeal anew</p>
<p>i would also advise against using [0] like this. while certain databases generally return objects in the same order, it is undocumented behavior and not guaranteed. it could also lead to your creeps running back and forth because sources[0] returns a different source suddenly</p>
]]></description><link>http://screeps.com/forum/post/15991</link><guid isPermaLink="true">http://screeps.com/forum/post/15991</guid><dc:creator><![CDATA[RayderBlitz]]></dc:creator><pubDate>Thu, 17 Dec 2020 02:36:27 GMT</pubDate></item><item><title><![CDATA[Reply to Creep not following moveTo() pathing on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3094">@explicit</a> <a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3891">@RayderBlitz</a> Yeah, that was it. Movement is still kinda funky when there is more than one creep out but at least now it's actually going where it is told.</p>
<p>Thanks for the help fellas (oﾟvﾟ)ノ</p>
]]></description><link>http://screeps.com/forum/post/15994</link><guid isPermaLink="true">http://screeps.com/forum/post/15994</guid><dc:creator><![CDATA[HotdogMan]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>