# Clamp (Integer)
Grammar — Clamp value between min and max
Flags —Function
Adjust the value to make sure it stays within the provided bounds.
# Arguments
int
— Valueint
— Minint
— Max
Returns — int
int libNtve_gf_ArithmeticIntClamp(
int lp_value,
int lp_min,
int lp_max,
);
# Related
Category: Math / Arithmetic
- Absolute Value (Integer) —
int
— AbsI - Absolute Value (Real) —
fixed
— AbsF - Arithmetic (Integer)
- Bitwise Arithmetic (Integer)
- Arithmetic (Real)
- Arithmetic Multiple (Integer)
- Bitwise Arithmetic Multiple (Integer)
- Arithmetic Multiple (Real)
- Ceiling (Integer) —
int
— CeilingI - Ceiling (Real) —
fixed
— Ceiling - Clamp (Integer) —
int
— libNtve_gf_ArithmeticIntClamp - Clamp (Real) —
fixed
— libNtve_gf_ArithmeticRealClamp - Cycle
- Floor (Integer) —
int
— FloorI - Floor (Real) —
fixed
— Floor - Log2 (Integer) —
int
— Log2I - Log2 (Real) —
fixed
— Log2 - Log (Real) —
fixed
— libNtve_gf_Log - Modulo (Integer) —
int
— ModI - Modulo (Real) —
fixed
— ModF - Power (Integer) —
int
— PowI - Power (Real) —
fixed
— Pow - Round (Integer) —
int
— RoundI - Round (Real) —
fixed
— Round - Pow2 (Integer) —
int
— Pow2I - Pow2 (Real) —
fixed
— Pow2 - Square Root (Integer) —
int
— SquareRootI - Square Root (Real) —
fixed
— SquareRoot - Trunc (Integer) —
int
— TruncI - Trunc (Real) —
fixed
— Trunc
# Examples
mods/heromods/alarak.stormmod — base.stormdata/LibHALA.galaxy:224
libHALA_gv_heroAlarakIsPlayerCastingDeadlyCharge[lv_player] = false;
libHALA_gv_heroAlarakActiveDeadlyChargeCasters -= 1;
libHALA_gv_heroAlarakActiveDeadlyChargeCasters = libNtve_gf_ArithmeticIntClamp(libHALA_gv_heroAlarakActiveDeadlyChargeCasters, 0, 10);
if ((libHALA_gv_heroAlarakActiveDeadlyChargeCasters == 0)) {
TriggerEnable(libHALA_gt_HeroAlarakDeadlyChargeCasterClicked, false);
mods/heromods/nexushunter.stormmod — base.stormdata/LibHNXH.galaxy:269
libHNXH_gv_heroNexusHunterIsPlayerCastingFinalStrike[lv_player] = false;
libHNXH_gv_heroNexusHunterActiveFinalStrikeCasters -= 1;
libHNXH_gv_heroNexusHunterActiveFinalStrikeCasters = libNtve_gf_ArithmeticIntClamp(libHNXH_gv_heroNexusHunterActiveFinalStrikeCasters, 0, 10);
if ((libHNXH_gv_heroNexusHunterActiveFinalStrikeCasters == 0)) {
TriggerEnable(libHNXH_gt_HeroNexusHunterFinalStrikeCasterClicked, false);
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:6195
lv_behavior = UserDataGetGameLink("CoopAbilityTychusRageBuffs", lp_rageBuff, "Behavior", 1);
lv_existingstackcount = UnitBehaviorCount(lp_targetUnit, lv_behavior);
lv_newstackcount = libNtve_gf_ArithmeticIntClamp(RoundI((UserDataGetFixed("CoopAbilityTychusRageBuffs", lp_rageBuff, "Rage Factor", 1) * UnitGetPropertyFixed(lp_tychusUnit, c_unitPropEnergy, c_unitPropCurrent))), UserDataGetInt("CoopAbilityTychusRageBuffs", lp_rageBuff, "Min Stacks", 1), UserDataGetInt("CoopAbilityTychusRageBuffs", lp_rageBuff, "Max Stacks", 1));
// Implementation
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOOC.galaxy:998
TextExpressionSetToken("Param/Expression/lib_COOC_36223CF3", "B", IntToText(lp_player));
TriggerDebugOutput(1, TextExpressionAssemble("Param/Expression/lib_COOC_36223CF3"), false);
libCOOC_gv_cCX_PlayerPrestigeIndex[lp_player] = libNtve_gf_ArithmeticIntClamp(lp_index, 0, libCOOC_gv_cCC_PLAYERPRESTIGEMAXRANK);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOUI.galaxy:1632
// Variable Initialization
lv_boundedIndex = libNtve_gf_ArithmeticIntClamp(lp_index, 0, libCOOC_gv_cCC_PLAYERPRESTIGEMAXRANK);
lv_state = "";
lv_playerAlly = libCOOC_gf_CC_PlayerAlly(lp_player);
mods/warcoop/warcoopdata.sc2mod — base.sc2data/TriggerLibs/WarCoopData.galaxy:1806
// Variable Initialization
lv_lootcount = libNtve_gf_ArithmeticIntClamp(lp_numberofLoots, 0, libWCdr_gv_dEBUG_LOOT_AWARD_MAX_LOOT);
lv_playergroup = PlayerGroupSingle(lp_player);
mods/warcoop/warcoopdata.sc2mod — base.sc2data/TriggerLibs/WarCoopData.galaxy:2490
lv_handicappedplayers = PlayerGroupEmpty();
lv_difficultylevelrangeinstance = libWCdr_gf_GetDifficultyLevelRangeInstance();
lv_difficultylevel = libNtve_gf_ArithmeticIntClamp(lp_difficultyLevel, UserDataGetInt("LegionDifficultyScaling", lv_difficultylevelrangeinstance, "MinLevel", 1), UserDataGetInt("LegionDifficultyScaling", lv_difficultylevelrangeinstance, "MaxLevel", 1));
lv_damagemultiplier = libWCdr_gf_GetDifficultyMultiplier("EnemyDamageMultiplier", lv_difficultylevel);
lv_healthmultiplier = libWCdr_gf_GetDifficultyMultiplier("EnemyHPMultiplier", lv_difficultylevel);
mods/warcoop/warcoopdata.sc2mod — base.sc2data/TriggerLibs/WarCoopData.galaxy:2633
lv_minlevel = UserDataGetInt("LegionDifficultyScaling", "PlayerHandicap", "MinLevel", 1);
lv_maxlevel = UserDataGetInt("LegionDifficultyScaling", "PlayerHandicap", "MaxLevel", 1);
lv_currentlevel = libNtve_gf_ArithmeticIntClamp(PlayerGroupCount(libWCdr_gf_GetLegendPlayers()), lv_minlevel, lv_maxlevel);
lv_scalingperlevel = UserDataGetFixed("LegionDifficultyScaling", "PlayerHandicap", "Value", 1);
mods/warcoop/warcoopdata.sc2mod — base.sc2data/TriggerLibs/WarCoopData.galaxy:3321
}
lv_newdifficultylevel = libNtve_gf_ArithmeticIntClamp(RoundI(libNtve_gf_DialogItemValue(libWCdr_gv_debugHeroSelectUI.lv_optionsPanel.lv_difficultySlider, 1)), UserDataGetInt("LegionDifficultyScaling", "LevelRange", "MinLevel", 1), UserDataGetInt("LegionDifficultyScaling", "LevelRange", "MaxLevel", 1));
if ((lv_newdifficultylevel == libWCdr_gv_legends.lv_difficultyLevel)) {
return true;