Find empty spawn in room with full extensions.
-
@ayrtep 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.
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?
-
@likeafox said in Find empty spawn in room with full extensions.:
@ayrtep 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.
If you read what I said above
room.energyCapacityAvailable returns null
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.
I checked the creep.transfer. 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.
I am not sure if this is relevant, but it's happening on a steam private server.
-
You man have corrupted your api or your DB entries might be corrupt. Try these:
Game.spawns.Spawn1.store.getCapacity() Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY) Game.spawns.Spawn1.store.getCapacity('energy') Game.spawns.Spawn1.energyCapacity
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
Store
schema.
-
Thanks, I'll try that the next time I reproduce.
I have reset my private server with a system.resetAllData(), and the new game does not have this problem.
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.
-
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?
-
@deft-code said in Find empty spawn in room with full extensions.:
Game.spawns.Spawn1.energyCapacity
Ok, It happened again. The trigger this time might have been stopping the server for eight hours then restarting.
I tried
console.log("Game.spawns.Spawn1.store.getCapacity()", Game.spawns.Spawn1.store.getCapacity()); console.log("Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY)", Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY)); console.log("Game.spawns.Spawn1.store.getCapacity('energy')", Game.spawns.Spawn1.store.getCapacity('energy')); console.log("Game.spawns.Spawn1.energyCapacity", Game.spawns.Spawn1.energyCapacity);
and got
Game.spawns.Spawn1.store.getCapacity() null
Game.spawns.Spawn1.store.getCapacity(RESOURCE_ENERGY) null
Game.spawns.Spawn1.store.getCapacity('energy') null
Game.spawns.Spawn1.energyCapacity 0
-
Happened again. Looks like restarting a steam private server is very likely to set the spawn energy and hence room energy to null.
-
Having the same issue
-
If it happends on private server maybe this is same issue? https://screeps.com/forum/topic/2829/room-energycapacityavailable-returns-null-due-to-corrupted-spawn-store/2
-
got the exact same issue here, after rebooting vm machine and restarting private server.
spawn.store and spawn.storeCapacityResource become an empty object.
if put energy into the spawn, spawn.store["energy"] will reappear, but spawn.storeCapacityResource still empty.
-
@ayrtep said in Find empty spawn in room with full extensions.:
So this is the first time I have looked at the screeps engine, so I am probably missing stuff. However
https://github.com/screeps/engine/blob/master/src/game/game.js#L316
register.rooms[object.room].energyAvailable += object.store.energy;
register.rooms[object.room].energyCapacityAvailable += object.storeCapacityResource.energy;
We are += on something that could be null, in which case it would just turn null and stay that way forever!
https://github.com/screeps/engine/blob/master/src/game/store.js#L28
Here stuff in the store is set to "null" rather than "0" if the resource is missing.
I am just guessing, but I suspect there might be an issue here. The bit in game.js was only done 11 months ago. https://github.com/screeps/engine/commit/879b4ca215f1e0b7fd92c7b32c7e59bdc4722cfc#diff-47818c887f19982321abd70c2e741871 https://www.worktime.com/
I am not sure if this is relevant, but it's happening on a steam private server.