Test Love Version

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
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Test Love Version

Post by tentus »

Is there a way to check which version of Love is being used to run the game? Right now if you try and run my game (which was intended for 0.7.0) in a copy of Love 0.6.2, you'll get the Love bluescreen. I would like to be be able to test if you're using < 0.7.0, and render a more user-friendly error screen.
Kurosuke needs beta testers
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Test Love Version

Post by bartbes »

There are love._version, love._version_string and love._version_codename.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Test Love Version

Post by tentus »

I couldn't find them in the wiki (this may be a deficiency in the search function or between my keyboard and chair, I'm not sure). Could you provide some details about how they work? Is love._version an int like the version defined in conf.lua?
Kurosuke needs beta testers
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Test Love Version

Post by Robin »

tentus wrote:I couldn't find them in the wiki (this may be a deficiency in the search function or between my keyboard and chair, I'm not sure).
It's undocumented. The leading underscore signifies that.
tentus wrote:Could you provide some details about how they work? Is love._version an int like the version defined in conf.lua?
In a main.lua:

Code: Select all

print(love._version) 
print(love._version_string)
print(love._version_codename)
Output

Code: Select all

70
0.7.0
Game Slave
Help us help you: attach a .love.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Test Love Version

Post by thelinx »

Robin wrote: In a main.lua:

Code: Select all

print(love._version) 
print(love._version_string)
print(love._version_codename)
Output

Code: Select all

70
0.7.0
Game Slave
Note that love._version is set to 070, which evaluates to 70.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Test Love Version

Post by tentus »

Robin wrote:
tentus wrote:I couldn't find them in the wiki (this may be a deficiency in the search function or between my keyboard and chair, I'm not sure).
It's undocumented. The leading underscore signifies that.
tentus wrote:Could you provide some details about how they work? Is love._version an int like the version defined in conf.lua?
In a main.lua:

Code: Select all

print(love._version) 
print(love._version_string)
print(love._version_codename)
Output

Code: Select all

70
0.7.0
Game Slave
By having this discussion, we document it. :) Or at the very least, we make it so that people searching the forum have a marginally higher chance of finding out what they want to know.

This is how I ended up using the information you guys provided (trimmed down for clarity)

Code: Select all

function love.load()
	if love._version >= 70 then		-- require at least love 0.7.0 to play
		-- do normal game stuff
	else
		function love.draw()
			love.graphics.print("You are running too old a version of Love", 0, 0)
		end
		function love.keypressed(key, unicode)
			love.event.push('q')
		end
	end
end
Kurosuke needs beta testers
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Test Love Version

Post by TechnoCat »

tentus wrote:

Code: Select all

function love.load()
	if love._version >= 70 then		-- require at least love 0.7.0 to play
		-- do normal game stuff
	else
		function love.draw()
			love.graphics.print("You are running too old a version of Love", 0, 0)
		end
		function love.keypressed(key, unicode)
			love.event.push('q')
		end
	end
end
Also note that 0.5.0 used load(), not love.load().
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Test Love Version

Post by Robin »

TechnoCat wrote:Also note that 0.5.0 used load(), not love.load().
We still want to account for people running 0.5.0?

From memory, I think adding this takes care of that:

Code: Select all

function draw()
	love.graphics.draw("You are running a very old version of Love, time to upgrade!", 0, 0)
end
function keypressed(key)
	love.system.exit()
end
Ah, nostalgia.
Help us help you: attach a .love.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Test Love Version

Post by zac352 »

I think that the version information shouldn't have a _ in front, it makes it seem internal, and a bad idea to use (like _openConsole in windows). I think the _ should be removed, or new values added in without the _ and just deprecate the old ones. But I'd recommend waiting for another major update, like when we go to 0.8.0? :3
Hello, I am not dead.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Test Love Version

Post by bartbes »

There's also love._version_compat, a table listing all versions this version is compatible with. (or should, anyway, currently it just has 0.7.0)
Post Reply

Who is online

Users browsing this forum: No registered users and 50 guests