You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AM2R-The-Horde-Multitroid/scripts/wrap.gml

39 lines
790 B

///wrap(value,min,max)
//returns the value wrapped. If it is above or below the threshold it will wrap around
var _val=argument[0];
var _max = argument[2];
var _min = argument[1];
if(_val mod 1 == 0)
{
while(_val > _max || _val < _min)
{
if(_val > _max)
{
_val=_min + _val - _max - 1
}
else if (_val < _min)
{
_val=_max + _val - _min + 1;
}
else
_val=_val;
}
return(_val);
}
else
{
var _old = argument[0]+1;
while(_val != _old)
{
_old=_val;
if(_val<_min)
_val=_max-(_min-_val);
else if(_val >_max)
_val=_min+(_val-_max);
else
_val=_val;
}
return(_val)
}