从文本文件运行lua程序 [英] Running a lua program from a text file

查看:90
本文介绍了从文本文件运行lua程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习Lua,并且我正在尝试让本地Lua解释器运行已保存到.txt文件的程序.我正在使用Lua 5.1.4运行Windows Vista.

I've just started learning Lua, and I'm trying to get the native Lua interpreter to run a program that has been saved to a .txt file. I'm running Windows Vista with Lua 5.1.4.

也许我遗漏了一些东西,但是我的书(在Lua中编程)唯一说的是,运行程序所要做的就是调用带有解释器的解释器.包含您的程序的文本文件的名称.然后,它给出了这段据说很方便的代码:

Perhaps I'm missing something, but the only thing my book (Programming in Lua) says is that all you have to do to run your program is to call the interpreter with the name of the text file that contains your program. Then it gives this supposedly handy piece of code:

% lua filename.lua

我无法使用cmd或Lua解释器工作.我所做的进一步研究表明,我可能需要使用

Which I can't get to work in cmd or in the Lua interpreter. Further research I've done indicates that I might need to use a

dofile("filename.lua")

命令,但是我不确定如何执行此操作.具体来说,我需要在参数中输入哪些信息?您能提供的任何帮助将不胜感激.

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

推荐答案

您需要下载Win32二进制文件(请参见 lua-5.2.1_Win32_bin.zip或lua-5.2.1_Win64_bin.zip在这里).将其解压缩到某个地方.如何按照易用性和相反的顺序或常见过程来运行脚本:

You need to download a Win32 binary (see lua-5.2.1_Win32_bin.zip or lua-5.2.1_Win64_bin.zip here). Unzip this somewhere. How to run your script, in order of easiness and inverse order or common procedure:

  1. 使用Windows文件资源管理器将脚本拖到Lua.exe.

  1. Drag your script onto the Lua.exe using the Windows file Explorer.

a.将脚本移至Lua.exe所在的文件夹中.
b.在该文件夹上单击鼠标右键,然后选择Open Command Window Here.
C.键入lua filename.lua并按Enter.

a. Move your script to the same folder as Lua.exe
b. Shift right-click on that folder and select Open Command Window Here.
c. Type lua filename.lua and press Enter.

将包含Lua.exe的目录添加到您的系统路径 ,然后在包含脚本的文件夹上执行步骤2a和2b.

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

这篇关于从文本文件运行lua程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆