简体   繁体   English

来自不同lua类的lua中的call函数

[英]call function in lua from different lua class

I have a function 我有一个功能

function f1(msg) return value end

in Lua file A.lua, how i can call this function or the return result of this function from a B.lua Thank you Jp 在Lua文件A.lua中,我如何从B.lua调用此函数或该函数的返回结果谢谢Jp

You use the require function ( http://www.lua.org/pil/8.1.html ) 您使用require函数( http://www.lua.org/pil/8.1.html

require("A")
f1("my message")

As a complement to brianm , you can also 作为对贿赂的补充,您还可以

dofile("A.lua")
f1("blah")

or 要么

local chunk = assert(loadfile("A.lua"))
chunk()
f1("blah")

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

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