The base table is how they should be. But I need to do this by function, how can I do this?
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 }
A table should be based on external parameters and encode one table for each parameter variable - not the best way. I make a function for this, they must create basic parameters, such as a title or description and pop-ups, and insert values ββinto the button table (if the option is enabled, the add button). But here is the problem, they will not insert into the tmp table, the button table and their values ββfor the following parameters.
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, value = "Return"}}); end --table main table.insert(tmp, { caption = "Main Window", description = "test window", popup = true }) return tmp end
How can I fix them?
source share