love2d 0.10.2 unable to load bytecode from luac 5.1

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.
Post Reply
entuland
Prole
Posts: 6
Joined: Sun Feb 26, 2017 4:41 pm

love2d 0.10.2 unable to load bytecode from luac 5.1

Post 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!
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Post 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.
entuland
Prole
Posts: 6
Joined: Sun Feb 26, 2017 4:41 pm

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Post 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)
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Post 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.
entuland
Prole
Posts: 6
Joined: Sun Feb 26, 2017 4:41 pm

Re: love2d 0.10.2 unable to load bytecode from luac 5.1

Post by entuland »

Thanks a lot for pointing out this other approach slime, I'll investigate it further!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 75 guests