From d90238d45fcedd863ac7f0cb261e616318f92eef Mon Sep 17 00:00:00 2001 From: zontreck Date: Tue, 13 Aug 2024 21:10:21 -0700 Subject: [PATCH] Add bitmask function --- functions.lsl | 23 ++++++++++++++++++++++- variables.lsl | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/functions.lsl b/functions.lsl index cffee26..d26cd0e 100644 --- a/functions.lsl +++ b/functions.lsl @@ -377,4 +377,25 @@ string inv2Perms(string inventory, integer iMask) else output += "none"; return output; -} \ No newline at end of file +} + + +/* + 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; + } +} diff --git a/variables.lsl b/variables.lsl index 8faa151..a0effba 100644 --- a/variables.lsl +++ b/variables.lsl @@ -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; \ No newline at end of file