c++ - What are the functions that look like table in Lua?
问题描述
I'm a beginner in Lua and I just found out some functions look like table (e.g. function love.update(dt)
) in Lua.
I wonder how these functions work. For example, does update
function belong to table love
? If so, should one construct this table somewhere beforehand?
Lastly, I would like to ask how to call these kind of functions from C++. (Please show me an example how to call love.update()
from C++)
解决方案
问题一:更新功能属于表爱吗?
是的。“function love.update(dt)”等于“love.update = function (dt)”。
问题 2:是否应该事先在某处构建此表?
是的。
问题 3:如何从 C++ 中调用这些函数?
我假设可以从全局访问“爱”。
void call_love_update (lua_State* l) {
lua_getglobal(l, "love");
lua_getfield(l, -1, "update");
lua_pushnumber(l, 0.016);
lua_call(l, 1, LUA_MULTRET);
}
推荐阅读
- javascript - 连接不是从网页开始的
- amazon-web-services - 从控制台删除 AWS S3 对象也会删除版本
- r - R, drc 包的 drm() 函数显示负山坡。即使图表描述为增加特征
- python - 有没有办法懒惰地解压无限生成器?
- python - Matplotlib matshow 一个矩阵热图,一维比另一个大得多
- azure-sdk-python - Azure python sdk:从 SAS 令牌复制 blob
- python - Scapy/ARP 请求不适用于多个/范围 IP。仅针对单个 IP 请求
- android - 在 ExoPlayer 中播放加密视频文件时遇到问题,超过几秒钟
- vb.net - 运行 vb.net 代码时,MICR 符号未显示在 Windows 2008 服务器上
- pyspark - 提供有关元数据的信息的不同 pyspark 函数(如 input_file_name() )有哪些?