Bitwise operators
#1
Is there anyway currently to use bitwise operators in plugins? I currently want to make a feature that either requires 12 new columns to a table and a lot of new queries, or using bitwise operators and only a few queries. I found this, and it seems that either Cuberite has to support it, or I have to use a pure Lua implementation, which I rather don't really.
Reply
Thanks given by:
#2
That could be a good candidate to upgrade lua 5.1 to 5.2.
Reply
Thanks given by:
#3
It's not build into Lua 5.1, but perhaps this wil help: http://nova-fusion.com/2011/03/21/simula...rs-in-lua/
Reply
Thanks given by:
#4
There is no built-in support in Cuberite so far. However, it should be fairly straightforward to implement some simple bitwise logic directly in lua, using regular math operations. It will not be as performant as C/C++, but it might be more performant than actually exporting an API for that (anyone care to bench-test this hypothesis? Smile
Reply
Thanks given by:
#5
You mean actually editing the Lua lib to support <<, >> and | or just exporting a function to the API? I'm kinda opposed to changing the Lua library in case we're going to update Lua (or replace with LuaJit) some day.
Reply
Thanks given by:
#6
Does Lua 5.2 support them? Are you guys planning on upgrading to 5.2 anytime soon then?
Reply
Thanks given by:
#7
http://lua-users.org/wiki/BitwiseOperators
Reply
Thanks given by:
#8
Woops, totally missed the very first line of that page lol. So are you planning on upgrading sometime soon?
Reply
Thanks given by:
#9
I tried once, but it crashed in LuaState and I gave up for want of knowledge. I'm sure it is possible, with much contribution from xoft.
Reply
Thanks given by:
#10
(08-19-2016, 11:16 PM)xoft Wrote: There is no built-in support in Cuberite so far. However, it should be fairly straightforward to implement some simple bitwise logic directly in lua, using regular math operations. It will not be as performant as C/C++, but it might be more performant than actually exporting an API for that (anyone care to bench-test this hypothesis? Smile

I had to work with individual byte mechanics here to get plugin messages handled in a sane manner. Note: that is one of the first things I ever programmed, and I *know* it was extremely broken at some point (to the point of screwing up every single non-string value) and I somewhat doubt I ever got around to fixing it (the associated plugin only used the string method). So while the theory may be valid, the implementation is likely... flawed to say the least. I'd do a complete rewrite of that entire repository before I recommended it to anyone, but the math at least worked.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)