vb加载lua脚本函数
答案:1 悬赏:50 手机版
解决时间 2021-02-08 21:25
- 提问者网友:树红树绿
- 2021-02-08 03:39
vb加载lua脚本函数
最佳答案
- 五星知识达人网友:时间的尘埃
- 2021-02-08 04:35
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 = z
End Function
Public 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 If
End Function
之前vbgood上有实现异步回调的例子,应该现在的这种调用方式用得多些
另外mdlLua.bas相信很多地方都有,百度下好了追问就是因为找不到modLua.bas才来提问的。给发一个modLua.bas吧
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 = z
End Function
Public 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 If
End Function
之前vbgood上有实现异步回调的例子,应该现在的这种调用方式用得多些
另外mdlLua.bas相信很多地方都有,百度下好了追问就是因为找不到modLua.bas才来提问的。给发一个modLua.bas吧
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯