lua 模块 概述 lua 模块类似于封装库 将相应功能封装为一个模块, 可以按照面向对象中的类定义去理解和使用 使用 模块文件示例程序 mod = {} mod.constant = "模块常量" function mod.func1() return "func1" end local function func2() print("local func2") return "func2" end function mod
Step By Step(Lua模块与包) 从Lua 5.1开始,我们可以使用require和module函数来获取和创建Lua中的模块.从使用者的角度来看,一个模块就是一个程序库,可以通过require来加载,之后便得到一个类型为table的全局变量.此时的table就像名字空间一样,可以访问其中的函数和常量,如: 1 require "mod"2 mod.foo()3 local m2 = require "mod2"4 local f = mod2.foo5
lua5.1 模块理解 http://www.lua.org/manual/5.1/manual.html#pdf-module 模块 5.3 – Modules The package library provides basic facilities for loading and building modules in Lua. It exports two of its functions directly in the global environment: require and m