Let a wand regain charges over time, even while the game was closed
A wand that refills a charge every so often is lovely, but a timer for every wand wastes work and stops when the game does. The trick is to not count at all and work out afterwards how much came back. The edges are a full wand, a clock that went back, and a charge used just before refilling.
Why this works
Time that has passed is a fact you can look up later; you don't need to watch it. Remembering only when the count last changed, and catching up when someone looks, works the same whether the game was running, paused or closed.
When not to use it
Don't let charges refill by themselves when the wand is meant as a scarce treasure, or in a game where players should rest, pay or hunt for refills. Then recharging is a choice with a cost, and the clock is a loophole.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- A diagram of every state
- 17 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 "Let a wand regain charges over time, even while the game was closed" (read_entry wand-charges-come-back-over-time-without-a-timer) 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