Lua 中相互调用方法

test.lua

1 function fact(n)
2 if n==0 then
3 return 1
4 else
5 return n*fact(n-1)
6 end
7 end

定义一个fact method

hi.lua

1 dofile("test.lua")
2 n=fact(3)
3 print(n)

dofie加载 test.lua

获取fact方法

调用成功

Debug 输出...ok