Secret Santa 2024
Prev Previous Post   Next Post Next
Original Post
suo got bored. Lua now more powerful.
Yep. Added a way to do bitwise functions. Kinda random, but I was, as I said, bored.

Kinda abstract, how it works... no examples either. But it does work.

You're probably gonna wanna use it via "dofile()", if you use it at all. Or you could just copy paste the table and functions into your own lua.

A basic thing to start off learning how to use it with would probably be:

dofile("bitwise.lua")

x = new_bitwise(8) -- 8 is the max size, in bits. Maximum possible size is around 50.
x:set_a(16) -- First number, the one returned with get_int().
x:set_b(15) -- The number that is operated with...
x:do_or() -- Do an "or" operation.
echo(x:get_int()) -- Say what we got. (31)
x:do_xor() -- Do an "exclusive or" operation (still with 15 as b, but 31 as a).
echo(x:get_int()) -- Say what we got. (16)
x:do_and() -- Do an "and" operation. (a = 16, b = 15)
echo(x:get_int()) -- Say what we got. (0)
x:do_not() -- Do a "not" operation. (a = 16, b doesn't matter)
echo(x:get_int()) -- Say what we got. (255, suo thinks)
Attached Files
bitwise.lua (1.8 KB, 38 views)
Squad Squad Squad lead?
The standardization of Toribash Squad roles may have gone too far!