1
我很困惑Lua属性在我试图维护的一些代码中如何工作。在此之前,我在Lua文档中花了很多时间。所以......Lua属性访问者
有那些Lua中的表的一个功能,像这样的(我们称其为 '嵌套表' 为例):
function addItem(item)
index = itemTable.getIndex(item.position[1], item.position[2])
itemTable.items[index] = item
end;
a = Xpl3dSwitch { position = { 27, 0, 1, 1} }
itemTable.addItem(a) --doesn't seem to 'register' the position property
而
a = Xpl3dSwitch { }
a.position[0] = 27
a.position[1] = 0
itemTable.addItem(a) --this 'registers' the position properties
...等,似乎工作。为什么位置表不会粘在'嵌套表'示例中?
此外,关于'a = Xpl3dSwitch {}' - 它是一个对象构造函数吗?从Lua的“文档”中不清楚这是什么。
Lua中没有的属性(你的意思是田地?)。此外,'foo {...}'是'foo({...})'的快捷方式(即其函数调用) – 2014-11-02 23:36:33
如果没有清除它,请显示Xpl3dSwitch的代码。 – 2014-11-02 23:43:50
是的,我的意思是......不幸的是,我没有Xpl3dSwitch的完整代码。 – WolfOdrade 2014-11-03 02:52:22