All I know is how to do it from command line, that is the -v
switch.
I need something like phpversion()
or sys.version
in python. Is that possible ?
Lua 5.4 was released on 29 Jun 2020. Its main new features are a new generational mode for garbage collection and const and to-be-closed variables.
To exit the interactive mode and the interpreter, just type end-of-file ( ctrl-D in Unix, ctrl-Z in DOS/Windows), or call the exit function, from the Operating System library (you have to type os. exit()<enter> ).
The Command Lua API allows users to control behaviour of Command directly by using the Lua scripting language, providing a flexible and easy to use tool for users to extend or customize the built-in functionality of Command.
Lua is not directly interpreted through a Lua file like other languages such as Python. Instead, it uses the Lua interpreter to compile a Lua file to bytecode. The Lua interpreter is written in ANSI C, making it highly portable and capable of running on a multitude of devices.
1 Answer 1. As the duplicate question says, the standard way to get Lua version is: There is another way: calling lua -v directly: Note that io.popen is not portable, but it should work in both Linux and Windows. But for the latter I would need the location of lua executable file.
The second method is in Windows file explorer, drag .lua file to lua.exe, it will start lua.exe and pass .lua file as a parameter, the same works for .wlua file and wlua.exe. The third method is when you ship the software, compiling the interpreter will lua code file path hard coded.
If you also need the third digit in Lua version (not available in _VERSION) you need to parse the output of lua -v command on the command line. For platforms that support io.popen this script will do the trick, but only if the script is run by the standalone interpreter (not in interactive mode).IOW the arg global table must be defined:
As the duplicate question says, the standard way to get Lua version is:
print(_VERSION)
Anyway, _VERSION
will contain a string like Lua 5.1
, but it's not the same as lua -v
, which outputs the whole version information including min version number like Lua 5.1.4
There is another way: calling lua -v
directly:
io.popen("lua -v") --Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
Note that io.popen
is not portable, but it should work in both Linux and Windows.
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