Event system
-
Hi,
I'm coding my scripts with an event system but the thing is that when a creep is dead, the event is still there and is triggered with an error saying that the creep cannot be found in the room.
I do not want to reload the events on every ticks, it would use memory.
I have added getObjectById method, but strangely I still get this error.
I was thinking that the creep is dying during the tick, but it can't appen, can it?
-
Not sure I understand the problem. What condition do you check to trigger the event?
Game.creeps.creepName will become undefined when the creep is dead.
Game.getObjectById(creepId) will return null when the creep is dead.
But Memory.creeps.creepName persists even after the death of the creep.
-
I think I found the problem.
My event system needs to be empty after each tick, so it does not trigger error on deleted objects on the map.
Since there is no way to guess what objects would need to be unregistered in the event system following the previous tick. (creeps dead etc...)