如何使用LuaBridge从文件加载表?[Lua来自C++]
How do I load a table from a file using LuaBridge? [Lua from C++]
我正在阅读LuaBridge参考手册,但我不明白如何实际加载/读取.loa文件,以便访问其中的表。
这是lua文件(从平铺导出):
return {
version = "1.1",
luaversion = "5.1",
tiledversion = "0.16.0",
orientation = "orthogonal",
renderorder = "right-down",
width = 16,
height = 16,
tilewidth = 32,
tileheight = 32,
nextobjectid = 3,
properties = {},
tilesets = {
{
name = "terrain_atlas",
firstgid = 1,
tilewidth = 32,
tileheight = 32,
spacing = 0,
margin = 0,
image = "../../../../Resources/Tilesets/Atlas/terrain_atlas.png",
imagewidth = 1024,
imageheight = 1024,
tileoffset = {
x = 0,
y = 0
},
properties = {},
terrains = {},
tilecount = 1024,
tiles = {}
}
},
layers = {
{
type = "tilelayer",
name = "Ground",
x = 0,
y = 0,
width = 16,
height = 16,
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {},
encoding = "lua",
data = {
839, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 841,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 872, 936, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 937, 872, 872, 872, 872, 872, 872, 872, 872, 872, 937, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 935, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 936, 872, 872, 937, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 935, 872, 872, 872, 872, 873,
871, 872, 872, 872, 935, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 936, 872, 872, 872, 872, 872, 872, 936, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 937, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 935, 872, 872, 872, 873,
871, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, 873,
903, 904, 904, 904, 904, 904, 904, 904, 904, 904, 904, 904, 904, 904, 904, 905
}
},
{
type = "tilelayer",
name = "Above",
x = 0,
y = 0,
width = 16,
height = 16,
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {},
encoding = "lua",
data = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 938, 0, 0, 0,
0, 0, 0, 0, 907, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 876, 0, 0, 0, 0,
0, 0, 939, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 874, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 939, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
}
}
}
您正在搜索:
f = loadfile("foo.lua")
如手册和参考手册中所述。它读取您的文件并返回f
变量中的对象。
相关文章:
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- 2D数组来自文本输入,中间有空格
- 通过继承类使用来自不同命名空间的运算符
- Cuda C++:设备上的Malloc类,并用来自主机的数据填充它
- C++:来自外部文件的Trivia
- 如何处理来自核心指南检查器的关于gsl::at的静态分析警告
- C++Lua用户数据扰乱了Mathfu浮点值
- 针对遗留库的链接:来自预制makefile的-lgfortranbegin
- 如何在C++中正确引用来自不同类的类的对象?
- Qt中来自不同功能的按钮引用
- C++包含来自 #include "DevEngine/Core.h" 的错误
- Eigen c++ 三角形来自
- 来自 DLL 的函数调用 [表观调用的括号前面的表达式必须具有(指向-)函数类型]
- 来自 Android 应用程序内部的 boost 类型的 boost::wrapexcept<boost::system::system_error> 的未捕获异常
- 使用 LuaBridge 或 Lua 将对象传递给 Lua 函数C++
- 中止信号来自 C++ 中的中止(3) (SIGABRT)
- 在C 函数中打印一个来自LUA的静态变量
- 使用来自C 的LUA,无法打开标准LIB,而没有错误
- 如何使用LuaBridge从文件加载表?[Lua来自C++]
- 来自 C++ 的 Lua 函数