Fix NaN Stats [B42.13-B42.18+]
Fix NaN Stats automatically detects when gameplay values become corrupted as NaN (Not-a-Number) or Infinity and safely restores them to valid values — preventing broken moodles/HUD bars, “temperature/wetness = NaN” issues, pain/health glitches, and other weird behavior caused by invalid numbers.
Sometimes a value can become NaN or Infinity due to a bug, a mod interaction, or an edge case. Once a value is invalid, many systems stop behaving correctly.
This mod is a lightweight safety net:
- Detects invalid numbers (NaN, +Inf, -Inf) in stats, nutrition, pain/health sources, thermoregulation, and worn clothing.
- Repairs only values that are actually invalid (it does not change normal values).
- Runs automatically while you play.
- Optional on-screen + log notifications when something is fixed (Mod Options).
Use this mod if you notice any of these symptoms:
- A stat/moodle looks “stuck”, behaves strangely, or never updates correctly.
- You use status-bar HUD mods (e.g. Simple Status, Modern Status) and one of the displayed bars shows weird/blank values, freezes, or behaves incorrectly.
- The Debug UI shows nan or an invalid value for a stat, nutrition value, temperature, wetness, pain, or a clothing-related field.
- You get the “body temperature = NaN” / “wetness = NaN” type of bug (especially noticeable during winter runs).
- You suspect a mod or an edge case caused numeric corruption.
You can keep it enabled permanently, or enable it temporarily to repair a save and disable it again afterward.
The mod checks every CharacterStat and repairs any value that becomes invalid.
Common examples include: Hunger, Thirst, Fatigue, Endurance, Fitness, Drunkenness, Anger, Pain, Panic, Morale, Stress, Boredom, Unhappiness, Sanity, Comfort, Wetness, Temperature, Health, ColdStrength, Sickness, etc.
- Calories
- Carbohydrates
- Lipids (Fats)
- Proteins
- Weight (fallback reset if needed)
- Repairs invalid numbers in BodyPart/BodyDamage fields that can cause global Pain to snap back to invalid values.
- Repairs BodyPart wetness and pain sources (plus related timers/fields when present).
- If a BodyPart’s Health becomes NaN, it is restored to 100 to prevent corruption loops.
- Repairs OverallBodyHealth (General Debuggers → Body) when it becomes invalid.
- Recovers from “body temperature = NaN”.
- Recovers from “wetness = NaN” (including per-body-part wetness).
- Scans Thermoregulator thermal nodes and performs a safe reset/update when needed.
- Includes BodyPart wetness recovery to prevent invalid-number feedback loops.
- Insulation (invalid → restored to a safe/script default)
- Wind Resistance (invalid → restored to a safe/script default)
- Clothing/item wetness
- Blood level
- Dirtiness
If enabled in Mod Options, the mod can display a small message over the character (and also write a log line) when it fixes something.
This helps you notice when a specific action or mod interaction produced an invalid value.
Example:
- Works in Singleplayer and Multiplayer (hosted/dedicated).
- For MP, the mod should be enabled on the server so fixes are server-authoritative and clients stay in sync.
Very low. The mod performs lightweight checks at a fixed interval and only writes values when something is actually invalid. During normal gameplay (with no NaNs/Infs), it effectively does nothing.
- Safe to add to an existing save: it only repairs corrupted values.
- Safe to remove: it does not add items, recipes, maps, or permanent content.
- It simply prevents and repairs invalid-number corruption while enabled.
- This mod is a “sanity fixer”: it does not attempt to diagnose the root cause, only to restore valid, playable values.
- If you consistently get NaNs/Infs, consider checking mod conflicts and reporting details (build number + mod list + steps to reproduce).
Possible future updates may include:
- Configurable check frequency
- Custom reset values (per stat)
- Afyrmo — Original author and main maintainer (Fix NaN Stats)
- Kaori — Helpful investigation, reproduction notes, and contributions that improved the 42.15+ fixes (thanks!)
You can find my other Project Zomboid mods here
If you find Fix NaN Stats useful, please consider leaving a thumbs up and adding it to your favorites — it helps other players discover it.
Feedback and suggestions are always welcome.
Workshop ID: 3627071412
Mod ID: FixNaNStats