In Lua, is there a function that will tell me what current version I'm running?
问题 Subject says it all. I would like to know if my host interpreter is running Lua 5.2 or 5.1 回答1: There is global variable _VERSION (a string): print(_VERSION) -- Output Lua 5.2 UPD : Other methods to distinguish between Lua versions: if _ENV then -- Lua 5.2 else -- Lua 5.1 end UPD2 : --[=[ local version = 'Lua 5.0' --[[]=] local n = '8'; repeat n = n*n until n == n*n local t = {'Lua 5.1', nil, [-1/0] = 'Lua 5.2', [1/0] = 'Lua 5.3', [2] = 'LuaJIT'} local version = t[2] or t[#'\z'] or t[n/'-0']