When a power-creep is not spawned in, it's ticksToLive property returns null, however, this value is somehow broken. While it does show up correctly when saved to memory or logged to the console, it somehow causes an evaluation against null to be false. Example:
var powerCreep = Game.powerCreeps[Object.keys(Game.powerCreeps)[0]];
console.log("---before---");
console.log(powerCreep.ticksToLive)
console.log(powerCreep.ticksToLive == null)
console.log("---after---");
The expected behaviour would be Game.powerCreeps[Object.keys(Game.powerCreeps)[0]].ticksToLive == null to be true in the case of Game.powerCreeps[Object.keys(Game.powerCreeps)[0]].ticksToLive being null. I've also checked and in this case the value is NOT a string that just sais "null".
When a power-creep is not spawned in, it's
ticksToLive
property returnsnull
, however, this value is somehow broken. While it does show up correctly when saved to memory or logged to the console, it somehow causes an evaluation againstnull
to befalse
. Example:This will yield the following output:
The expected behaviour would be
Game.powerCreeps[Object.keys(Game.powerCreeps)[0]].ticksToLive == null
to betrue
in the case ofGame.powerCreeps[Object.keys(Game.powerCreeps)[0]].ticksToLive
beingnull
. I've also checked and in this case the value is NOT a string that just sais"null"
.I don't know a fix for this, however someone in discord suggested this was the cause: https://github.com/screeps/engine/blob/97c9d12385fed686655c13b09f5f2457dd83a2bf/src/game/power-creeps.js#L72
The start of this conversation in the official discord can be found with this link: https://discord.com/channels/860665589738635336/866441713383637032/1267538335002529853