Which shard is affected?
shard3
What happened?
After the game update version 4.0. I tried to use the store
prototype instead of the previous carry
. But sometimes there are some confusing errors when the code is executed. Like below:
Error: This creep doesn't exist yet
at data (<runtime>:37632:19)
at Object.get [as store] (eval at exports.defineGameObjectProperties (<runtime>:1093:9), <anonymous>:7:62)
at Object.switch (roles.advanced:17:53)
at Object.CreepExtension.work (mount.creep:46:62)
at Object.doing (utils:64:18)
at Object.module.exports.loop (main:9:13)
at __mainLoop:1:52
at __mainLoop:2:3
at Object.exports.evalCode (<runtime>:16037:76)
The corresponding code as follows:
// Update status based on its carrying
Creep.prototype.updateState = () => {
// Get the first resource
const resourceType = (Object.keys(this.store).length > 0) ?
Object.keys(this.store)[0] :
RESOURCE_ENERGY
// Get its amount
const resourceAmount = this.store.getUsedCapacity(resourceType)
// ....
}
What should have happened?
You can use the following code to fix this problem (this fix has been updated by replying from @fangxm):
// creep.work() will execute every tick
Creep.prototype.work = () => {
if (this.ticksToLive === CREEP_LIFE_TIME) return;
}
How can we reproduce this?
You can find the reproduce from @fangxm reply below.