你如何制作一个默认表,然后在制作其他表时使用它?
例子
--default table
Button = {
x = 0,
y = 0,
w = 10,
h = 10,
Texture = "buttonimg.png",
onClick = function() end
}
newbutton = Button {
onClick = function()
print("button 1 pressed")
end
}
newbutton2 = Button {
x = 12,
onClick = function()
print("button 2 pressed")
end
}
newbuttons 将 y、w、h 和纹理设置为默认值,但括号中设置的任何内容都会被覆盖