My code doesn't flow as intended
Calfa last edited by
I have 2 big groups of creeps. One group controls each colony and the other group depends on flags. My issue is that creeps depending on flags are being created before the creeps that control the colony, and don't understand why.
Here's how my code is supposed to flow (each entry is a different module):
Main: 1.- ClearMemory 1.1- This Deletes dead creeps from memory 1.2- This deletes non-existing flags from memory 2.- RoomManager 2.1- ClearRoomMemory 2.2- SetMemory 2.3- CountCreeps 2.3.1- SpawnCreeps <---- This is what tells my code what creeps 3.- CreepManager -> This calls role modules 4.- FlagManager -> This tells 2.3.1 to spawn creeps when needed.
As shown above, flagManager runs after RoomManager has ran, so i don't see why creeps are created in the opposite order. Any idea?
it's not easy to say without checking your code but if you have two calls calling to spawn a creep on the same spawn the last one will get executed.
I have a similar system with room creeps and flag creeps.. but I create a list of creeps I need and then decide by priority which one to spawn
Calfa last edited by Calfa
@w4rl0ck Oh! Then it must be this. I used "console.log()" in different places and the code flows in the order i expected. The only reason i see is what you say.
I also wondered about making a list (someone suggested me to do a Spawn Queue) but i din't see how. What i'm going to do while i investigate on how to do that spawn queue is to set the room as isSpawning, so when the code gets to the part that controls creeps depending on flags is not allowed to spawn another one.
Thank you so much!!!
EDIT: It's fixed!!! Thank you again!!