talkgroup

What is the best way of targetting multiple love2d versions?

So I ordered a RG 350 and im waiting on it to arrive, but I note that love2d is built into it’s firmware, and the GCW Zero’s. So it struck me that it would be pretty cool if I could write a love2d game that could run on these devices. Though their version of love2d is a little dusty as the devices only have OpenGLES support. Limiting them to version 0.91. Current love2d is at version 0.11.x and love breaks API between minor versions but not revisions.

As I wait on the device to come in I wonder what’s the best way to target different love2d versions. So that the same codebase runs on these heandhelds, and on a newer desktop version of love. Im a stranger to lua but i’ts interpretted. So we can just make the API calls that do break conditional and check the version to choose between them. I tested this somewhat in love2d 0.9.1. (KDE Neon’s default package of love2d follows Ubuntu LTS, but it should jump to something recent soon, as the new LTS for Ubuntu dropped.)

function love.draw()
    local major, minor, revision, codename = love.getVersion()
    
    if ( minor ~= 9 ) and ( revision ~= 1 )
    then
        love.graphics.fakecall("This api doesn't exist and will crash the interpreter.")
    else
        love.graphics.print('Hello World!', 400, 300)
    end
end

(The above shouldn’t work in a compiled language, but appears to work in love2d because it’s interpreted.)

But is there a better way? Does lua suport macros? Like in c/c++ id be tempted to to use #define & #ifndef

Also whats the best way of running multiple versions of love2d on one’s laptop? They provide appimages for more recent versions as a matter of course, but that practice started after 0.9.1.

  • Debian or ubuntu chroot?
  • When you SSH into one of these handhelds, do they support forwarding X apps locally? with the -x parameter? I always got the impression they were using a framebuffer though and not full blown X. If thats true, their local love2d executable + associated libraries won’t be compiled to make use of X.
  • Virtual Machine?
  • Compile it myself?
  • pkgsrc / guix / nix
2 Likes