Create an array in main loop
-
I'm trying to create an array in my main loop to keep track of active squads of military creeps. The problem is that when the game detects that it needs to push a new squad to the array, it does it and the array returns length = 1, but as soon as the loop encounters the code again, the array length is 0 and it executes the push command again. Can anyone help me here? is there a problem with pushing strings into an array in the main loop? Is it possibly a scope issue?
-
the short answer is, if you want to persist data from one tick to the next tick you need to store it in the "Memory" object. Screeps is running on multiple servers and every tick might get handled by a different server.
http://support.screeps.com/hc/en-us/articles/205960931-Server-side-architecture-overview
-
vulgarwozard checkout the slack channel for screeps there are a ton of players on it that will usually help answer questions like this. http://chat.screeps.com