Add bitmask function
This commit is contained in:
parent
4b9e19425a
commit
d90238d45f
2 changed files with 26 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue