Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'function i register
- Public Function Print(ByVal lua_state As IntPtr) As Integer
- Console.WriteLine(clua.GetString(-1))
- End Function
- 'how i register a function
- clua.RegisterCfunction("print", AddressOf Print)
- Public Sub RegisterCfunction(ByVal refname As String, ByVal func As LuaCFunction)
- register(cLuaState, refname, func)
- End Sub
- Friend Sub register(ByVal lua_state As IntPtr, ByVal name As String, ByVal func As LuaCFunction)
- Dim top As Integer = lua_gettop(lua_state) 'upvalues
- lua_pushcclosure(lua_state, func, top)
- lua_setfield(lua_state, LUA_GLOBALSINDEX, name)
- End Sub
- 'lua code
- function test(duration)
- print('timer started: '..duration..' seconds')
- local inittime = os.time()
- local curtime = os.time()
- while curtime - inittime < duration do
- curtime = os.time()
- coroutine.yield()
- end
- print('timer exited')
- end
- co = coroutine.create(test)
- coroutine.resume(co,5)
- while coroutine.status(co) == 'suspended' do
- coroutine.resume(co)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement