Home >Backend Development >Golang >Can golang call lua?

Can golang call lua?

尚
Original
2020-03-12 16:59:453769browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn