How can I use Lua 5.2 for LOVE

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: How can I use Lua 5.2 for LOVE

Post by Croutonix »

Nevermind I found this lua 5.1 library which is the equivalent of bit32 library in lua 5.2.
http://www.snpedia.com/extensions/Scrib ... /bit32.lua

I could have done this with LuaJIT, maybe it would have been faster, but speed isn't key here, and it saves me work.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How can I use Lua 5.2 for LOVE

Post by zorg »

Croutonix wrote:I just need this?
local bit = require("bit")
Yes.

Also, curious how getting an external lib instead of writing one line saves you work. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: How can I use Lua 5.2 for LOVE

Post by Positive07 »

Wow, a pure Lua implementation of bit32... I wouldn't recommend that EVER, just use local bit32 = require("bit"), it's mostly compatible, maybe with a few minor differences but shouldn't matter that much, test it before going with the pure Lua alternative you suggested
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: How can I use Lua 5.2 for LOVE

Post by Croutonix »

It saves me work because bit and bit32 aren't the same.
This I don't need to write missing functions. (that I don't even understand)
But why is it so bad?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: How can I use Lua 5.2 for LOVE

Post by Positive07 »

Bit operations are hard, you need to separate the number into bits (because you can't look at the inner representation) then compare and perform operations on those bits, then combine all those bits again into a number, when you are handling 2 32bits number your are working with around 192 operations, and probably some of them may not be JIT compiled, and you most likely aren't using a single operation, you probably do more than one, and you probably do all this in a loop which adds up.

LuaJIT library does all this in a single operation compiled by the JIT compiler so it is several orders of magnitudes faster. Also the incompatibilities between bit and bit32 libraries is minimal, and if you find problems you should be able to fix them easily.

Have you find any incompatibilities between the two of them? If so what is it? Maybe we can help you fix them
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How can I use Lua 5.2 for LOVE

Post by zorg »

Also, from a cursory glance, the luajit bit lib has all the functions that bit32 lib has, maybe except some checking ones, and some may have slightly different names.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: How can I use Lua 5.2 for LOVE

Post by Croutonix »

bit32.extract, bit32.btest and bit32.replace
I replaced the other functions with luajit bit
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests