Module initialization code not running every tick
-
I have a module that requires code to run every tick. I attempt to do this by constructing a new object, placing this code in the constructor and passing that as the export of the module, but the code is only running once every 8 or so ticks. This code should be running every tick.
-
Read up on this - http://support.screeps.com/hc/en-us/articles/204825672-New-main-loop-architecture
And this - http://support.screeps.com/hc/en-us/articles/203032752-Understanding-game-loop-time-and-ticks
-
specially if your using the constructor of an exported module it will only "construct" when the module constructs which is infrequently. It should be happening once every 30 ticks or maybe even less.
I would have to see the code to be sure, but generally, a good pattern for screeps is to have a tick() function and do your setup there, leave module level constructors for free temporary volatile memory, and config settings.