Skip to content

Instantly share code, notes, and snippets.

@LolloDev5123
Forked from TheGreatSageEqualToHeaven/LuaVersion.lua
Created January 28, 2025 15:00
Show Gist options
  • Select an option

  • Save LolloDev5123/ad3461a0949c563a4fb6855558759ca0 to your computer and use it in GitHub Desktop.

Select an option

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