Page 1 of 1
Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 2:15 pm
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?
Re: Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 3:26 pm
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.
Re: Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 4:38 pm
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.
Re: Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 4:45 pm
by bartbes
As I said, you can check love._version. 0.8.0 also brings love._version_major/minor/revision (pick one
).
Re: Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 4:52 pm
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
).
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?
Re: Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 5:25 pm
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
Re: Check LÖVE version at runtime?
Posted: Tue Nov 01, 2011 6:00 pm
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!