Search code examples
luaversioninglove2d

How to programmatically check LOVE2D version


How would one go about making sure that a .love file only runs if the current version of LOVE2D is better than a given minimum version? Without some sort of check, the resulting errors can be obscure and seemingly unrelated to the LOVE version, requiring the user to waste a lot of time trying to diagnose issues based on misleading errors.


Solution

  • You can add t.version = "0.8.0" to your conf.lua and it will warn the user if he is using a version other than 0.8.0. You shouldn't block mismatched versions, you should warn them.

    Here's an example of conf.lua:

    function love.conf(t)
        t.title = "Game title"
        t.author = "Your name"
        t.version = "0.8.0"
    end
    

    Here's the wiki article on conf.lua.