Check LÖVE version at runtime?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Check LÖVE version at runtime?

Post by T-Bone »

I've searched a bit for this but found nothing. Is there a way to determine the LÖVE version at runtime? My game uses gamepads, so it matters if it's running on LÖVE 0.8 or 0.7.2 or some other version. It would also be nice to have shaders implemented, and showing only if it's running in LÖVE 0.8. Or are we doomed to develop for specific LÖVE versions?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Check LÖVE version at runtime?

Post by bartbes »

There's a variable love._version, that stores the current version. Do note that in 0.8.0 love._version is equal to what love._version_string was in earlier versions (so a string representation).

As for shaders, just because people run 0.8.0 doesn't mean they support pixeleffects, there's love.graphics.isSupported for that.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Check LÖVE version at runtime?

Post by T-Bone »

bartbes wrote:There's a variable love._version, that stores the current version. Do note that in 0.8.0 love._version is equal to what love._version_string was in earlier versions (so a string representation).

As for shaders, just because people run 0.8.0 doesn't mean they support pixeleffects, there's love.graphics.isSupported for that.
So there's not way to check if it's "0.8 or higher"? I guess the best to do is to check is it's 0.7.1 or 0.7.2, and if it's not, assume that it's 0.8 or higher...? Trying to future proof here.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Check LÖVE version at runtime?

Post by bartbes »

As I said, you can check love._version. 0.8.0 also brings love._version_major/minor/revision (pick one :P).
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Check LÖVE version at runtime?

Post by T-Bone »

bartbes wrote:As I said, you can check love._version. 0.8.0 also brings love._version_major/minor/revision (pick one :P).
But you just said that 0.8.0 gives love._version as a string. Or is it like java where the string '0.8.0' is "larger than" '0.7.2'?
And does love._version_major/minor/whatever give numbers or strings?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Check LÖVE version at runtime?

Post by Robin »

T-Bone wrote:So there's not way to check if it's "0.8 or higher"?

Code: Select all

if type(love._version) == "string" and love._version >= "0.8.0" then
Help us help you: attach a .love.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Check LÖVE version at runtime?

Post by T-Bone »

Robin wrote:
T-Bone wrote:So there's not way to check if it's "0.8 or higher"?

Code: Select all

if type(love._version) == "string" and love._version >= "0.8.0" then
I had no idea you could compare strings in lua. Nice!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests