如何在Lua语言中创建包含文件? [英] How to create include files in Lua language?

查看:192
本文介绍了如何在Lua语言中创建包含文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Lua(header.lua)中创建一个头文件,然后执行 require 函数加载它。

I want to create a header file in Lua (header.lua), then execute the require function to load it.

如何对我创建的文件执行 require

How do I execute require to a file that I have created?

推荐答案

require "header"

中的要求条目Lua参考手册。文件header.lua必须位于Lua的搜索路径中。

See the require entry in the Lua Reference manual. The file "header.lua" must be somewhere in Lua's search path.

您可以在

You can see (and modify) the path at

package.path

请参阅 package.path 条目在 Lua参考手册

这个wiki页面描述了创建加载模块的方法要求

This wiki page describes ways of creating modules to load with require.

这篇关于如何在Lua语言中创建包含文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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