获取包含lua文件的路径 [英] Get containing path of lua file

查看:1041
本文介绍了获取包含lua文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法来获取当前正在执行的lua脚本文件的路径?

这不是当前的工作目录,可能完全不同。我知道 luafilesystem 将让我得到当前的工作目录,但似乎并不能够告诉当前正在执行的脚本文件。



谢谢

编辑:
我是没有从标准的命令行解释器运行,我正在通过 luabind

解决方案

如果标准命令行解释器正在运行Lua脚本,请尝试 arg [0]


I am wondering if there is a way of getting the path to the currently executing lua script file?

This is specifically not the current working directory, which could be entirely different. I know luafilesystem will let me get the current working directory, but it doesn't seem to be able to tell the current executing script file.

Thanks

EDIT: I'm not running from the standard command line interpreter, I am executing the scripts from a C++ binary via luabind.

解决方案

If the Lua script is being run by the standard command line interpreter, then try arg[0].

这篇关于获取包含lua文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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