基本表,应该如何。但是我需要按功能进行操作,我该怎么做?
local mainMenu = {
caption = "Main Window",
description = "test window",
buttons = {
{ id = 1, value = "Info" },
{ id = 2, value = "Return" },
{ id = 3, value = "Ok" },
{ id = 4, value = "Cancel" }
},
popup = true
}
Run Code Online (Sandbox Code Playgroud)
表应基于外部参数,并为每个选项变量编写一个表-更好的方法。我为此创建了一个函数,它们应该创建标题或描述之类的基本选项并弹出,然后将值插入按钮表(如果启用了选项-添加按钮)。但是这里的问题是,它们不会插入到tmp表,buttons表及其下一个选项的值中。
function createMenu()
tmp = {}
--buttons insert
if(config.info) then
table.insert(tmp, {buttons = {id = 1, value = "Info"}});
elseif(config.return) then
table.insert(tmp, {buttons = {id = 2, …Run Code Online (Sandbox Code Playgroud)