Spielerando

Whole days pass in my game when the player switches to another window and comes back

A day and night clock that follows the real time jumps forward when the game was paused by the computer, and the shops open and close in a blink. Your AI can limit how much time one step may add and show the clock as day and hour without errors before day one.

Why this works

While the window is hidden, the next step reports the whole time away as one huge step. Clamping a step to a small maximum keeps the world calm, and expressing time with floor rather than truncation keeps negative or early values correct.

When not to use it

If time away is meant to count, such as crops growing while the player is out, calculate it once on return from the saved time and apply it in a controlled way, not as one step.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 25 lines of example code with 3 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Whole days pass in my game when the player switches to another window and comes back" (read_entry rpg-game-clock-jumps-after-tab-switch) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP