Bit Operations

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

ashplayah
decaying skeleton
decaying skeleton
Posts: 8
Joined: Tue Dec 10, 2002 5:55 pm

Bit Operations

Post by ashplayah » Wed Dec 11, 2002 2:00 pm

I've added some bit operations on variables:

/varor <variable> <bitmask as a decimal number>
/varand <variable> <bitmask as a decimal number>
/varlshift <variable> <number to shift>
/varrshift <variable> <number to shift>

I've added bit compares to /if:
/if a&b /do something
/if a|b /do something
Note: a and b are decimal numbers

Also in this delta I have added a count to $alert()
$alert(<number>,count) will return the count of members in the alert

I've posted the delta to a MSN's free webhosting service (you need to sign in with a passport):
http://groups.msn.com/AshPlayah/Documents/MQDelta.zip

I will mirror it somewhere else once I have a better webhoster...

Please take a look and drop me some comments or (hopefully) include it in the next release.

Ashplayah

Note: alerts are not cleared between runnings of macros so if you do not /alert clear <number> before you add stuff to an alert you may have old alert data still present.

Samples:

Code: Select all

/varor v1 9
/varand v1 1
/echo $v1  | displays 1
/varlshift v1 2
/echo $v1  | displays 4
This is how I use it (to process multiple random prioritized events):

Code: Select all

Sub Event_Event1
   /varor v1 1
/return

Sub Event_Event2
   /varor v1 2
/return

Sub Event_Event3
   /varor v1 4
/return

Sub Process_Events
   /if v1&1 {
      /call Handle_Event1
   } else /if v1&2 {
      /call Handle_Event2
   } else /if v1&4 {
      /call Handle_Event3
   }
/return
I tried to do bitmasks as hex but I couldn't guarantee that they are in a general sense as /varor v1 &v2 will produce a non-hex mask... so we are stuck with decimal masks

xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 12:49 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 1:26 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 1:27 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 1:28 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 1:30 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 2:07 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 2:08 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 2:09 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 2:10 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 2:11 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 2:48 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 3:26 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 4:02 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Bit Operations

Post by xyilla » Tue Aug 12, 2025 4:03 pm