A built-in function to clamp values between 0 and 100.
*comment assume variable dexterity, with value 95
*set dexterity stat(dexterity + 20)
*comment the return will be 100, despite the operation result being 115
Rationale
Stats are at the heart of ChoiceScript games and it is imperative to keep them inside the 0 to 100 range.
ChoiceScript offers built-in fairmath operations to deal with stats. However, fairmath comes with its own set of problems.
For developers, it is harder to balance a game, for players stat changes can be unpredictable, especially near the extremes.
Linear operations may be desired except for the boilerplate needed to always keep stat variables inside the range.
The stat function offers a simple interface for those developers who prefer to use linear operations instead of the ones based on percentage points. The function clamps the value between the acceptable range.
A built-in function to clamp values between 0 and 100.
Rationale
Stats are at the heart of ChoiceScript games and it is imperative to keep them inside the 0 to 100 range.
ChoiceScript offers built-in fairmath operations to deal with stats. However, fairmath comes with its own set of problems. For developers, it is harder to balance a game, for players stat changes can be unpredictable, especially near the extremes.
Linear operations may be desired except for the boilerplate needed to always keep stat variables inside the range.
The
stat
function offers a simple interface for those developers who prefer to use linear operations instead of the ones based on percentage points. The function clamps the value between the acceptable range.