Difference between revisions of "Comparing LÖVE Versions"
(Created page with "It's sometimes useful to check for certain LÖVE versions, for example, do automatic color conversion to 0..1 range in version 11.0 and later, and keep using 0..255 range...") |
m (i18n) |
||
(One intermediate revision by one other user not shown) | |||
Line 49: | Line 49: | ||
[[Category:Snippets]] | [[Category:Snippets]] | ||
+ | {{#set:LOVE_Version=any}} | ||
+ | {{#set:Description=Compare current LOVE version used}} | ||
+ | == Other Languages == | ||
+ | {{i18n|Comparing LÖVE Versions}} |
Latest revision as of 06:17, 17 December 2019
It's sometimes useful to check for certain LÖVE versions, for example, do automatic color conversion to 0..1 range in version 11.0 and later, and keep using 0..255 range in 0.10.2 and earlier.
Contents
Function
Synopsis
compare = compareLOVEVersion(major, minor, revision)
Arguments
Returns
number compare
- -1 if current LÖVE version is lower than specified, 0 if exactly equal, 1 if it's later version
Examples
-- LÖVE version: 0.9.2
compareLOVEVersion(0, 9, 2) -- returns 0
-- LÖVE version: 0.10.0
compareLOVEVersion(11, 1) -- returns -1
-- LÖVE version: 0.10.2
compareLOVEVersion(0, 10, 0) -- returns 1
Source
function compareLOVEVersion(maj, min, rev)
if love._version_major > maj then
return 1
elseif love._version_major < maj then
return -1
elseif min then
if love._version_minor > min then
return 1
elseif love._version_minor < min then
return -1
elseif rev then
if love._version_revision > rev then
return 1
elseif love._version_revision < rev then
return -1
end
end
end
-- equal
return 0
end
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info