首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb 调用lua函数,该如何解决

2012-06-01 
vb 调用lua函数VB codePrivate Function f(ByVal hState As Long, ByVal x As Long) As StringDim z As St

vb 调用lua函数

VB code
Private Function f(ByVal hState As Long, ByVal x As Long) As String    Dim z As String    Dim hRet As Long    hRet = lua_getglobal(hState, "f")    hRet = lua_pushnumber(hState, x)    hRet = lua_pcall(hState, 1, 1, 0)    If hRet <> 0 Then Debug.Print "error lua_pcall:" & hRet    z = lua_tostring(hState, -1)    hRet = lua_pop(hState, 1)    f = zEnd FunctionPublic Function AddFunc()    Dim hState As Long, hRet As Long    hState = lua_open    If hState <> 0 Then        hRet = luaopen_base(hState)        hRet = luaL_openlibs(hState)        hRet = luaopen_string(hState)        hRet = luaL_dofile(hState, App.Path + "\test.lua")        If hRet = 0 Then            Debug.Print f(hState, 2)        Else            Debug.Print "luaL_dofile:" & hRet        End If        lua_close hState        hState = 0    End IfEnd Function


之前vbgood上有实现异步回调的例子,应该现在的这种调用方式用得多些
另外mdlLua.bas相信很多地方都有,百度下好了

[解决办法]
用来干吗呢?

热点排行