MacroMonkey.com - Home

Automation - Macro - Bot - Scripting system.



Bitwise operators:

Facilitates bitwise operations on number values.


bit.NOT(a)Returns the one's complement of a.
bit.AND(w1, ...)Returns the bitwise and of the w's.
bit.OR(w1, ...)Returns the bitwise or of the w's.
bit.XOR(w1, ...)Returns the bitwise exclusive or of the w's.
bit.lshift(a, b)Returns a shifted left b places.
bit.rshift(a, b)Returns a shifted logically right b places.
bit.arshift(a, b)Returns a shifted arithmetically right b places.
bit.bnotSame as NOT above.
bit.bandSame as AND above.
bit.borSame as OR above.
bit.bxorSame as XOR above.


Pack library:

Luiz Henrique's binary pack/unpack library; adds to the standard string library.


string.pack(f, ...)Create a structured binary record (as a string) from one or more elements.
string.unpack(s, f, [i])Unpack a structured binary record (from a string) into one or more strings and numbers.
i is optional start position.

Format:

z

Zero-terminated string.

p

String preceded by length byte (8 bits).

P

String preceded by length word (16 bits).

a

String preceded by length dword (32 bits).

A

String.

f

Float (32 bit.

d

Double (64 bit).

n

Lua number (double, 64 bit).

c

Character (8 bit, signed).

b

Byte (8 bit, unsigned).

h

Short (16 bit, signed).

H

Short/word (16 bit, unsigned).

i

Int (32 bit, signed).

I

Int/uint (32 bit, unsigned).

l

Long (32 bit, signed).

L

Long/ulong (32 bit, unsigned).

<

Little-endian. Native for us on 0x86 PC.

>

Big-endian. Java files, some other processors other then 0x86, some Network protocols, etc.

=

Little-endian (same as < this Window based setup).


Digits from 0 to 9 is repetition count.

I.E. “H2b3” is the same as “HHbbb”.


Example:

local testpack = string.pack("Ab8", "\027Lua",5*16+1,0,1,4,4,4,8,0)

local testupack = string.unpack(BinData, "bA3b8")


In particular good for use with the process library with the memory read and write functions (see below) to work directly with binary structures, etc.



Hash Library:

Data hash and checksum library.

 

MD5(Message-Digest algorithm 5):

See: http://en.wikipedia.org/wiki/Md5, http://en.wikipedia.org/wiki/Md5sum

Input is in the form of string/data block(s).

md5obj = hash.MD5([stringdata]) Create a new MD5 type, with optional first string data input.

md5obj:Add(stringdata) Add more string data input.

md5obj:Finalize() Finalize hash. Must do this before hash is valid.

 

Metamethods:

tostring(): Return MD5 as a hex string (must be Finalize()’d) first.

Test for equality MD5 == MD5.


Example:

-- Make a hash of a test string and display it

local md5 = hash.MD5(“The quick brown fox jumps over the lazy dog”)

md5:Finalize()

print(tostring(md5))



Vector Math Library:

2D and 3D vector math support.

See: http://en.wikipedia.org/wiki/Euclidean_vector


2D:

vector2    2D Vector.

vector2()    Constructor/define. Defaults components to zero.


Example:

-- Construct a 2D vector

v1 = vector2(1.2, 2.2)


To set, or get access with ‘x’ or ‘y’.

Example:

v1.x = 5.5

v1.y = 6.5

print(v1.x, v1.y)


Operators:

add: vector2 + vector2, or vector2 + Scaler

sub: vector2 - vector2, or vector2 - Scaler

mul: vector2 * vector2, or vector2 * Scaler

div: vector2 / vector2, or vector2 / Scaler

Test for equality (w/epsilon) I.E. vector2 == vector2 or vector2 ~= vector2


Examples:

v1 = v2 * 0.5

v1 = v1 + v2

v1 = v1 / v2

if v1 == v2 then print(“Equals”) end


Methods:

boolean = vector2:IsZero()Returns true if vector is zero (w/epsilon).
vector2:Neg()Negates vector.
number = vector2:Length()Returns length of vector.
length = vector2:Normalise()Normalize vector and return length of it too.
vector2:Rotate(angle)Vector as a point, rotates it by given angle.
distance = vector2:Distance(vector2)Distance to another 2D vector.
angle = vector2:Facing(vector2)Returns direction angle to another 2D vector.


3D:

vector3    3D Vector.

vector3()    Constructor/define (defaults to zero(0,0,0))


Example:

-- Construct a 3D with defaults zero for x,y,z

v1 = vector3()


-- Construct another with values.

v1 = vector3(100.0, 48.0, -20.0)


To access elements, index with ‘x’,‘y’, ‘z’.


Example:

print(v1.x, v1.y, v1.z)


Operators:

add: vector3 + vector3, or vector3 + Scaler

sub: vector3 – vector3, or vector3 - Scaler

mul: vector3 * vector3, or vector3 * Scaler

div: vector3 / vector3, or vector3 / Scaler

Test for equality (w/epsilon) I.E. vector3 == vector3 or vector3 ~= vector3


Examples:

v1 = v2 * 0.5

v1 = v1 + v2

v1 = v1 / v2

if v1 == v2 then print(“Equals”) end


Methods:

boolean = vector3:IsZero()Returns true if vector is zero (w/epsilon).
vector3:Neg()Negates vector.
number = vector3:Length()Returns length of vector.
length = vector3:Normalise()Normalize vector and return it’s length.
number = vector3:Squared()Returns squared length of vector.
number = vector3:Dot(vector3)Returns dot product.
vector3:Cross(vector3)Sets vector to cross product of another.
distance = vector3:Distance(vector3)Distance to another vector.
angle = vector3:Facing(vector3)Returns direction angle to another 3D vector on the X/Y axis (ignoring Z).
vector3:Rotate(angle)Rotates vector it by given angle on the X/Y axis (ignoring Z).