Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions msu/utils/math.nut
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,11 @@
local tens = ::pow(10, _decimalPlaces);
return ::Math.floor(tens * _num) / tens;
}

// The return has the same type as that of _value
function clamp( _value, _min, _max )
{
local ret = _value < _min ? _min : (_value > _max ? _max);
return typeof _value == "integer" ? ret.tointeger() : ret.tofloat();
}
};