Running lua from a text file

I was just starting to learn Lua, and I'm trying to get the Lua interpreter to use a program that was saved in a .txt file. I am running Windows Vista with Lua 5.1.4.

Maybe something is missing me, but the only thing my book (Programming in Lua) says that all you need to do to run your program is to invoke an interpreter with the name of the text file that contains your program. He then gives this supposedly convenient piece of code:

 % lua filename.lua 

I cannot work in cmd or in the Lua interpreter. Further research that I have done shows that I may need

 dofile("filename.lua") 

but I'm not sure how to do this. In particular, what information do I need to include in the argument? Any help you can give is greatly appreciated.

+4
source share
1 answer

You need to download the Win32 binary (see lua-5.2.1_Win32_bin.zip or lua-5.2.1_Win64_bin.zip here ). Unzip it somewhere. How to run a script in simplification and reverse order or general procedure:

  • Drag and drop your script onto Lua.exe using Windows Explorer.

  • a. Move your script to the same folder as Lua.exe
    b. Right-click on this folder and select Open Command Window Here .
    with. Type lua filename.lua and press Enter.

  • Add the directory containing Lua.exe to the PATH system , then follow steps 2a and 2b in the folder containing your script.

  • The integration of Lua.exe with your editor in some way (how you do this depends on your editor).
+3
source

Source: https://habr.com/ru/post/1436720/


All Articles