存储的Lua功能? [英] Store a Lua function?

查看:74
本文介绍了存储的Lua功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C中调用一个Lua函数是相当简单的,但有没有办法<我>商店的一个Lua函数某处以后使用?我要存储用户定义的传递给我的C函数用于对事件的Lua函数,类似连接功能如何wxLua 工作。

Calling a Lua function from C is fairly straight forward but is there a way to store a Lua function somewhere for later use? I want to store user defined Lua functions passed to my C function for use on events, similar to how the Connect function works in wxLua.

推荐答案

检查注册表( luaL_ref())。它管理一个简单的表格,可以存储任何的Lua值(如功能),并通过一个简单的整数指从C到它。

check the registry (luaL_ref()). it manages a simple table that lets you store any Lua value (like the function), and refer to it from C by a simple integer.

这篇关于存储的Lua功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆