Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Lua, is there a function that will tell me what current version I'm running?

Tags:

Subject says it all. I would like to know if my host interpreter is running Lua 5.2 or 5.1

like image 907
henryaz Avatar asked Apr 27 '13 21:04

henryaz


People also ask

How do I check my Lua version?

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.

What is the current version of Lua?

The current release is Lua 5.3. 6, released on 25 Sep 2020.

What is a Lua state?

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.


1 Answers

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) 
like image 141
Egor Skriptunoff Avatar answered Oct 17 '22 07:10

Egor Skriptunoff