lua调用外部lua方法 (lua语言)

来源:互联网 发布:mac os x使用手册 编辑:程序博客网 时间:2024/05/17 12:19

“foo.lua”文件:

function foo (x)

    print(x)

end

function honghong()

print("honghong")

end

--主lua文件

function dofile (filename)

    local f = assert(loadfile(filename))

    return f()

end

dofile("foo.lua")

foo("hello")

honghong()