LUA VERSION
From codeTank
Contents |
Description
_LUA_VERSION is a string that contains the current version of Lua. The format of this string will always be in the format of either: "Lua x.y" or "Lua x.y.z", where x is the major version, y is the minor version, and the optional z is the revision.
Example
print(_LUA_VERSION) -- output: Lua 5.1.2 -- extract the sub-version numbers using pattern matching local ver = {} local w = "" for w in string.gmatch(_LUA_VERSION, "%d+") do ver[table.getn(ver) + 1] = tonumber(w); end ver[3] = ver[3] or 0 -- if revision isn't specified, then assume 0 print("Maj = " .. ver[1]) -- output: Maj = 5 print("Min = " .. ver[2]) -- output: Min = 1 print("Rev = " .. ver[3]) -- output: Rev = 2
Extra Notes
Please be aware that this is different than the _VERSION value, which is the default Lua mechanism for detecting the Lua version. This alternate was created to include the revision number, because _VERSION will only return the major and minor numbers.
E.g., _LUA_VERSION = "Lua 5.1.2", but _VERSION = "Lua 5.1"

