Page 1 of 1

love2d 0.10.2 unable to load bytecode from luac 5.1

Posted: Sun Feb 26, 2017 5:16 pm
by entuland
Hello everybody,
I'm beginning to learn Lua and the lovely love2d framework.

I've created a simple main.lua with the three main love functions (load, update, draw) and tested it running love somefolder (where the actual file is somefolder/main.lua). All is fine, the program runs, draws the graphics, reads the keyboard input and so forth.

Then I created anotherfolder and run luac -o anotherfolder/main.lua somefolder/main.lua and tried running love anotherfolder, but I got a message saying that the bytecode is incompatible (it also report some sort of hex address and mentions in function "require", in function "xpcall").

Luac is version 5.1. Love2d is version 0.10.2.

I tried searching through the web and these forums, also tried asking on IRC in the #lua and #luajit channels, no response so far.

Any pointer to help me understand the problem and to find a solution?

Thanks a lot for your attention!

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Posted: Sun Feb 26, 2017 5:36 pm
by slime
Lua bytecode is incompatible between different versions of Lua. By default, love uses LuaJIT 2.0 rather than Lua 5.1 (although LuaJIT is backwards compatible with Lua 5.1 source code).

There's generally no reason to use bytecode anyway.

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Posted: Sun Feb 26, 2017 6:06 pm
by entuland
Thanks for the feedback slime, I'm just fiddling with the language and the tools to get a grip about what can be done in general.

I tried compiling with the LuaJIT 2.1 windows binary that comes with LuaPower, but that resulted in a further incompatibility error, I guess I should find a LuaJIT 2.0 windows binary (although I cannot find it anywhere, maybe I'll have to set up all the stuff to be able to create it myself using LuaDist or the alike)

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Posted: Sun Feb 26, 2017 6:28 pm
by slime
I believe you can do something like this to generate bytecode with just LÖVE:

Code: Select all

local filefunc = love.filesystem.load("myfile.lua")
local bytecode = string.dump(filefunc)

love.filesystem.write("myfile.luac", bytecode)

love.system.openURL("file://"..love.filesystem.getSaveDirectory()) -- open an Explorer window to the saved file.

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Posted: Sun Feb 26, 2017 7:29 pm
by entuland
Thanks a lot for pointing out this other approach slime, I'll investigate it further!

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Posted: Mon Mar 13, 2017 3:00 am
by Snake174rus