简体   繁体   English

如何在lua中打开文件

[英]How to open a file in lua

How to open a file on desktop in lua program? 如何在lua程序中在桌面上打开文件? Is there a simple way to do it? 有简单的方法吗?

I'm trying to make a addon for a game so when I'm in combat, It opens my mp3 file on my computer. 我正在尝试为游戏制作插件,因此在战斗中,它会在计算机上打开mp3文件。 It's running on Windows 10. 它在Windows 10上运行。

To open a file in it's registered application you can use os.execute('start [file_path]') , as stated by Henri and Bartek 如Henri和Bartek所述,要在已注册的应用程序中打开文件,可以使用os.execute('start [file_path]')

the registered application is the application that launches when you double click the file icon, it is determined by the file's extension Examples: .lua , mp3 , .txt . 注册的应用程序是双击文件图标时启动的应用程序,它由文件的扩展名决定。示例: .luamp3.txt

You can find/change the application in the properties window of the file on a windows system: 您可以在Windows系统上文件的属性窗口中找到/更改应用程序:

属性窗口

The start param is not system independent, some systems will require open rather then start . start参数不是独立于系统的,某些系统需要先open ,然后再start Related information on determining os: how-can-i-determine-the-os-of-the-system-from-within-a-lua-script 有关确定操作系统的相关信息: 我如何从lua脚本中确定系统的操作系统

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM