What you will complete in this lesson
This lesson has one goal: understand why Screeps code runs again, why Game.time changes, and why a Creep usually needs several ticks to complete a task.
You will perform one read-only Console observation. An optional code-editor probe logs the tick number only; it does not move a Creep, create a unit, submit a structure action, or write to Memory.
By the end, you should be able to describe Screeps as a repeated sequence:
read the current state → choose commands for this tick → let the game advance → read the new state.
What happens in one Screeps tick?
A tick is one update cycle of the Screeps world. It is closer to a turn or simulation step than to a fixed number of real-world seconds.
- The tick begins with a current game state: object positions, Stores, Controller progress, hits, cooldowns, and other properties.
- Your main module and the modules it requires run against that current state.
- Your code reads objects and submits commands for Creeps and structures.
- The other players' scripts also complete for the tick.
- The game resolves the submitted commands and prepares the state visible at the beginning of the next tick.
This timing explains an important beginner rule: after you call a movement or work method, do not expect the related object properties to show the future result immediately in the same script execution. Read the object again on a later tick.
Observe the current tick with Game.time
State impact: read-only. The following Console expression reads the current tick counter and changes nothing in the game.
Game.time;
Record the returned number. Run the same expression again later. A larger value means that the world has advanced through additional ticks.
Your numbers will not match the numbers in another account, screenshot, or tutorial. Game.time is a server-wide counter, and the real-time duration of a tick depends on server load.
Why module.exports.loop keeps running
A normal one-off JavaScript program can start, finish its work, and exit. Screeps instead operates a persistent game world, so the game repeatedly invokes the exported main loop.
module.exports.loop = function () {
// Read the current state.
// Choose this tick's commands.
};
You do not need to study the full CommonJS module system yet. At this stage, treat module.exports.loop as the main function Screeps runs for each tick.
The function should finish. Screeps provides the repetition by calling it again on a later tick.
Optional: add a controlled main-loop probe
State impact: Console logs only. Do not replace working live-colony logic with this example. Add the if block inside your existing loop, or test the complete example only in an empty tutorial branch.
module.exports.loop = function () {
if (Game.time % 20 === 0) {
console.log(
'[tick-probe] current tick: ' + Game.time
);
}
// Keep your existing colony logic here.
};
The value 20 is only a logging interval for this observation. It is not an official tick length or a special Screeps constant.
After you have seen several increasing tick numbers, remove the temporary probe so it does not keep adding routine messages to the Console.
Why one Creep task needs later ticks
Imagine a Creep that is several squares away from a Source. The complete job cannot normally finish inside one call to the main loop.
| Tick state | What the script can decide | What you inspect later |
|---|---|---|
| The Creep is outside harvest range. | Submit movement toward the Source. | Read its new position on a later tick. |
| The Creep reaches harvest range. | Submit harvest(). | Read its Store and the Source state later. |
| The Creep carries Energy. | Choose a delivery, building, or upgrading task. | Read the resulting Store or progress later. |
The exact number of ticks depends on current game state, including distance, terrain, fatigue, roads, body parts, traffic, and target availability. Do not convert a tutorial example into a fixed time promise.
When an action method returns OK, treat that as evidence that the command was accepted or scheduled. It is not proof that every visible property has already changed during the same script execution.
Avoid four common misunderstandings
A tick is not a fixed number of seconds
Official documentation states that tick duration depends on current server load. Write logic around game state and tick numbers rather than assuming an exact wall-clock delay.
The Console does not bypass tick timing
A Console command runs within one tick under the same general execution model. It can inspect current state or submit a command, but it does not create a separate instant future state for you to read.
Do not create your own infinite loop
while (true) {
// Do not use this for continuous Screeps behavior.
}
An infinite JavaScript loop prevents the current execution from finishing and can consume the CPU available for that tick. Put repeated game decisions in module.exports.loop instead.
Re-read live objects on later ticks
Game.creeps, Game.rooms, and other live game collections describe the current tick. Retrieve the current object again when the loop runs later instead of treating an earlier object snapshot as proof of the new state.
Persistent decision state is a separate topic. The later Memory guide explains how to preserve simple serializable values across ticks.
Completion check
You have completed this lesson when you can do all of the following:
- define a tick as one Screeps world update cycle;
- use
Game.timeto confirm that ticks are advancing; - explain why
module.exports.loopruns again without a manualwhileloop; - explain why movement, harvesting, and delivery usually span several ticks;
- distinguish an accepted command from a later visible state change;
- avoid assuming that a tick has a fixed number of seconds.
Continue to your first Creep action
The next lesson connects this timing model to a real unit. You will find a Creep and Source, inspect harvest() return codes, move only when range is insufficient, and observe the result across later ticks:
Make your first Screeps Creep harvest Energy →
Return to the English beginner roadmap to review the full twelve-lesson sequence, or open the glossary for short definitions of tick, game loop, return code, CPU, and Memory.