I mean the condition in the script.
Added 4 minutes later
Here's an example: Let's say, 10 spells and 14 knowledge at the start. A knowledge stat comes: spells = 10 + (14-10)/2 = 12 12/15 Another knowledge stat comes: spells = 12 + (15-12)/2 = 13 13/16 A spell stat comes: +1 spell 14/16 +4 to the spell stat comes: +2 to the spell. 16/16 If we want to keep the excess, then the difference when exceeding can be calculated as zero (16-18) == 0.