Project Zomboid

Project Zomboid

Stat Tweaks Lib
Dr. Lalaoz  [developer] 26 Jan @ 5:42pm
Modder's Guide
This is a quick write up of how the library works and how to use it. its not perfect but i'm running out of time in the day lol.

This library is very simple.
this mod creates a table in player mod data called StatsLib;

local StatsLib = getPlayer():getModData().StatsLib

This table has everything you need to use the library.
The main function of stat tweaker is to let you create your own stat gain/loss modifiers. things like +25% endurance gain or -50% hunger loss. (something vanilla zomboid doesn't let you do)

to use these systems you will simply create a value inside of the respective gain/loss table for whatever stat you want. all of them will be descendants of the main StatsLib table.
the tables are defined as; StatName + Effect + "Modifiers"
The only exception to this rule is Unhappiness being shortened to just Unhappy. otherwise all other stat names are fully spelled.

Heres the full list of the current stats that can be modified;

Endurance
Fatigue
Hunger
Thirst
Stress
CigStress
Unhappy
Boredom
Panic

Other stats can be added upon request, this was a rush job to get the mod out by the end of the weekend.

Here are some code examples;

To add a +50% Endurance Gain Modifier you would create a value in that table;
StatsLib.EnduranceGainModifiers.YourUniqueStatModifierName = 1.5

or a -50% Hunger Loss would be
StatsLib.HungerLossModifiers.SomeOtherStatIdentifier = 0.5

The name of the values you create in each modifiers table does not matter, its simply used to asign that value a name so you can change it later or remove it.

So if you wanted to create a temporary Fatigue Gain modifier, you could do;
StatsLib.FatigueGainModifiers.MyTemporaryModifier = 0.75 -- -25% fatigue gain

then once you want to turn it off you can run;
StatsLib.FatigueGainModifiers.MyTemporaryModifier = 1 -- Anything x1 is itself.

You can also use
StatsLib.FatigueGainModifiers.MyTemporaryModifier = nil -- this effectively removes MyTemporaryModifier from the table. this is not permanent and you can always asign a value again.

The library will multiply all of their respective values together when changing the gain/loss of a stat.
so if multiple mods have modifiers, they will stack multiplicatively
ie; if Mod1 = 1.5 and Mod2 = 1.25 then the stat will be multiplied by (1.5*1.25) or x1.875.
This also works with reductions.

NOTE: these tables are persistent, so your mod should probably account for gaining/losing traits or effects and update its modifier accordingly. otherwise the value will remain in that table permanently and will never turn off.

you can edit/change this value as often as you like. for example the Expeditious trait checks every 60 ticks to see if you are sprinting, and if you are it sets its endurance loss modifier to 0.25.

Inside of StatsLib there are a ton of tables, but they're all named according to the following rules;
StatName + Effect + "Modifiers"
so to



Another thing stat tweaker can do is change stats gradually over time instead of instantly.
this is nice for stat bars mods, or to just make an effect happen over several seconds instead of instantly.

In order to use it, simply add or subtract numbers from StatsLib.StatName"Change"
examples;
StatsLib.EnduranceChange = StatsLib.EnduranceChange + 0.5
StatsLib.StressChange = StatsLib.StressChange + 0.25
StatsLib.UnhappyChange = StatsLib.UnhappyChange - 30

The only real note here is that gradual changes do not use a normalized value.
so Unhappiness needs its values from 0-100, while Stress needs values from 0-1.
Boredom and Panic also use 0-100. but those are the only ones that do.


I may update this mod to make it more user friendly, such as adding functions for changing/adding values for people who find that easier. but for right now this is how it is.
Last edited by Dr. Lalaoz; 26 Jan @ 5:42pm