Subject says it all. I would like to know if my host interpreter is running Lua 5.2 or 5.1
From the lua docs: -v show version information. there doesn't seem to be just a lua -v in Debian, at least couldn't find it, need to give some liblua5. x -v to get the actual version.
The current release is Lua 5.3. 6, released on 25 Sep 2020.
The lua_State is basically a way to access what's going on in the Lua "box" during execution of your program and allows you to glue the two languages together.
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'] or 'Lua 5.4' --]] print(version)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With