10.05.2018, 07:56
It's much better to use bit functions for setting bits:
The only thing I don't understand is why you have 1-byte value and bool values setting the same bits. How many writable bits are there?
Code:
function setbit(value, nr)
return bit.bor(value, bit.lshift(1, nr))
end
value = 0
value = setbit(value, 0)
value = setbit(value, 1)
value = setbit(value, 9)
log(value) -- result: 515
The only thing I don't understand is why you have 1-byte value and bool values setting the same bits. How many writable bits are there?