Test Love Version
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Test Love Version
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
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Test Love Version
There are love._version, love._version_string and love._version_codename.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Test Love Version
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Test Love Version
It's undocumented. The leading underscore signifies that.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).
In a main.lua:tentus wrote:Could you provide some details about how they work? Is love._version an int like the version defined in conf.lua?
Code: Select all
print(love._version)
print(love._version_string)
print(love._version_codename)
Code: Select all
70
0.7.0
Game Slave
Help us help you: attach a .love.
Re: Test Love Version
Note that love._version is set to 070, which evaluates to 70.Robin wrote: In a main.lua:OutputCode: Select all
print(love._version) print(love._version_string) print(love._version_codename)
Code: Select all
70 0.7.0 Game Slave
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Test Love Version
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.Robin wrote:It's undocumented. The leading underscore signifies that.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).In a main.lua:tentus wrote:Could you provide some details about how they work? Is love._version an int like the version defined in conf.lua?OutputCode: Select all
print(love._version) print(love._version_string) print(love._version_codename)
Code: Select all
70 0.7.0 Game Slave
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
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Denver, CO
- Contact:
Re: Test Love Version
Also note that 0.5.0 used load(), not love.load().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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Test Love Version
We still want to account for people running 0.5.0?TechnoCat wrote:Also note that 0.5.0 used load(), not love.load().
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
Help us help you: attach a .love.
Re: Test Love Version
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?
Hello, I am not dead.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Test Love Version
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)
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests