Add bitmask function

This commit is contained in:
zontreck 2024-08-13 21:10:21 -07:00
parent 4b9e19425a
commit d90238d45f
2 changed files with 26 additions and 1 deletions

View file

@ -377,4 +377,25 @@ string inv2Perms(string inventory, integer iMask)
else
output += "none";
return output;
}
}
/*
Usage: i = mask (SET, i, BITMASK)
i = mask (FALSE, i, BITMASK)
*/
integer mask(integer states, integer source, integer mask)
{
if(states==TOGGLE)
{
return source ^ mask;
}
if(states)
{
source = source | mask;
return source;
}else {
source = source &~ mask;
return source;
}
}

View file

@ -18,3 +18,7 @@ integer THIRTY_DAYS = 2592000; //(((60*60)*24)*30);
list g_lCheckboxes = ["□","▣"];
list g_lDSRequests;
integer TOGGLE = 2;
integer SET=1;
integer UNSET=0;