Created
March 28, 2024 01:35
-
-
Save TheGreatSageEqualToHeaven/4c57fe3e5f71c0b361282d77c787095f to your computer and use it in GitHub Desktop.
Runtime Lua version detection without _VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function luaVersion() | |
local f = function() | |
return function() end | |
end | |
if 0xffffffffffffffffffffffffffffffffffffffffffffff == 2 ^ 64 then | |
return "Luau" | |
end | |
if ({nil,[1] = true})[1] then | |
return "LuaJIT" | |
end | |
if 1/0 == 1/"-0" then | |
return ("1" + "2").."" == "3.0" and "Lua 5.3" or "Lua 5.4" | |
end | |
return f() == f() and "Lua 5.2" or "Lua 5.1" | |
end | |
print(luaVersion()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment