I was just thinking of a better way to define patterns than using hex numbers. Importing a full bitwise module seemed overkill, so I ended up using tonumber (e [, base])
with base 2.
which means this cryptic and obtuse hex:
pattern = { 0xF0, 0xE1, 0xC3, 0x87, 0xF, 0x1E, 0x3C, 0x78 } -- diagonal lines
becomes this much more visual and readable "binary":
pattern = { -- diagonal lines
tonumber('11110000', 2),
tonumber('11100001', 2),
tonumber('11000011', 2),
tonumber('10000111', 2),
tonumber('00001111', 2),
tonumber('00011110', 2),
tonumber('00111100', 2),
tonumber('01111000', 2),
}
we could even go further with a simple wrapper:
-- binary string to number
local function b(e)
return tonumber(e, 2)
end
pattern = { -- diagonal lines
b('11110000'),
b('11100001'),
b('11000011'),
b('10000111'),
b('00001111'),
b('00011110'),
b('00111100'),
b('01111000'),
}