Home > Article > Backend Development > Can golang call lua?
golang can call lua.
Golang uses golua to call lua scripts:
1: import
import "github.com/aarzilli/golua/lua"
2: Call several important functions of lua scripts
L := lua.NewState() //创建一个lua虚拟机 L.DoFile("./xxx") //设置要调用的lua文件 L.GetField(lua.LUA_GLOBALSINDEX,"xxx") //获取lua脚本的符号 L.Call(arg1,arg2) //调用函数 第一个参数标识参数的个数,第二个参数标识返回值的个数
For more golang knowledge, please pay attention to the PHP Chinese websitegolang tutorial column.
The above is the detailed content of Can golang call lua?. For more information, please follow other related articles on the PHP Chinese website!