-
-
Save LolloDev5123/ad3461a0949c563a4fb6855558759ca0 to your computer and use it in GitHub Desktop.
Runtime Lua version detection without _VERSION
This file contains hidden or 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