<?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[Find empty spawn in room with full extensions.]]></title><description><![CDATA[<p>How do you work out if a spawn can accept more energy in a room with extensions?</p>
<p>Say you have ten filled extensions and one or more empty spawns. If you query the spawn, it tells you its energyCapacity is 0.  Presumably to stop it gaining one energy per turn.</p>
<p>You can ask the room if it's room.energy &lt; room.energyCapacity. If the room is not at capacity, you know that at least one of the spawns is not at capacity, but not which one. Can't see how you could tell which without visiting each spawn in turn and seeing if anything happens if you transfer. (edit: Although I seem to looking at a room with energy 300 and energycapacity 0 so maybe that won't work.)</p>
<p>I feel sure that I have to be missing something here, but not sure what.</p>
<p>So how, in a room with a mixture of spawns and extensions, can you guarantee finding the one that will accept an energy transfer?</p>
<p>This seems a total fail.</p>
<p>const nextSourceContainer = this.creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
filter: function(structure)  {
return (structure.structureType === STRUCTURE_EXTENSION
|| structure.structureType === STRUCTURE_SPAWN )
&amp;&amp; structure.store.getFreeCapacity(RESOURCE_ENERGY) &gt; 0;
}
});</p>
]]></description><link>http://screeps.com/forum/topic/2973/find-empty-spawn-in-room-with-full-extensions</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 12:45:46 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/2973.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 May 2020 14:59:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Sun, 10 May 2020 15:12:43 GMT]]></title><description><![CDATA[<p>How do you work out if a spawn can accept more energy in a room with extensions?</p>
<p>Say you have ten filled extensions and one or more empty spawns. If you query the spawn, it tells you its energyCapacity is 0.  Presumably to stop it gaining one energy per turn.</p>
<p>You can ask the room if it's room.energy &lt; room.energyCapacity. If the room is not at capacity, you know that at least one of the spawns is not at capacity, but not which one. Can't see how you could tell which without visiting each spawn in turn and seeing if anything happens if you transfer. (edit: Although I seem to looking at a room with energy 300 and energycapacity 0 so maybe that won't work.)</p>
<p>I feel sure that I have to be missing something here, but not sure what.</p>
<p>So how, in a room with a mixture of spawns and extensions, can you guarantee finding the one that will accept an energy transfer?</p>
<p>This seems a total fail.</p>
<p>const nextSourceContainer = this.creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
filter: function(structure)  {
return (structure.structureType === STRUCTURE_EXTENSION
|| structure.structureType === STRUCTURE_SPAWN )
&amp;&amp; structure.store.getFreeCapacity(RESOURCE_ENERGY) &gt; 0;
}
});</p>
]]></description><link>http://screeps.com/forum/post/15072</link><guid isPermaLink="true">http://screeps.com/forum/post/15072</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Sun, 10 May 2020 15:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p><code>room.find(FIND_MY_SPAWNS).filter((s:StructureSpawn) =&gt; s.store.getUsedCapacity(RESOURCE_ENERGY) === 0)</code></p>
]]></description><link>http://screeps.com/forum/post/15073</link><guid isPermaLink="true">http://screeps.com/forum/post/15073</guid><dc:creator><![CDATA[Gadjung]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Mon, 11 May 2020 14:53:38 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3748">@gadjung</a> said in <a href="/forum/post/15073">Find empty spawn in room with full extensions.</a>:</p>
<blockquote>
<p><code>room.find(FIND_MY_SPAWNS).filter((s:StructureSpawn) =&gt; s.store.getUsedCapacity(RESOURCE_ENERGY) === 0)</code></p>
</blockquote>
<p>Thanks for replying, but this answer does not find any extensions unless you are saying that you should never fill extensions?!?</p>
<p>Anyway, I am still really confused. I have a room with:</p>
<p>room.energyAvailable 317</p>
<p>room.energyCapacityAvailable null</p>
<p>I don't understand how &quot;Total amount of energyCapacity of all spawns and extensions in the room.&quot; is null here? <a href="https://docs.screeps.com/api/#Room.energyCapacityAvailable" rel="nofollow">https://docs.screeps.com/api/#Room.energyCapacityAvailable</a></p>
<p>The 317 is 50 from each of 5 extensions and 67 from the spawn. Querying the spawn gives.</p>
<p>spawn store {&quot;energy&quot;:67}</p>
<p>spawn getCapacity null</p>
<p>spawn getFreeCapacity null</p>
<p>spawn getUsedCapacity 67</p>
<p>Which seems to be saying that the spawn which has 67 energy, has no energy capcity.</p>
<p>Code I used to get this.</p>
<p>const home = Game.rooms[&quot;W7N7&quot;];</p>
<p>console.log(&quot;home energyAvailable&quot;, home.energyAvailable,    &quot;energyCapacityAvailable&quot;,home.energyCapacityAvailable);</p>
<p>const spawn = Game.spawns[&quot;Spawn1&quot;];</p>
<p>console.log(&quot;spawn store&quot;, JSON.stringify(spawn.store),
&quot;spawn getCapacity&quot;, spawn.store.getCapacity(RESOURCE_ENERGY),
&quot;spawn getFreeCapacity&quot;, spawn.store.getFreeCapacity(RESOURCE_ENERGY),
&quot;spawn getUsedCapacity&quot;, spawn.store.getUsedCapacity(RESOURCE_ENERGY));</p>
<p>With result:</p>
<p>home energyAvailable 317 energyCapacityAvailable null
spawn store {&quot;energy&quot;:67} spawn getCapacity null spawn getFreeCapacity null spawn getUsedCapacity 67</p>
]]></description><link>http://screeps.com/forum/post/15076</link><guid isPermaLink="true">http://screeps.com/forum/post/15076</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Mon, 11 May 2020 14:53:38 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Mon, 11 May 2020 15:45:06 GMT]]></title><description><![CDATA[<p>So this is the first time I have looked at the screeps engine, so I am probably missing stuff. However</p>
<p><a href="https://github.com/screeps/engine/blob/master/src/game/game.js#L316" rel="nofollow">https://github.com/screeps/engine/blob/master/src/game/game.js#L316</a></p>
<p>register.rooms[object.room].energyAvailable += object.store.energy;</p>
<pre><code> register.rooms[object.room].energyCapacityAvailable += object.storeCapacityResource.energy;
</code></pre>
<p>We are += on something that could be <strong>null</strong>, in which case it would just turn <strong>null</strong> and stay that way forever!</p>
<p><a href="https://github.com/screeps/engine/blob/master/src/game/store.js#L28" rel="nofollow">https://github.com/screeps/engine/blob/master/src/game/store.js#L28</a></p>
<p>Here stuff in the store is set to &quot;<strong>null</strong>&quot; rather than &quot;<strong>0</strong>&quot; if the resource is missing.</p>
<p>I am just guessing, but I suspect there might be an issue here. The bit in game.js was only done 11 months ago. <a href="https://github.com/screeps/engine/commit/879b4ca215f1e0b7fd92c7b32c7e59bdc4722cfc#diff-47818c887f19982321abd70c2e741871" rel="nofollow">https://github.com/screeps/engine/commit/879b4ca215f1e0b7fd92c7b32c7e59bdc4722cfc#diff-47818c887f19982321abd70c2e741871</a></p>
]]></description><link>http://screeps.com/forum/post/15078</link><guid isPermaLink="true">http://screeps.com/forum/post/15078</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Mon, 11 May 2020 15:45:06 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p>const nextSourceContainer = this.creep.pos.findClosestByRange(FIND_MY_STRUCTURES, { filter: function(structure) { return (structure.structureType === STRUCTURE_EXTENSION || structure.structureType === STRUCTURE_SPAWN ) &amp;&amp; structure.store.energy &gt; 0; } });</p>
<p>structure.store.energy &gt; 0; Being key - this will return all structures that have energy.</p>
<p>If you're looking for spawn/extensions that need energy filled you can replace &quot;structure.store.energy &gt; 0&quot; for &quot;!structure.store.energy || structure.store.energy &lt; structure.store.getCapacity(RESOURCE_ENERGY) &quot; - !structure.store.energy will detect null/undefined and 0.</p>
<p>I would recommend getting on Slack, and the help channel. People are a bit more active than in these forums.</p>
]]></description><link>http://screeps.com/forum/post/15079</link><guid isPermaLink="true">http://screeps.com/forum/post/15079</guid><dc:creator><![CDATA[likeafox]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Mon, 11 May 2020 16:38:28 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1747">@likeafox</a></p>
<p>Thanks, I'll try your suggestion.</p>
<p>I am also using <strong>room.energyCapacity</strong> to work out how big to build my creeps. I guess I will have to replace that with something that explicitly counts spawns and extensions. Plus my spawn no longer accepts energy despite having only 67 energy.</p>
<p>Might be an idea to move this post to the bugs forum.</p>
]]></description><link>http://screeps.com/forum/post/15080</link><guid isPermaLink="true">http://screeps.com/forum/post/15080</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Mon, 11 May 2020 16:38:28 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/447">@ayrtep</a>
I would use room.energyCapacityAvailable to figure out how big you can build you're creeps, that way you don't have to count you're spawns/extensions.</p>
<p>Your spawn should always accept energy unless the RCL isn't high enough, do you know what error is coming back after you try a transfer?</p>
]]></description><link>http://screeps.com/forum/post/15081</link><guid isPermaLink="true">http://screeps.com/forum/post/15081</guid><dc:creator><![CDATA[likeafox]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Mon, 11 May 2020 17:23:26 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1747">@likeafox</a> said in <a href="/forum/post/15081">Find empty spawn in room with full extensions.</a>:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/447">@ayrtep</a>
I would use room.energyCapacityAvailable to figure out how big you can build you're creeps, that way you don't have to count you're spawns/extensions.</p>
</blockquote>
<p>If you read what I said above</p>
<p><strong>room.energyCapacityAvailable returns null</strong></p>
<p>so I just created a wrapper function to do it the long way until the 'bug?' gets fixed and room.energyCapacityAvailable returns the room's  energyCapacityAvailable.</p>
<p>I checked the <em>creep.transfer.</em> The transfer is successful, but as far as I can tell no energy is transferred to the spawn. On the GUI the spawn's energy status stays around 50-80. Sometimes it goes up in ones, I think after I use the energy in the extensions to make a creep.</p>
<p>I am not sure if this is relevant, but it's happening on a steam private server.</p>
]]></description><link>http://screeps.com/forum/post/15082</link><guid isPermaLink="true">http://screeps.com/forum/post/15082</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Mon, 11 May 2020 17:23:26 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p>You man have corrupted your api or your DB entries might be corrupt. Try these:</p>
<pre><code>Game.spawns.Spawn1.store.getCapacity()
Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY)
Game.spawns.Spawn1.store.getCapacity('energy')
Game.spawns.Spawn1.energyCapacity
</code></pre>
<p>If this is on MMO it is very unlikely to be a DB error. If this is a private server, you may have found a problem when db upgraded to use the new <code>Store</code> schema.</p>
]]></description><link>http://screeps.com/forum/post/15084</link><guid isPermaLink="true">http://screeps.com/forum/post/15084</guid><dc:creator><![CDATA[deft-code]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/49">@deft-code</a></p>
<p>Thanks, I'll try that the next time I reproduce.</p>
<p>I have reset my private server with a system.resetAllData(), and the new game does not have this problem.</p>
<p>It could easily be some form of corruption. My development cycle involves deleting and replacing the files in my .../127_0_0_1___21025/default directory every few minutes.</p>
]]></description><link>http://screeps.com/forum/post/15087</link><guid isPermaLink="true">http://screeps.com/forum/post/15087</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Tue, 12 May 2020 13:14:51 GMT]]></title><description><![CDATA[<p>Spawn will stop generating energy if the combined energy of spawn + extensions in the room is 300 or above. Does that make any difference for you?</p>
]]></description><link>http://screeps.com/forum/post/15088</link><guid isPermaLink="true">http://screeps.com/forum/post/15088</guid><dc:creator><![CDATA[PowerDuDe]]></dc:creator><pubDate>Tue, 12 May 2020 13:14:51 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Tue, 12 May 2020 13:45:18 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/49">@deft-code</a> said in <a href="/forum/post/15084">Find empty spawn in room with full extensions.</a>:</p>
<blockquote>
<p>Game.spawns.Spawn1.energyCapacity</p>
</blockquote>
<p>Ok, It happened again. The trigger this time might have been stopping the server for eight hours then restarting.</p>
<p>I tried</p>
<pre><code>    console.log(&quot;Game.spawns.Spawn1.store.getCapacity()&quot;, Game.spawns.Spawn1.store.getCapacity());
    console.log(&quot;Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY)&quot;, Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY));
    console.log(&quot;Game.spawns.Spawn1.store.getCapacity('energy')&quot;, Game.spawns.Spawn1.store.getCapacity('energy'));
    console.log(&quot;Game.spawns.Spawn1.energyCapacity&quot;, Game.spawns.Spawn1.energyCapacity);
</code></pre>
<p>and got</p>
<p>Game.spawns.Spawn1.store.getCapacity() null<br />
Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY) null<br />
Game.spawns.Spawn1.store.getCapacity('energy') null<br />
Game.spawns.Spawn1.energyCapacity 0</p>
]]></description><link>http://screeps.com/forum/post/15089</link><guid isPermaLink="true">http://screeps.com/forum/post/15089</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Tue, 12 May 2020 13:45:18 GMT</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/447">@ayrtep</a></p>
<p>Happened again. Looks like restarting a steam private server is very likely to set the spawn energy and hence room energy to null.</p>
]]></description><link>http://screeps.com/forum/post/15095</link><guid isPermaLink="true">http://screeps.com/forum/post/15095</guid><dc:creator><![CDATA[ayrtep]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p>Having the same issue</p>
]]></description><link>http://screeps.com/forum/post/15223</link><guid isPermaLink="true">http://screeps.com/forum/post/15223</guid><dc:creator><![CDATA[ZephyrGrant]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p>If it happends on private server maybe this is same issue? <a href="https://screeps.com/forum/topic/2829/room-energycapacityavailable-returns-null-due-to-corrupted-spawn-store/2" rel="nofollow">https://screeps.com/forum/topic/2829/room-energycapacityavailable-returns-null-due-to-corrupted-spawn-store/2</a></p>
]]></description><link>http://screeps.com/forum/post/15371</link><guid isPermaLink="true">http://screeps.com/forum/post/15371</guid><dc:creator><![CDATA[U-238]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p>got the exact same issue here, after rebooting vm machine and restarting private server.</p>
<p>spawn.store and spawn.storeCapacityResource become an empty object.</p>
<p>if put energy into the spawn, spawn.store[&quot;energy&quot;] will reappear,  but spawn.storeCapacityResource still empty.</p>
]]></description><link>http://screeps.com/forum/post/16382</link><guid isPermaLink="true">http://screeps.com/forum/post/16382</guid><dc:creator><![CDATA[Qionglu735]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Find empty spawn in room with full extensions. on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/447">@ayrtep</a> said in <a href="/forum/post/15078">Find empty spawn in room with full extensions.</a>:</p>
<blockquote>
<p>So this is the first time I have looked at the screeps engine, so I am probably missing stuff. However</p>
<p><a href="https://github.com/screeps/engine/blob/master/src/game/game.js#L316" rel="nofollow">https://github.com/screeps/engine/blob/master/src/game/game.js#L316</a></p>
<p>register.rooms[object.room].energyAvailable += object.store.energy;</p>
<p>register.rooms[object.room].energyCapacityAvailable += object.storeCapacityResource.energy;</p>
<p>We are += on something that could be <strong>null</strong>, in which case it would just turn <strong>null</strong> and stay that way forever!</p>
<p><a href="https://github.com/screeps/engine/blob/master/src/game/store.js#L28" rel="nofollow">https://github.com/screeps/engine/blob/master/src/game/store.js#L28</a></p>
<p>Here stuff in the store is set to &quot;<strong>null</strong>&quot; rather than &quot;<strong>0</strong>&quot; if the resource is missing.</p>
<p>I am just guessing, but I suspect there might be an issue here. The bit in game.js was only done 11 months ago. <a href="https://github.com/screeps/engine/commit/879b4ca215f1e0b7fd92c7b32c7e59bdc4722cfc#diff-47818c887f19982321abd70c2e741871" rel="nofollow">https://github.com/screeps/engine/commit/879b4ca215f1e0b7fd92c7b32c7e59bdc4722cfc#diff-47818c887f19982321abd70c2e741871</a> <a href="https://www.worktime.com/" rel="nofollow">https://www.worktime.com/</a></p>
</blockquote>
<p>I am not sure if this is relevant, but it's happening on a steam private server.</p>
]]></description><link>http://screeps.com/forum/post/16405</link><guid isPermaLink="true">http://screeps.com/forum/post/16405</guid><dc:creator><![CDATA[lisukovigor492]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>